How to add python-blosc2 to PyInstaller's spec file?
ShootingStarDragon opened this issue · 1 comments
My googling and chatgpt skills have failed me. I have a simple test importing blosc and after clicking on bloscdir.exe
all it does it loop at the beginning (spamming why is blosc2 failing? BEFORE
), I suspect that importing blosc to the spec file is incorrect.
test code:
blosctest3.py
try:
import time
print("why is blosc2 failing? BEFORE")
import blosc2
print("why is blosc2 failing? AFTER")
time.sleep(1000)
except Exception as e:
print("blosc died died!", e, flush=True)
import traceback
print("full exception", "".join(traceback.format_exception(*sys.exc_info())))
spec for pyinstaller (version ^5.9.0 as per pyproject.toml):
bloscdir.spec
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(
['blosctest3.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=['blosc2'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='bloscdir',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='bloscdir',
)
to build the onedir: python -m PyInstaller bloscdir.spec --clean
I suspect it has something to do with either blosc's __init__
not working right or not bundling the assorted .h files in the include
folder of the environment, like b2nd.h
, blosc2.h
, and the blosc2
folder.
more info:
windows 10
python: 3.9.0
As usual, after the moment I post I find the answer: call multiprocessing.freeze_support
before importing blosc.
pyinstaller/pyinstaller#7470 (comment)
this works:
try:
# Must be done before importing blosc2
import multiprocessing
if __name__ == "__main__":
multiprocessing.freeze_support()
import time
print("why is blosc2 failing? BEFORE, freeze supp")
import blosc2
print("why is blosc2 failing? AFTER")
time.sleep(1000)
except Exception as e:
print("blosc died died!", e, flush=True)
import traceback
print("full exception", "".join(traceback.format_exception(*sys.exc_info())))
Hope this helps someone in the future.