mirror of
https://github.com/blw1138/Zordon.git
synced 2026-02-05 05:36:09 +00:00
Fix pyinstaller spec files
This commit is contained in:
@@ -38,7 +38,8 @@ git clone https://github.com/blw1138/Zordon.git
|
|||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
pip3 install pyinstaller
|
pip3 install pyinstaller
|
||||||
pip3 install pyinstaller_versionfile
|
pip3 install pyinstaller_versionfile
|
||||||
pyinstaller main.spec
|
pyinstaller client.spec
|
||||||
|
pyinstaller server.spec
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
83
client.spec
83
client.spec
@@ -1,25 +1,53 @@
|
|||||||
# -*- mode: python ; coding: utf-8 -*-
|
# -*- mode: python ; coding: utf-8 -*-
|
||||||
from PyInstaller.utils.hooks import collect_all
|
|
||||||
|
|
||||||
# - get version from version file
|
from PyInstaller.utils.hooks import collect_all
|
||||||
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import platform
|
import platform
|
||||||
src_path = os.path.abspath("src")
|
|
||||||
sys.path.insert(0, src_path)
|
|
||||||
from version import APP_NAME, APP_VERSION, APP_AUTHOR
|
|
||||||
sys.path.insert(0, os.path.abspath('.'))
|
|
||||||
|
|
||||||
datas = [('resources', 'resources'), ('src/engines/blender/scripts/', 'src/engines/blender/scripts')]
|
# ------------------------------------------------------------
|
||||||
|
# Project paths
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
project_root = Path(SPECPATH).resolve()
|
||||||
|
src_dir = project_root / "src"
|
||||||
|
|
||||||
|
# Ensure `src.*` imports work during analysis
|
||||||
|
sys.path.insert(0, str(project_root))
|
||||||
|
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# Import version info
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
from src.version import APP_NAME, APP_VERSION, APP_AUTHOR
|
||||||
|
|
||||||
|
APP_NAME = f"{APP_NAME}-client"
|
||||||
|
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# PyInstaller data / imports
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
datas = [
|
||||||
|
("resources", "resources"),
|
||||||
|
("src/engines/blender/scripts", "src/engines/blender/scripts"),
|
||||||
|
]
|
||||||
|
|
||||||
binaries = []
|
binaries = []
|
||||||
hiddenimports = ['zeroconf']
|
hiddenimports = ["zeroconf", "src.version"]
|
||||||
tmp_ret = collect_all('zeroconf')
|
|
||||||
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
|
|
||||||
|
|
||||||
|
tmp_ret = collect_all("zeroconf")
|
||||||
|
datas += tmp_ret[0]
|
||||||
|
binaries += tmp_ret[1]
|
||||||
|
hiddenimports += tmp_ret[2]
|
||||||
|
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# Analysis
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
a = Analysis(
|
a = Analysis(
|
||||||
['client.py'],
|
["client.py"],
|
||||||
pathex=[],
|
pathex=[str(project_root)],
|
||||||
binaries=binaries,
|
binaries=binaries,
|
||||||
datas=datas,
|
datas=datas,
|
||||||
hiddenimports=hiddenimports,
|
hiddenimports=hiddenimports,
|
||||||
@@ -28,11 +56,16 @@ a = Analysis(
|
|||||||
runtime_hooks=[],
|
runtime_hooks=[],
|
||||||
excludes=[],
|
excludes=[],
|
||||||
noarchive=False,
|
noarchive=False,
|
||||||
optimize=1, # fyi: optim level 2 breaks on windows
|
optimize=1, # optimize=2 breaks Windows builds
|
||||||
)
|
)
|
||||||
|
|
||||||
pyz = PYZ(a.pure)
|
pyz = PYZ(a.pure)
|
||||||
|
|
||||||
if platform.system() == 'Darwin': # macOS
|
# ------------------------------------------------------------
|
||||||
|
# Platform targets
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
if platform.system() == "Darwin": # macOS
|
||||||
|
|
||||||
exe = EXE(
|
exe = EXE(
|
||||||
pyz,
|
pyz,
|
||||||
@@ -51,23 +84,26 @@ if platform.system() == 'Darwin': # macOS
|
|||||||
codesign_identity=None,
|
codesign_identity=None,
|
||||||
entitlements_file=None,
|
entitlements_file=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
app = BUNDLE(
|
app = BUNDLE(
|
||||||
exe,
|
exe,
|
||||||
a.binaries,
|
a.binaries,
|
||||||
a.datas,
|
a.datas,
|
||||||
strip=True,
|
strip=True,
|
||||||
name=f'{APP_NAME}.app',
|
name=f"{APP_NAME}.app",
|
||||||
icon='resources/Server.png',
|
icon="resources/Server.png",
|
||||||
bundle_identifier=None,
|
bundle_identifier=None,
|
||||||
version=APP_VERSION
|
version=APP_VERSION,
|
||||||
)
|
)
|
||||||
|
|
||||||
elif platform.system() == 'Windows':
|
elif platform.system() == "Windows":
|
||||||
|
|
||||||
import pyinstaller_versionfile
|
import pyinstaller_versionfile
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
version_file_path = os.path.join(tempfile.gettempdir(), 'versionfile.txt')
|
version_file_path = os.path.join(
|
||||||
|
tempfile.gettempdir(), "versionfile.txt"
|
||||||
|
)
|
||||||
|
|
||||||
pyinstaller_versionfile.create_versionfile(
|
pyinstaller_versionfile.create_versionfile(
|
||||||
output_file=version_file_path,
|
output_file=version_file_path,
|
||||||
@@ -77,7 +113,7 @@ elif platform.system() == 'Windows':
|
|||||||
internal_name=APP_NAME,
|
internal_name=APP_NAME,
|
||||||
legal_copyright=f"© {APP_AUTHOR}",
|
legal_copyright=f"© {APP_AUTHOR}",
|
||||||
original_filename=f"{APP_NAME}.exe",
|
original_filename=f"{APP_NAME}.exe",
|
||||||
product_name=APP_NAME
|
product_name=APP_NAME,
|
||||||
)
|
)
|
||||||
|
|
||||||
exe = EXE(
|
exe = EXE(
|
||||||
@@ -97,10 +133,11 @@ elif platform.system() == 'Windows':
|
|||||||
target_arch=None,
|
target_arch=None,
|
||||||
codesign_identity=None,
|
codesign_identity=None,
|
||||||
entitlements_file=None,
|
entitlements_file=None,
|
||||||
version=version_file_path
|
version=version_file_path,
|
||||||
)
|
)
|
||||||
|
|
||||||
else: # linux
|
else: # Linux
|
||||||
|
|
||||||
exe = EXE(
|
exe = EXE(
|
||||||
pyz,
|
pyz,
|
||||||
a.scripts,
|
a.scripts,
|
||||||
@@ -117,5 +154,5 @@ else: # linux
|
|||||||
argv_emulation=False,
|
argv_emulation=False,
|
||||||
target_arch=None,
|
target_arch=None,
|
||||||
codesign_identity=None,
|
codesign_identity=None,
|
||||||
entitlements_file=None
|
entitlements_file=None,
|
||||||
)
|
)
|
||||||
142
server.spec
142
server.spec
@@ -1,24 +1,53 @@
|
|||||||
# -*- mode: python ; coding: utf-8 -*-
|
# -*- mode: python ; coding: utf-8 -*-
|
||||||
from PyInstaller.utils.hooks import collect_all
|
|
||||||
|
|
||||||
# - get version from version file
|
from PyInstaller.utils.hooks import collect_all
|
||||||
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import platform
|
import platform
|
||||||
sys.path.insert(0, os.path.abspath('.'))
|
|
||||||
from version import APP_NAME, APP_VERSION, APP_AUTHOR
|
|
||||||
|
|
||||||
APP_NAME = APP_NAME + " Server"
|
# ------------------------------------------------------------
|
||||||
datas = [('resources', 'resources'), ('src/engines/blender/scripts/', 'src/engines/blender/scripts')]
|
# Project paths
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
project_root = Path(SPECPATH).resolve()
|
||||||
|
src_dir = project_root / "src"
|
||||||
|
|
||||||
|
# Ensure `src.*` imports work during analysis
|
||||||
|
sys.path.insert(0, str(project_root))
|
||||||
|
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# Import version info
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
from src.version import APP_NAME, APP_VERSION, APP_AUTHOR
|
||||||
|
|
||||||
|
APP_NAME = f"{APP_NAME}-server"
|
||||||
|
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# PyInstaller data / imports
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
datas = [
|
||||||
|
("resources", "resources"),
|
||||||
|
("src/engines/blender/scripts", "src/engines/blender/scripts"),
|
||||||
|
]
|
||||||
|
|
||||||
binaries = []
|
binaries = []
|
||||||
hiddenimports = ['zeroconf']
|
hiddenimports = ["zeroconf", "src.version"]
|
||||||
tmp_ret = collect_all('zeroconf')
|
|
||||||
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
|
|
||||||
|
|
||||||
|
tmp_ret = collect_all("zeroconf")
|
||||||
|
datas += tmp_ret[0]
|
||||||
|
binaries += tmp_ret[1]
|
||||||
|
hiddenimports += tmp_ret[2]
|
||||||
|
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# Analysis
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
a = Analysis(
|
a = Analysis(
|
||||||
['server.py'],
|
["server.py"],
|
||||||
pathex=[],
|
pathex=[str(project_root)],
|
||||||
binaries=binaries,
|
binaries=binaries,
|
||||||
datas=datas,
|
datas=datas,
|
||||||
hiddenimports=hiddenimports,
|
hiddenimports=hiddenimports,
|
||||||
@@ -27,16 +56,54 @@ a = Analysis(
|
|||||||
runtime_hooks=[],
|
runtime_hooks=[],
|
||||||
excludes=[],
|
excludes=[],
|
||||||
noarchive=False,
|
noarchive=False,
|
||||||
optimize=1, # fyi: optim level 2 breaks on windows
|
optimize=1, # optimize=2 breaks Windows builds
|
||||||
)
|
)
|
||||||
|
|
||||||
pyz = PYZ(a.pure)
|
pyz = PYZ(a.pure)
|
||||||
|
|
||||||
if platform.system() == 'Windows':
|
# ------------------------------------------------------------
|
||||||
|
# Platform targets
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
if platform.system() == "Darwin": # macOS
|
||||||
|
|
||||||
|
exe = EXE(
|
||||||
|
pyz,
|
||||||
|
a.scripts,
|
||||||
|
[],
|
||||||
|
exclude_binaries=True,
|
||||||
|
name=APP_NAME,
|
||||||
|
debug=False,
|
||||||
|
bootloader_ignore_signals=False,
|
||||||
|
strip=True,
|
||||||
|
upx=True,
|
||||||
|
console=False,
|
||||||
|
disable_windowed_traceback=False,
|
||||||
|
argv_emulation=False,
|
||||||
|
target_arch=None,
|
||||||
|
codesign_identity=None,
|
||||||
|
entitlements_file=None,
|
||||||
|
)
|
||||||
|
|
||||||
|
app = BUNDLE(
|
||||||
|
exe,
|
||||||
|
a.binaries,
|
||||||
|
a.datas,
|
||||||
|
strip=True,
|
||||||
|
name=f"{APP_NAME}.app",
|
||||||
|
icon="resources/Server.png",
|
||||||
|
bundle_identifier=None,
|
||||||
|
version=APP_VERSION,
|
||||||
|
)
|
||||||
|
|
||||||
|
elif platform.system() == "Windows":
|
||||||
|
|
||||||
import pyinstaller_versionfile
|
import pyinstaller_versionfile
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
version_file_path = os.path.join(tempfile.gettempdir(), 'versionfile.txt')
|
version_file_path = os.path.join(
|
||||||
|
tempfile.gettempdir(), "versionfile.txt"
|
||||||
|
)
|
||||||
|
|
||||||
pyinstaller_versionfile.create_versionfile(
|
pyinstaller_versionfile.create_versionfile(
|
||||||
output_file=version_file_path,
|
output_file=version_file_path,
|
||||||
@@ -46,30 +113,9 @@ if platform.system() == 'Windows':
|
|||||||
internal_name=APP_NAME,
|
internal_name=APP_NAME,
|
||||||
legal_copyright=f"© {APP_AUTHOR}",
|
legal_copyright=f"© {APP_AUTHOR}",
|
||||||
original_filename=f"{APP_NAME}.exe",
|
original_filename=f"{APP_NAME}.exe",
|
||||||
product_name=APP_NAME
|
product_name=APP_NAME,
|
||||||
)
|
)
|
||||||
|
|
||||||
exe = EXE(
|
|
||||||
pyz,
|
|
||||||
a.scripts,
|
|
||||||
a.binaries,
|
|
||||||
a.datas,
|
|
||||||
[],
|
|
||||||
name=APP_NAME,
|
|
||||||
debug=False,
|
|
||||||
bootloader_ignore_signals=False,
|
|
||||||
strip=True,
|
|
||||||
upx=True,
|
|
||||||
console=True,
|
|
||||||
disable_windowed_traceback=False,
|
|
||||||
argv_emulation=False,
|
|
||||||
target_arch=None,
|
|
||||||
codesign_identity=None,
|
|
||||||
entitlements_file=None,
|
|
||||||
version=version_file_path
|
|
||||||
)
|
|
||||||
|
|
||||||
else: # linux / macOS
|
|
||||||
exe = EXE(
|
exe = EXE(
|
||||||
pyz,
|
pyz,
|
||||||
a.scripts,
|
a.scripts,
|
||||||
@@ -86,5 +132,27 @@ else: # linux / macOS
|
|||||||
argv_emulation=False,
|
argv_emulation=False,
|
||||||
target_arch=None,
|
target_arch=None,
|
||||||
codesign_identity=None,
|
codesign_identity=None,
|
||||||
entitlements_file=None
|
entitlements_file=None,
|
||||||
|
version=version_file_path,
|
||||||
|
)
|
||||||
|
|
||||||
|
else: # Linux
|
||||||
|
|
||||||
|
exe = EXE(
|
||||||
|
pyz,
|
||||||
|
a.scripts,
|
||||||
|
a.binaries,
|
||||||
|
a.datas,
|
||||||
|
[],
|
||||||
|
name=APP_NAME,
|
||||||
|
debug=False,
|
||||||
|
bootloader_ignore_signals=False,
|
||||||
|
strip=True,
|
||||||
|
upx=True,
|
||||||
|
console=False,
|
||||||
|
disable_windowed_traceback=False,
|
||||||
|
argv_emulation=False,
|
||||||
|
target_arch=None,
|
||||||
|
codesign_identity=None,
|
||||||
|
entitlements_file=None,
|
||||||
)
|
)
|
||||||
Reference in New Issue
Block a user