This Python script can be run locally, but after being packaged with pyinstaller, it has been stuck in an endless loop. Is there a problem with packaging?
Python 3.9.6
pyinstaller==5.13.0
pytest==7.4.0
pytest-xdist==3.3.1
My code:
test_case.py
import pytest
def test_example1():
assert 1==1
def test_example2():
assert 1 + 1 == 2
if __name__ == "__main__":
pytest.main(["-n", "1"])
test_case.spec
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(
['test_case.py'],
pathex=[],
binaries=[],
datas=[
('D:/Anaconda/envs/python3.9/Lib/site-packages/apipkg', './apipkg'),
('D:/Anaconda/envs/python3.9/Lib/site-packages/apipkg-3.0.2.dist-info', './apipkg-3.0.2.dist-info'),
('D:/Anaconda/envs/python3.9/Lib/site-packages/pytest_xdist-3.3.1.dist-info', './pytest_xdist-3.3.1.dist-info'),
('D:/Anaconda/envs/python3.9/Lib/site-packages/xdist', './xdist'),
('D:/Anaconda/envs/python3.9/Lib/site-packages/execnet', './execnet'),
('D:/Anaconda/envs/python3.9/Lib/site-packages/execnet-2.0.2.dist-info', './execnet-2.0.2.dist-info'),
],
hiddenimports=[],
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,
a.binaries,
a.zipfiles,
a.datas,
[],
name='test_case',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
It was always running before.
I have tried using different versions of packages, but none of them worked.
I asked to the pyinstaller support and here you can find an answer to your question: https://github.com/pyinstaller/pyinstaller/issues/8283
I then wanted to make pyinstaller work with the BaseCase class and I proceeded like this (I wanted to include aaa.py in my bundle):
In the BaseCase.main I had to modify this method:
because the sys.executable (instead of "python") referred to the .exe (done by Pyinstaller)