Skip to content

Commit 2c325f2

Browse files
committed
added --onefile option to build script
1 parent bc227ea commit 2c325f2

File tree

3 files changed

+41
-15
lines changed

3 files changed

+41
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ or
2222

2323
[Releases](https://github.com/precise-simulation/mesh-viewer/releases)
2424
as stand-alone executables are available, and can be built using
25-
_Pyinstaller_ and the [build/build-exe.py](https://github.com/precise-simulation/mesh-viewer/blob/master/build/build-exe.py)
25+
_Pyinstaller_ and the [build/build.py](https://github.com/precise-simulation/mesh-viewer/blob/master/build/build-exe.py)
2626
script.
2727

2828
# Dependencies

build/build-exe.py renamed to build/build.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"""
22
This is an example of using PyInstaller packager to build
3-
an executable for meshviewer with plotly/cef.
3+
stand-alone executable for meshviewer with plotly/cef.
44
55
Adapted from https://github.com/cztomczak/cefpython/tree/master/examples/pyinstaller
66
77
To package example type: `python build-pyinstaller.py`.
8+
Accepts optional command line arguments --debug and --onefile
89
"""
910

1011
import os
@@ -53,6 +54,10 @@ def main():
5354
env = os.environ
5455
if "--debug" in sys.argv:
5556
env["CEFPYTHON_PYINSTALLER_DEBUG"] = "1"
57+
58+
if "--onefile" in sys.argv:
59+
env["CEFPYTHON_PYINSTALLER_ONEFILE"] = "1"
60+
5661
sub = Popen(["pyinstaller", "--clean", "meshviewer_plotly_cef_tk.spec"], env=env)
5762
sub.communicate()
5863
rcode = sub.returncode
@@ -65,7 +70,10 @@ def main():
6570

6671
# Make sure everything went fine
6772
curdir = os.path.dirname(os.path.abspath(__file__))
68-
app_dir = os.path.join(curdir, "dist")
73+
if "--onefile" in sys.argv:
74+
app_dir = os.path.join(curdir, "dist")
75+
else:
76+
app_dir = os.path.join(curdir, "dist", APP)
6977
executable = os.path.join(app_dir, APP+EXE_EXT)
7078
if not os.path.exists(executable):
7179
print("Error: PyInstaller failed, main executable is missing: %s"

build/meshviewer_plotly_cef_tk.spec

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ from PyInstaller.archive.pyz_crypto import PyiBlockCipher
1313

1414
# Constants
1515
DEBUG = os.environ.get("CEFPYTHON_PYINSTALLER_DEBUG", False)
16+
ONEFILE = os.environ.get("CEFPYTHON_PYINSTALLER_ONEFILE", False)
1617

1718
# ----------------------------------------------------------------------------
1819
# Main
@@ -32,15 +33,32 @@ if not os.environ.get("PYINSTALLER_CEFPYTHON3_HOOK_SUCCEEDED", None):
3233
pyz = PYZ(a.pure,
3334
a.zipped_data)
3435

35-
exe = EXE(pyz,
36-
a.scripts,
37-
a.binaries,
38-
a.zipfiles,
39-
a.datas,
40-
name="meshviewer",
41-
debug=DEBUG,
42-
strip=False,
43-
upx=False,
44-
windowed=True,
45-
console=DEBUG,
46-
icon=False)
36+
if ONEFILE:
37+
exe = EXE(pyz,
38+
a.scripts,
39+
a.binaries,
40+
a.zipfiles,
41+
a.datas,
42+
name="meshviewer",
43+
debug=DEBUG,
44+
strip=False,
45+
upx=False,
46+
console=DEBUG,
47+
icon=False)
48+
else:
49+
exe = EXE(pyz,
50+
a.scripts,
51+
exclude_binaries=True,
52+
name="meshviewer",
53+
debug=DEBUG,
54+
strip=False,
55+
upx=False,
56+
console=DEBUG)
57+
58+
COLLECT(exe,
59+
a.binaries,
60+
a.zipfiles,
61+
a.datas,
62+
strip=False,
63+
upx=False,
64+
name="meshviewer")

0 commit comments

Comments
 (0)