Below is the game.spec file that I have created.
When running the below command, the app gets created perfectly
pyinstaller --onefile game.spec
When operating the game, it is unable to locate any of the datafiles. On further exploration found that it searches for all the datafiles in the directory /Users/username and not from the absolute path the program runs from.
Does the spec file need to be written differently?
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['game.py'],
pathex=['/Users/username/pythonenv/mygame'],
binaries=[],
datas=[('images','images'),
('fonts','fonts'),
('sounds','sounds'),
('pygame','pygame'),
('pygameMenu','pygameMenu'),
('pgzero','pgzero'),
('numpy','numpy'),
('pgzrun.py','.')],
hiddenimports=[],
hookspath=[],
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='game',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='game')
app = BUNDLE(coll,
name='game.app',
icon=None,
bundle_identifier=None)
Question&Answers:
os