fix(packaging): bundle setuptools/_vendor for frozen pkg_resources

Setuptools 80+ pkg_resources imports jaraco.* and platformdirs after
adding setuptools/_vendor to sys.path. PyInstaller onefile did not ship
that tree, causing ModuleNotFoundError: jaraco at pyi_rth_pkgres.
Include the full _vendor directory as datas; add platformdirs to
hiddenimports. Applied to windows, linux, and macos specs.

Made-with: Cursor
This commit is contained in:
Sceef
2026-04-02 14:59:09 +07:00
parent f28e4e3384
commit 57b686c841
3 changed files with 27 additions and 3 deletions

View File

@@ -10,7 +10,13 @@ block_cipher = None
# customtkinter ships JSON themes + assets that must be bundled
import customtkinter
import setuptools
ctk_path = os.path.dirname(customtkinter.__file__)
_vendor = os.path.join(os.path.dirname(setuptools.__file__), '_vendor')
_setuptools_vendor = (
[(_vendor, os.path.join('setuptools', '_vendor'))]
if os.path.isdir(_vendor) else [])
# Collect gi (PyGObject) submodules and data so pystray._appindicator works
gi_hiddenimports = collect_submodules('gi')
@@ -26,7 +32,7 @@ a = Analysis(
[os.path.join(os.path.dirname(SPEC), os.pardir, 'linux.py')],
pathex=[],
binaries=[],
datas=[(ctk_path, 'customtkinter/')] + gi_datas + typelib_datas,
datas=[(ctk_path, 'customtkinter/')] + _setuptools_vendor + gi_datas + typelib_datas,
hiddenimports=[
'pystray._appindicator',
'PIL._tkinter_finder',
@@ -35,6 +41,7 @@ a = Analysis(
'cryptography.hazmat.primitives.ciphers.algorithms',
'cryptography.hazmat.primitives.ciphers.modes',
'cryptography.hazmat.backends.openssl',
'platformdirs',
'gi',
'_gi',
'gi.repository.GLib',