Skip to content

Commit abe0af3

Browse files
committed
Update appimage build to include fontconfig and fix lib placement
1 parent 7a1d9a3 commit abe0af3

4 files changed

Lines changed: 168 additions & 97 deletions

File tree

main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
1010
@author: jrm
1111
"""
12+
1213
from declaracad import main
13-
1414

15-
if __name__ == '__main__':
15+
if __name__ == "__main__":
1616
main()

makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ docs:
22
cd docs
33
make html
44
isort:
5-
isort --profile=black declaracad tests
5+
isort --profile=black declaracad tests *.py
66
typecheck:
77
mypy declaracad tests --ignore-missing-imports
88
lintcheck:
9-
flake8 --ignore=E501,E203,W503 declaracad tests
9+
flake8 --ignore=E501,E203,W503 declaracad tests *.py
1010
reformat:
11-
black declaracad tests
12-
clang-format -i src/*.cpp
13-
clang-format -i src/*.h
11+
black declaracad tests *.py
12+
#clang-format -i src/*.cpp
13+
#clang-format -i src/*.h
1414
test:
1515
pytest -v tests --cov declaracad --cov-report xml --asyncio-mode auto
1616
cleancache:

release.py

Lines changed: 154 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,53 @@
99
1010
@author
1111
"""
12+
13+
import importlib
1214
import os
1315
import sys
16+
from glob import glob
17+
from os.path import dirname
18+
from pathlib import Path
19+
1420
import enaml
15-
import importlib
21+
from cx_Freeze import Executable, hooks, setup
22+
from cx_Freeze.hooks.qthooks import (
23+
IS_WINDOWS,
24+
QtHook,
25+
_get_qt_files,
26+
_qt_implementation,
27+
)
28+
1629
import declaracad
17-
import shutil
18-
from pathlib import Path
19-
from glob import glob
20-
from os.path import dirname, split, exists
21-
from cx_Freeze import hooks, setup, Executable
30+
31+
32+
def patch_cx_freeze():
33+
# Patch to fix all libs getting placed in the PySide6 folder
34+
if IS_WINDOWS:
35+
return
36+
37+
def qt_qtcore_patched(self, finder, module) -> None:
38+
"""Include plugins for the module."""
39+
name = _qt_implementation(module)
40+
for source, target in _get_qt_files(name, "LibrariesPath", "libQt*.so*"):
41+
finder.lib_files.setdefault(source, target.as_posix())
42+
43+
QtHook.qt_qtcore = qt_qtcore_patched
2244

2345

2446
def load_declaracad(finder, module):
2547
import OCCT
2648

2749
root = dirname(dirname(dirname(OCCT.__path__[0])))
28-
if sys.platform == 'win32':
29-
root = os.path.join(root, 'Library', 'lib')
50+
if sys.platform == "win32":
51+
root = os.path.join(root, "Library", "lib")
3052

31-
if sys.platform == 'win32':
32-
patterns = ['*.lib']
33-
elif sys.platform == 'darwin':
34-
patterns = ['*.dylib']
53+
if sys.platform == "win32":
54+
patterns = ["*.lib"]
55+
elif sys.platform == "darwin":
56+
patterns = ["*.dylib"]
3557
else:
36-
patterns = ['*.so*']
58+
patterns = ["*.so*"]
3759

3860
# Keep all libraries in venv/lib
3961
for pattern in patterns:
@@ -42,22 +64,22 @@ def load_declaracad(finder, module):
4264
finder.lib_files.setdefault(source, target)
4365
finder.include_module("declaracad")
4466

67+
4568
# Normal import does not work
4669
hooks.load_declaracad = load_declaracad
4770

4871

4972
def find_enaml_files(*modules):
50-
""" Find .enaml files to include in the zip """
73+
"""Find .enaml files to include in the zip"""
5174
files = {}
5275
for name in modules:
5376
mod = importlib.import_module(name)
5477
mod_path = dirname(mod.__file__)
5578
pkg_root = dirname(mod_path)
5679

57-
for file_type in ['enaml', 'png']:
58-
for f in glob('{}/**/*.{}'.format(mod_path, file_type),
59-
recursive=True):
60-
pkg = f.replace(pkg_root+os.path.sep, '')
80+
for file_type in ["enaml", "png"]:
81+
for f in glob("{}/**/*.{}".format(mod_path, file_type), recursive=True):
82+
pkg = f.replace(pkg_root + os.path.sep, "")
6183
files[f] = pkg
6284

6385
return files.items()
@@ -66,103 +88,149 @@ def find_enaml_files(*modules):
6688
def find_data_files(*modules):
6789
files = {}
6890
for name in modules:
69-
mod = importlib.import_module(name)
7091
mod_path = name
7192
pkg_root = name
7293

73-
for f in glob('{}/**/*.png'.format(mod_path), recursive=True):
74-
pkg = f.replace(pkg_root+os.path.sep, '')
94+
for f in glob("{}/**/*.png".format(mod_path), recursive=True):
95+
pkg = f.replace(pkg_root + os.path.sep, "")
7596
files[f] = pkg
7697
return files.items()
7798

7899

79-
is_windows = sys.platform == 'win32'
100+
def find_fonts() -> list[tuple[str, str]]:
101+
# Include font config on linux
102+
if IS_WINDOWS or "CONDA_PREFIX" not in os.environ:
103+
return []
104+
etc_dir = os.path.join(os.environ["CONDA_PREFIX"], "etc")
105+
return [(os.path.join(etc_dir, "fonts"), "etc/fonts")]
106+
80107

108+
patch_cx_freeze()
81109
with enaml.imports():
82110
setup(
83-
name='declaracad',
111+
name="declaracad",
84112
author="CodeLV",
85113
author_email="frmdstryr@gmail.com",
86-
license='GPLv3',
87-
url='https://github.com/codelv/declaracad/',
114+
license="GPLv3",
115+
url="https://github.com/codelv/declaracad/",
88116
description="A declarative parametric 3D modeling application",
89117
long_description=open("README.md").read(),
90118
version=declaracad.version,
91119
options=dict(
92120
build_exe=dict(
93121
packages=[
94-
'declaracad',
95-
'enaml',
96-
'enamlx',
97-
"parso", "jedi", # Needed outsize of zip for autocomplete to work
98-
'markdown',
99-
'html.parser',
100-
'pygments',
101-
'ipykernel',
102-
'zmq.utils.garbage', # Needed for embedded qt console
122+
"declaracad",
123+
"enaml",
124+
"enamlx",
125+
"parso",
126+
"jedi", # Needed outsize of zip for autocomplete to work
127+
"markdown",
128+
"html.parser",
129+
"pygments",
130+
"ipykernel",
131+
"zmq.utils.garbage", # Needed for embedded qt console
103132
],
133+
include_files=find_fonts(),
104134
zip_include_packages=[
105-
'asttokens',
106-
'asyncqtpy',
107-
'asyncio',
108-
'attr',
109-
'backcall',
110-
'bytecode',
111-
'curses', 'chardet', 'collections', 'concurrent', 'ctypes',
112-
'colorama', 'comm',
113-
'dateutil', 'distutils', 'docutils',
114-
'email',
115-
'executing',
116-
'encodings',
117-
'ezdxf',
118-
'http', 'html', 'fontTools',
119-
'IPython', 'ipython_genutils', 'ipykernel',
120-
'importlib', 'importlib_metadata',
121-
'json', 'jsonpickle', 'jupyter_client', 'jupyter_core',
122-
'jinja2',
123-
'logging',
124-
'numpydoc',
125-
'multiprocessing', 'markdown',
126-
'pathlib', 'pdf4py', 'pygments', 'pluggy', 'prompt_toolkit', 'packaging',
127-
'pytz', 'pydoc_data', 'pycparser', 'ptyprocess', 'pkg_resources', 'platformdirs',
128-
'pyparsing',
129-
'qtpy', 'qtconsole',
130-
're',
131-
'sqlite3', 'sphinx', 'serial', 'scipy', 'stack_data', 'sysconfig',
132-
'traitlets', 'tornado', 'toml', 'test', 'tomlib',
133-
'unittest', 'urllib',
134-
'wcwidth',
135-
'zipfile',
136-
'xml', 'xmlrpc',
137-
'_distutils_hack',
135+
"asttokens",
136+
"asyncqtpy",
137+
"asyncio",
138+
"attr",
139+
"backcall",
140+
"bytecode",
141+
"curses",
142+
"chardet",
143+
"collections",
144+
"concurrent",
145+
"ctypes",
146+
"colorama",
147+
"comm",
148+
"dateutil",
149+
"distutils",
150+
"docutils",
151+
"email",
152+
"executing",
153+
"encodings",
154+
"ezdxf",
155+
"http",
156+
"html",
157+
"fontTools",
158+
"IPython",
159+
"ipython_genutils",
160+
"ipykernel",
161+
"importlib",
162+
"importlib_metadata",
163+
"json",
164+
"jsonpickle",
165+
"jupyter_client",
166+
"jupyter_core",
167+
"jinja2",
168+
"logging",
169+
"numpydoc",
170+
"multiprocessing",
171+
"markdown",
172+
"pathlib",
173+
"pdf4py",
174+
"pygments",
175+
"pluggy",
176+
"prompt_toolkit",
177+
"packaging",
178+
"pytz",
179+
"pydoc_data",
180+
"pycparser",
181+
"ptyprocess",
182+
"pkg_resources",
183+
"platformdirs",
184+
"pyparsing",
185+
"qtpy",
186+
"qtconsole",
187+
"re",
188+
"sqlite3",
189+
"sphinx",
190+
"serial",
191+
"scipy",
192+
"stack_data",
193+
"sysconfig",
194+
"traitlets",
195+
"tornado",
196+
"toml",
197+
"test",
198+
"tomlib",
199+
"unittest",
200+
"urllib",
201+
"wcwidth",
202+
"zipfile",
203+
"xml",
204+
"xmlrpc",
205+
"_distutils_hack",
138206
],
139-
zip_includes=find_enaml_files('enaml'),
207+
zip_includes=find_enaml_files("enaml"),
140208
excludes=[
141-
'alabaster',
142-
'babel',
143-
'wx',
144-
'tkinter',
145-
'matplotlib', 'matplotlib_inline',
146-
'lib2to3',
147-
'enamlx.qt.qt_occ_viewer',
148-
'zmq.eventloop.minitornado',
149-
'sphinx',
150-
'vtkmodules',
151-
'wheel'
152-
'debugpy',
209+
"alabaster",
210+
"babel",
211+
"wx",
212+
"tkinter",
213+
"matplotlib",
214+
"matplotlib_inline",
215+
"lib2to3",
216+
"enamlx.qt.qt_occ_viewer",
217+
"zmq.eventloop.minitornado",
218+
"sphinx",
219+
"vtkmodules",
220+
"wheel" "debugpy",
153221
],
154222
)
155223
),
156224
executables=[
157225
Executable(
158-
'main.py',
226+
"main.py",
159227
base="gui",
160-
icon='declaracad/res/icons/logo.' + ('ico' if is_windows else 'png'),
161-
target_name='declaracad',
162-
shortcut_name="DeclaraCAD" if is_windows else None,
163-
shortcut_dir="DesktopFolder" if is_windows else None,
228+
icon="declaracad/res/icons/logo." + ("ico" if IS_WINDOWS else "png"),
229+
target_name="declaracad",
230+
shortcut_name="DeclaraCAD" if IS_WINDOWS else None,
231+
shortcut_dir="DesktopFolder" if IS_WINDOWS else None,
164232
# stdout doesn't
165233
# base='Win32GUI' is_windows else None
166234
)
167-
]
235+
],
168236
)

setup.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
The full license is in the file COPYING.txt, distributed with this software.
66
Created on Dec 13, 2017
77
"""
8+
89
import os
910
import re
1011
import sys
11-
from setuptools import setup, find_packages
1212
from glob import glob
1313

14+
from setuptools import find_packages, setup
15+
1416
try:
1517
from pybind11.setup_helpers import Pybind11Extension, build_ext
1618
except ImportError:
@@ -26,7 +28,7 @@
2628
"asyncqtpy", # asyncio + qt
2729
"pyserial>=3.5",
2830
"lxml",
29-
"pyqcodeeditor", # text editor
31+
"pyqcodeeditor", # text editor
3032
"ezdxf",
3133
"pdf4py",
3234
]
@@ -44,6 +46,7 @@ def find_include(name: str) -> str:
4446
prefix = os.path.dirname(os.path.dirname(sys.executable))
4547
return os.path.join(prefix, "include", name)
4648

49+
4750
def find_lib(name: str) -> str:
4851
prefix = os.path.dirname(os.path.dirname(sys.executable))
4952
return os.path.join(prefix, "lib", name)
@@ -84,8 +87,8 @@ def find_pyocct():
8487
os.path.join(pyocct_dir, "src"),
8588
],
8689
libraries=[
87-
#"TKernel", "TKOpenGl", "TKVoxel"
88-
#"Qt6Core",
90+
# "TKernel", "TKOpenGl", "TKVoxel"
91+
# "Qt6Core",
8992
"TKernel",
9093
"TKOpenGl",
9194
"Qt6Gui",

0 commit comments

Comments
 (0)