PyInstaller Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import py5_tools | |
import py5 | |
if hasattr(sys, '_MEIPASS'): | |
print('running through pyinstaller', getattr(sys, '_MEIPASS')) | |
else: | |
print('not running through pyinstaller') | |
print('cwd =', os.getcwd()) | |
print('__file__ =', __file__) | |
def setup(): | |
py5.size(200, 200, py5.P2D) | |
py5.println(py5_tools.get_jvm_debug_info()) | |
def draw(): | |
py5.rect(py5.mouse_x, py5.mouse_y, 10, 10) | |
py5.run_sketch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyInstaller.utils.hooks import collect_submodules, collect_dynamic_libs, collect_data_files | |
datas, binaries, hiddenimports = [], [], [] | |
# add Java 17 | |
datas += [('/usr/lib/jvm/java-17-openjdk', 'JAVA_HOME')] | |
# add Jar files | |
datas += collect_data_files('py5', includes=['**/*.jar']) | |
# add Processing native libraries | |
binaries += collect_dynamic_libs('py5') | |
# add py5 logo image | |
datas += collect_data_files('py5_tools') | |
# add Python source code to give py5 access to setup() source code | |
datas += [('simple.py', '.')] | |
# add a few missing Python libraries | |
hiddenimports += collect_submodules('xmlrpc') | |
datas += collect_data_files('debugpy') | |
# exclude unnecessary Python libraries | |
excludes = ['matplotlib', 'scipy', 'jedi', 'lxml'] | |
block_cipher = None | |
a = Analysis(['simple.py'], | |
pathex=[], | |
binaries=binaries, | |
datas=datas, | |
hiddenimports=hiddenimports, | |
hookspath=[], | |
hooksconfig={}, | |
runtime_hooks=[], | |
excludes=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='simple', | |
debug=False, | |
bootloader_ignore_signals=False, | |
strip=False, | |
upx=True, | |
console=True, | |
disable_windowed_traceback=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='simple') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyInstaller.utils.hooks import collect_submodules, collect_dynamic_libs, collect_data_files | |
datas, binaries, hiddenimports = [], [], [] | |
# add Java 17 | |
datas += [('/usr/lib/jvm/java-17-openjdk', 'JAVA_HOME')] | |
# add Jar files | |
datas += collect_data_files('py5', includes=['**/*.jar']) | |
# add Processing native libraries | |
binaries += collect_dynamic_libs('py5') | |
# add py5 logo image | |
datas += collect_data_files('py5_tools') | |
# add Python source code to give py5 access to setup() source code | |
datas += [('simple.py', '.')] | |
# add a few missing Python libraries | |
hiddenimports += collect_submodules('xmlrpc') | |
datas += collect_data_files('debugpy') | |
# exclude unnecessary Python libraries | |
excludes = ['matplotlib', 'scipy', 'jedi', 'lxml'] | |
block_cipher = None | |
a = Analysis(['simple.py'], | |
pathex=[], | |
binaries=binaries, | |
datas=datas, | |
hiddenimports=hiddenimports, | |
hookspath=[], | |
hooksconfig={}, | |
runtime_hooks=[], | |
excludes=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='simple', | |
debug=False, | |
bootloader_ignore_signals=False, | |
strip=False, | |
upx=True, | |
upx_exclude=[], | |
runtime_tmpdir=None, | |
console=True, | |
disable_windowed_traceback=False, | |
target_arch=None, | |
codesign_identity=None, | |
entitlements_file=None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment