Skip to content

Commit 17bae9e

Browse files
authored
Reworked the PyInstaller Builds (#569)
* Reworked the pyinstaller.spec file * Added workflow file for pyinstaller builds
1 parent 3f5b47b commit 17bae9e

2 files changed

Lines changed: 107 additions & 54 deletions

File tree

.github/workflows/build.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build Executables
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
include:
14+
- os: ubuntu-22.04
15+
artifact: CQ-editor-linux-x86_64
16+
- os: windows-latest
17+
artifact: CQ-editor-windows-x86_64.exe
18+
- os: macos-13
19+
artifact: CQ-editor-macos-x86_64
20+
- os: macos-latest
21+
artifact: CQ-editor-macos-arm64
22+
23+
runs-on: ${{ matrix.os }}
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- uses: actions/setup-python@v5
29+
with:
30+
python-version: '3.11'
31+
32+
- name: Install dependencies
33+
run: |
34+
pip install .
35+
pip install pyinstaller
36+
37+
- name: Build executable
38+
run: pyinstaller pyinstaller.spec
39+
40+
- name: Upload artifact
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: ${{ matrix.artifact }}
44+
path: dist/CQ-editor*
45+
46+
- name: Upload to release
47+
if: github.event_name == 'release'
48+
uses: softprops/action-gh-release@v2
49+
with:
50+
files: dist/CQ-editor*
51+

pyinstaller.spec

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,62 @@
11
# -*- mode: python -*-
22

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
57

68
block_cipher = None
79

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
1139
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

Comments
 (0)