-
Notifications
You must be signed in to change notification settings - Fork 7
/
cq-cli_pyinstaller.spec
106 lines (98 loc) · 3.4 KB
/
cq-cli_pyinstaller.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- mode: python ; coding: utf-8 -*-
import sys, site, os
import glob
from path import Path
from PyInstaller.utils.hooks import collect_submodules
# Whether we are running in onefile or dir mode
onefile_mode = True
if len(sys.argv) == 3:
if sys.argv[2] == 'onefile':
onefile_mode = True
elif sys.argv[2] == 'dir':
onefile_mode = False
block_cipher = None
if sys.platform == 'linux':
occt_dir = os.path.join(Path(sys.prefix), 'share', 'opencascade')
ocp_path = (os.path.join(HOMEPATH, 'OCP.cpython-38-x86_64-linux-gnu.so'), '.')
elif sys.platform == 'darwin':
occt_dir = os.path.join(Path(sys.prefix), 'Library', 'share', 'opencascade')
ocp_path = (os.path.join(HOMEPATH, 'OCP.cpython-38-darwin.so'), '.')
elif sys.platform == 'win32':
occt_dir = os.path.join(Path(sys.prefix), 'Library', 'share', 'opencascade')
ocp_path = (os.path.join(HOMEPATH, 'OCP.cp38-win_amd64.pyd'), '.')
# Dynamically find all the modules in the cqcodecs directory
hidden_imports = []
file_list = glob.glob('.' + os.path.sep + 'src' + os.path.sep + 'cq_cli' + os.path.sep + 'cqcodecs' + os.path.sep + 'cq_codec_*.py')
for file_path in file_list:
file_name = file_path.split(os.path.sep)[-1]
module_name = file_name.replace(".py", "")
hidden_imports.append("cqcodecs." + module_name)
hidden_imports.append('OCP')
hidden_imports.append('typing_extensions')
hidden_imports.append('pyparsing')
hidden_imports.append('ezdxf')
hidden_imports.append('nptyping')
hidden_imports.append('typish')
hidden_imports.append('numpy.core.dtype')
hidden_imports.append('numpy.core._dtype')
hidden_imports.append('vtkmodules')
hidden_imports.append('vtkmodules.all')
# numpy hidden imports
hidden_imports_numpy = collect_submodules('numpy')
hidden_imports = hidden_imports + hidden_imports_numpy
a = Analysis(['src/cq_cli/main.py'],
pathex=['.'],
binaries=[
ocp_path
],
datas=[
(os.path.join(os.path.dirname(os.path.realpath('__file__')), 'src', 'cq_cli', 'cqcodecs'), 'cqcodecs')
],
hiddenimports=hidden_imports,
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)
# Select between onefile and dir mode executables
if onefile_mode:
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='cq-cli',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
upx_exclude=[],
runtime_tmpdir=None,
console=True )
else:
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='cq-cli',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=True )
exclude = ('libGL','libEGL','libbsd')
a.binaries = TOC([x for x in a.binaries if not x[0].startswith(exclude)])
if not onefile_mode:
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name='cq-cli')