|
1 | 1 | # -*- mode: python -*- |
2 | 2 |
|
3 | | -import sys, site, os |
4 | | -from path import Path |
| 3 | +import sys |
| 4 | +from pathlib import Path |
| 5 | +import parso |
| 6 | +from PyInstaller.utils.hooks import collect_data_files |
5 | 7 |
|
6 | 8 | block_cipher = None |
7 | 9 |
|
8 | | -spyder_data = Path(site.getsitepackages()[-1]) / 'spyder' |
9 | | -parso_grammar = (Path(site.getsitepackages()[-1]) / 'parso/python').glob('grammar*') |
10 | | - |
| 10 | +parso_grammar = (Path(parso.__file__).parent / 'python').glob('grammar*') |
| 11 | + |
| 12 | +a = Analysis( |
| 13 | + ['run.py'], |
| 14 | + pathex=['.'], |
| 15 | + binaries=[], |
| 16 | + datas=[ |
| 17 | + ('cq_editor/icons_res.py', 'cq_editor'), |
| 18 | + *[(str(p), 'parso/python') for p in parso_grammar], |
| 19 | + *collect_data_files('debugpy'), |
| 20 | + ], |
| 21 | + hiddenimports=[ |
| 22 | + 'ipykernel.datapub', |
| 23 | + 'pygments.styles.default', |
| 24 | + 'qtconsole.client', |
| 25 | + 'OCP', |
| 26 | + ], |
| 27 | + hookspath=[], |
| 28 | + runtime_hooks=[ |
| 29 | + 'pyinstaller/pyi_rth_fontconfig.py', |
| 30 | + ], |
| 31 | + excludes=['_tkinter', 'spyder'], |
| 32 | + win_no_prefer_redirects=False, |
| 33 | + win_private_assemblies=False, |
| 34 | + cipher=block_cipher, |
| 35 | + noarchive=False, |
| 36 | +) |
| 37 | + |
| 38 | +# Exclude problemmatic Linux system libraries |
11 | 39 | if sys.platform == 'linux': |
12 | | - occt_dir = os.path.join(Path(sys.prefix), 'share', 'opencascade') |
13 | | - ocp_path = (os.path.join(HOMEPATH, 'OCP.cpython-38-x86_64-linux-gnu.so'), '.') |
14 | | -elif sys.platform == 'darwin': |
15 | | - occt_dir = os.path.join(Path(sys.prefix), 'share', 'opencascade') |
16 | | - ocp_path = (os.path.join(HOMEPATH, 'OCP.cpython-38-darwin.so'), '.') |
17 | | -elif sys.platform == 'win32': |
18 | | - occt_dir = os.path.join(Path(sys.prefix), 'Library', 'share', 'opencascade') |
19 | | - ocp_path = (os.path.join(HOMEPATH, 'OCP.cp38-win_amd64.pyd'), '.') |
20 | | - |
21 | | -a = Analysis(['run.py'], |
22 | | - pathex=['.'], |
23 | | - binaries=[ocp_path], |
24 | | - datas=[(spyder_data, 'spyder'), |
25 | | - (occt_dir, 'opencascade')] + |
26 | | - [(p, 'parso/python') for p in parso_grammar], |
27 | | - hiddenimports=['ipykernel.datapub'], |
28 | | - hookspath=[], |
29 | | - runtime_hooks=['pyinstaller/pyi_rth_occ.py', |
30 | | - 'pyinstaller/pyi_rth_fontconfig.py'], |
31 | | - excludes=['_tkinter',], |
32 | | - win_no_prefer_redirects=False, |
33 | | - win_private_assemblies=False, |
34 | | - cipher=block_cipher, |
35 | | - noarchive=False) |
36 | | - |
37 | | -pyz = PYZ(a.pure, a.zipped_data, |
38 | | - cipher=block_cipher) |
39 | | -exe = EXE(pyz, |
40 | | - a.scripts, |
41 | | - [], |
42 | | - exclude_binaries=True, |
43 | | - name='CQ-editor', |
44 | | - debug=False, |
45 | | - bootloader_ignore_signals=False, |
46 | | - strip=False, |
47 | | - upx=True, |
48 | | - console=True, |
49 | | - icon='icons/cadquery_logo_dark.ico') |
50 | | - |
51 | | -exclude = ('libGL','libEGL','libbsd') |
52 | | -a.binaries = TOC([x for x in a.binaries if not x[0].startswith(exclude)]) |
53 | | - |
54 | | -coll = COLLECT(exe, |
55 | | - a.binaries, |
56 | | - a.zipfiles, |
57 | | - a.datas, |
58 | | - strip=False, |
59 | | - upx=True, |
60 | | - name='CQ-editor') |
| 40 | + exclude_libs = ('libGL', 'libEGL', 'libbsd') |
| 41 | + a.binaries = TOC( |
| 42 | + [x for x in a.binaries if not x[0].startswith(exclude_libs)] |
| 43 | + ) |
| 44 | + |
| 45 | +pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) |
| 46 | + |
| 47 | +exe = EXE( |
| 48 | + pyz, |
| 49 | + a.scripts, |
| 50 | + a.binaries, |
| 51 | + a.zipfiles, |
| 52 | + a.datas, |
| 53 | + name='CQ-editor', |
| 54 | + debug=False, |
| 55 | + bootloader_ignore_signals=False, |
| 56 | + strip=False, |
| 57 | + upx=True, |
| 58 | + upx_exclude=[], |
| 59 | + console=False, |
| 60 | + icon='icons/cadquery_logo_dark.ico', |
| 61 | +) |
| 62 | + |
0 commit comments