Fix leftover selenium cert files;
Sys-dependent handling of the site-packages path
This commit is contained in:
1 parent
330eb4f184
commit
c5bf130e4e
2 files changed
+28
-7
No files matched your search
+17
-7
@@ -9,22 +9,31 @@ SELF_PATH = str(Path(".").absolute())
|
|||||||
if SELF_PATH not in sys.path:
|
if SELF_PATH not in sys.path:
|
||||||
sys.path.insert(0, SELF_PATH)
|
sys.path.insert(0, SELF_PATH)
|
||||||
|
|
||||||
from constants import WORKING_DIR, DEFAULT_LANG
|
from constants import WORKING_DIR, SITE_PACKAGES_PATH, DEFAULT_LANG
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from PyInstaller.building.api import PYZ, EXE
|
from PyInstaller.building.api import PYZ, EXE
|
||||||
from PyInstaller.building.build_main import Analysis
|
from PyInstaller.building.build_main import Analysis
|
||||||
|
|
||||||
|
# (source_path, dest_path, required)
|
||||||
datas: list[tuple[str | Path, str]] = [
|
to_add: list[tuple[Path, str, bool]] = [
|
||||||
("pickaxe.ico", '.'), # icon file
|
(Path("pickaxe.ico"), '.', True), # icon file
|
||||||
# SeleniumWire HTTPS/SSL cert file and key
|
# SeleniumWire HTTPS/SSL cert file and key
|
||||||
("./env/Lib/site-packages/seleniumwire/ca.crt", "./seleniumwire"),
|
(Path(SITE_PACKAGES_PATH, "seleniumwire/ca.crt"), "./seleniumwire", False),
|
||||||
("./env/Lib/site-packages/seleniumwire/ca.key", "./seleniumwire"),
|
(Path(SITE_PACKAGES_PATH, "seleniumwire/ca.key"), "./seleniumwire", False),
|
||||||
]
|
]
|
||||||
for lang_filepath in WORKING_DIR.joinpath("lang").glob("*.json"):
|
for lang_filepath in WORKING_DIR.joinpath("lang").glob("*.json"):
|
||||||
if lang_filepath.stem != DEFAULT_LANG:
|
if lang_filepath.stem != DEFAULT_LANG:
|
||||||
datas.append((lang_filepath, "lang"))
|
to_add.append((lang_filepath, "lang", True))
|
||||||
|
|
||||||
|
# ensure the required to-be-added data exists
|
||||||
|
datas: list[tuple[Path, str]] = []
|
||||||
|
for source_path, dest_path, required in to_add:
|
||||||
|
if source_path.exists():
|
||||||
|
datas.append((source_path, dest_path))
|
||||||
|
elif required:
|
||||||
|
raise FileNotFoundError(str(source_path))
|
||||||
|
|
||||||
|
|
||||||
block_cipher = None
|
block_cipher = None
|
||||||
a = Analysis(
|
a = Analysis(
|
||||||
@@ -41,6 +50,7 @@ a = Analysis(
|
|||||||
"setuptools._distutils.dir_util",
|
"setuptools._distutils.dir_util",
|
||||||
"setuptools._distutils.file_util",
|
"setuptools._distutils.file_util",
|
||||||
"setuptools._distutils.archive_util",
|
"setuptools._distutils.archive_util",
|
||||||
|
"PIL._tkinter_finder",
|
||||||
],
|
],
|
||||||
runtime_hooks=[],
|
runtime_hooks=[],
|
||||||
cipher=block_cipher,
|
cipher=block_cipher,
|
||||||
|
|||||||
@@ -22,6 +22,14 @@ IS_PACKAGED = hasattr(sys, "_MEIPASS")
|
|||||||
# logging special levels
|
# logging special levels
|
||||||
CALL = logging.INFO - 1
|
CALL = logging.INFO - 1
|
||||||
logging.addLevelName(CALL, "CALL")
|
logging.addLevelName(CALL, "CALL")
|
||||||
|
# site-packages venv path changes depending on the system platform
|
||||||
|
if sys.platform == "win32":
|
||||||
|
SYS_SITE_PACKAGES = "Lib/site-packages"
|
||||||
|
else:
|
||||||
|
# On Linux, the site-packages path includes a versioned 'pythonX.Y' folder part
|
||||||
|
# The Lib folder is also spelled in lowercase: 'lib'
|
||||||
|
version_info = sys.version_info
|
||||||
|
SYS_SITE_PACKAGES = f"lib/python{version_info.major}.{version_info.minor}/site-packages"
|
||||||
|
|
||||||
|
|
||||||
def _resource_path(relative_path: Path | str) -> Path:
|
def _resource_path(relative_path: Path | str) -> Path:
|
||||||
@@ -46,6 +54,9 @@ SELF_PATH = Path(sys.argv[0]).absolute()
|
|||||||
if SELF_PATH.stem == "pyinstaller":
|
if SELF_PATH.stem == "pyinstaller":
|
||||||
SELF_PATH = Path(__file__).with_name("main.py").absolute()
|
SELF_PATH = Path(__file__).with_name("main.py").absolute()
|
||||||
WORKING_DIR = SELF_PATH.absolute().parent
|
WORKING_DIR = SELF_PATH.absolute().parent
|
||||||
|
# Development paths
|
||||||
|
VENV_PATH = Path(WORKING_DIR, "env")
|
||||||
|
SITE_PACKAGES_PATH = Path(VENV_PATH, SYS_SITE_PACKAGES)
|
||||||
# Translations path
|
# Translations path
|
||||||
# NOTE: These don't have to be available to the end-user, so the path points to the internal dir
|
# NOTE: These don't have to be available to the end-user, so the path points to the internal dir
|
||||||
LANG_PATH = _resource_path("lang")
|
LANG_PATH = _resource_path("lang")
|
||||||
|
|||||||
Reference in new issue
Block a user