Skip to content

Commit

Permalink
fix: SSL context in the binary
Browse files Browse the repository at this point in the history
Cannot download PyPandoc, using urllib.
  • Loading branch information
clemlesne committed Nov 7, 2024
1 parent ff848e9 commit 62979a5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
13 changes: 5 additions & 8 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import re
import string
import sys
from os import environ as env
from platform import python_version

import click
Expand Down Expand Up @@ -568,14 +567,12 @@ def _job_name(job_name: str | None) -> str:
)


if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"): # Running in PyInstaller
import certifi
# If running in PyInstaller
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
# Make sure all SSL certificates come from the system truststore
import truststore

# Path the bundle with certifi
# See: https://github.com/Azure/azure-iot-sdk-python/issues/991#issuecomment-1118235694
# See: https://github.com/pyinstaller/pyinstaller/issues/7229#issuecomment-1309406736
# See: https://github.com/pyinstaller/pyinstaller/issues/6352#issuecomment-962499220
env["SSL_CERT_FILE"] = certifi.where()
truststore.inject_into_ssl()

# Run the CLI
cli(sys.argv[1:])
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies = [
"python-dotenv~=1.0",
"tenacity~=9.0",
"tiktoken~=0.7",
"truststore~=0.10",
]

[project.optional-dependencies]
Expand Down Expand Up @@ -70,9 +71,6 @@ DEP002 = [
"aiodns", # Async DNS resolver for aiohttp
"aiohttp", # Async HTTP client for Azure SDKs
]
DEP003 = [
"certifi", # Patch for CA certificates when built with PyInstaller
]

[tool.ruff]
target-version = "py312"
Expand Down
4 changes: 4 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,10 @@ tqdm==4.67.0 \
--hash=sha256:0cd8af9d56911acab92182e88d763100d4788bdf421d251616040cc4d44863be \
--hash=sha256:fe5a6f95e6fe0b9755e9469b77b9c3cf850048224ecaa8293d7d2d31f97d869a
# via openai
truststore==0.10.0 \
--hash=sha256:5da347c665714fdfbd46f738c823fe9f0d8775e41ac5fb94f325749091187896 \
--hash=sha256:b3798548e421ffe2ca2a6217cca49e7a17baf40b72d86a5505dc7d701e77d15b
# via scrape-it-now (pyproject.toml)
typing-extensions==4.12.2 \
--hash=sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d \
--hash=sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,10 @@ tqdm==4.67.0 \
--hash=sha256:0cd8af9d56911acab92182e88d763100d4788bdf421d251616040cc4d44863be \
--hash=sha256:fe5a6f95e6fe0b9755e9469b77b9c3cf850048224ecaa8293d7d2d31f97d869a
# via openai
truststore==0.10.0 \
--hash=sha256:5da347c665714fdfbd46f738c823fe9f0d8775e41ac5fb94f325749091187896 \
--hash=sha256:b3798548e421ffe2ca2a6217cca49e7a17baf40b72d86a5505dc7d701e77d15b
# via scrape-it-now (pyproject.toml)
typing-extensions==4.12.2 \
--hash=sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d \
--hash=sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8
Expand Down

0 comments on commit 62979a5

Please sign in to comment.