cutienator 0.0.1.dev0__tar.gz → 0.0.1.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cutienator-0.0.1.dev0/src/cutienator.egg-info → cutienator-0.0.1.dev1}/PKG-INFO +2 -2
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/README.md +1 -1
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/pyproject.toml +1 -1
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/__init__.py +1 -1
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/occult/__init__.py +8 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/occult/_build.py +71 -24
- cutienator-0.0.1.dev1/src/cutienator/occult/_linux.py +139 -0
- cutienator-0.0.1.dev1/src/cutienator/occult/_mac.py +154 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/occult/_rituals.py +11 -6
- cutienator-0.0.1.dev1/src/cutienator/occult/_system.py +251 -0
- cutienator-0.0.1.dev1/src/cutienator/occult/_windows.py +178 -0
- cutienator-0.0.1.dev1/src/cutienator/occult/rituals/q_event.cpp +81 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/occult/rituals/q_meta_object.cpp +50 -36
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/occult/rituals/q_object.cpp +56 -36
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/trial/_judge.py +19 -8
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1/src/cutienator.egg-info}/PKG-INFO +2 -2
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator.egg-info/SOURCES.txt +6 -0
- cutienator-0.0.1.dev1/tests/test_build.py +92 -0
- cutienator-0.0.1.dev1/tests/test_system.py +171 -0
- cutienator-0.0.1.dev0/src/cutienator/occult/rituals/q_event.cpp +0 -70
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/LICENSE +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/setup.cfg +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_cpp_addr.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_cpp_box.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_cute_load_hook.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_cute_mixin.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_cute_overload.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_cute_space.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_header_descriptor.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_meta_cute.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_q_binding_storage.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_q_event.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_q_meta_object.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_q_object.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_q_thread.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_q_widget.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_ugly.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_wait.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/_waiting_overload.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/example/__init__.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/example/__main__.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/example/_calls.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/occult/__main__.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/occult/_base_meta_ugly.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/occult/_cognito_warning.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/occult/_declaration.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/occult/_header.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/occult/_ritual.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/occult/_shared_object.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/occult/_symbol.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/trial/__init__.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/trial/__main__.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/trial/_q_object_trials.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/trial/_trial.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator/trial/_verdict.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator.egg-info/dependency_links.txt +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator.egg-info/requires.txt +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/src/cutienator.egg-info/top_level.txt +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/tests/test_cute_load_hook.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/tests/test_cute_overload.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/tests/test_cute_space.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/tests/test_meta_cute.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/tests/test_q_object.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/tests/test_wait.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/tests/test_wait_bound_elsewhere.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/tests/test_wait_settle_raises.py +0 -0
- {cutienator-0.0.1.dev0 → cutienator-0.0.1.dev1}/tests/test_waiting_overload.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cutienator
|
|
3
|
-
Version: 0.0.1.
|
|
3
|
+
Version: 0.0.1.dev1
|
|
4
4
|
Summary: A vastly superior binding of Qt C++ to Python
|
|
5
5
|
Author-email: Asger Jon Vistisen <asgerjon2@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -29,5 +29,5 @@ Dynamic: license-file
|
|
|
29
29
|
|
|
30
30
|
[](https://claude.com/claude-code)
|
|
31
31
|
|
|
32
|
-
# cutienator v0.0.1-
|
|
32
|
+
# cutienator v0.0.1-dev1 (development build)
|
|
33
33
|
A vastly superior binding of Qt C++ to Python.
|
|
@@ -5,7 +5,7 @@ The 'cutienator' provides Python bindings to the occult world of C++.
|
|
|
5
5
|
# Copyright (c) 2026 Asger Jon Vistisen
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
|
-
__version__ = '0.0.1-
|
|
8
|
+
__version__ = '0.0.1-dev1'
|
|
9
9
|
|
|
10
10
|
from ._cpp_addr import CppAddr
|
|
11
11
|
from ._cpp_box import CppBox
|
|
@@ -10,7 +10,11 @@ from ._cognito_warning import CognitoWarning
|
|
|
10
10
|
from ._base_meta_ugly import BaseMetaUgly
|
|
11
11
|
from ._symbol import Symbol
|
|
12
12
|
from ._shared_object import SharedObject
|
|
13
|
+
from ._system import System
|
|
13
14
|
from ._build import Build
|
|
15
|
+
from ._linux import Linux
|
|
16
|
+
from ._mac import Mac
|
|
17
|
+
from ._windows import Windows
|
|
14
18
|
from ._rituals import Rituals
|
|
15
19
|
from ._declaration import Declaration
|
|
16
20
|
from ._header import Header
|
|
@@ -20,7 +24,11 @@ __all__ = (
|
|
|
20
24
|
'BaseMetaUgly',
|
|
21
25
|
'Symbol',
|
|
22
26
|
'SharedObject',
|
|
27
|
+
'System',
|
|
23
28
|
'Build',
|
|
29
|
+
'Linux',
|
|
30
|
+
'Mac',
|
|
31
|
+
'Windows',
|
|
24
32
|
'Rituals',
|
|
25
33
|
'Declaration',
|
|
26
34
|
'Header',
|
|
@@ -9,6 +9,8 @@ from typing import TYPE_CHECKING
|
|
|
9
9
|
|
|
10
10
|
from worktoy.waitaminute import MissingVariable, TypeException
|
|
11
11
|
|
|
12
|
+
from . import System
|
|
13
|
+
|
|
12
14
|
if TYPE_CHECKING: # pragma: no cover, no mutate
|
|
13
15
|
from typing import Tuple, Optional
|
|
14
16
|
|
|
@@ -50,12 +52,17 @@ class Build:
|
|
|
50
52
|
Found for you
|
|
51
53
|
-------------
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
Three things, which have no setter. Each is asked of Qt's own program
|
|
54
56
|
'qmake6' the first time it is needed, and then remembered for every
|
|
55
57
|
'Build', since Qt is installed in one place.
|
|
56
58
|
|
|
57
59
|
- 'getQtHeaderFolder': where Qt keeps its headers.
|
|
58
60
|
- 'getQtSharedObjectFolder': where Qt keeps its shared objects.
|
|
61
|
+
- 'getQtProgramFolder': where Qt keeps its programs.
|
|
62
|
+
|
|
63
|
+
What differs between Linux, mac and Windows is not written here. The
|
|
64
|
+
build asks 'System.getHere()' for it: the name of a Qt shared object
|
|
65
|
+
and some of what 'clang++' is told.
|
|
59
66
|
|
|
60
67
|
What to expect
|
|
61
68
|
--------------
|
|
@@ -121,6 +128,7 @@ class Build:
|
|
|
121
128
|
# Class Variables
|
|
122
129
|
__qt_header_folder__: Optional[str] = None
|
|
123
130
|
__qt_shared_object_folder__: Optional[str] = None
|
|
131
|
+
__qt_program_folder__: Optional[str] = None
|
|
124
132
|
|
|
125
133
|
# Fallback Variables
|
|
126
134
|
|
|
@@ -218,6 +226,49 @@ class Build:
|
|
|
218
226
|
return cls.getQtSharedObjectFolder(_recursion=True)
|
|
219
227
|
return cls.__qt_shared_object_folder__
|
|
220
228
|
|
|
229
|
+
@classmethod
|
|
230
|
+
def _createQtProgramFolder(cls, ) -> None:
|
|
231
|
+
"""Asks 'qmake6' where Qt keeps its programs and remembers it."""
|
|
232
|
+
answer = cls._run('qmake6', '-query', 'QT_INSTALL_BINS')
|
|
233
|
+
cls.__qt_program_folder__ = answer.strip()
|
|
234
|
+
|
|
235
|
+
@classmethod
|
|
236
|
+
def getQtProgramFolder(cls, **kwargs) -> str:
|
|
237
|
+
"""
|
|
238
|
+
Gives the folder where Qt keeps its programs, as '/usr/lib/qt6/bin'.
|
|
239
|
+
'qmake6' itself is one of them.
|
|
240
|
+
|
|
241
|
+
Found for you: there is no setter. The first call asks Qt's own
|
|
242
|
+
program 'qmake6', and the answer is remembered on the class for every
|
|
243
|
+
'Build'. Call it on the class or on an instance, with no arguments;
|
|
244
|
+
the keyword is for the method's own use.
|
|
245
|
+
|
|
246
|
+
No build needs it. On Windows it is also the folder of Qt's shared
|
|
247
|
+
objects themselves, which 'Windows.prepareOpening' tells Python of.
|
|
248
|
+
|
|
249
|
+
Returns
|
|
250
|
+
-------
|
|
251
|
+
|
|
252
|
+
str
|
|
253
|
+
The full path of the folder.
|
|
254
|
+
|
|
255
|
+
Raises
|
|
256
|
+
------
|
|
257
|
+
|
|
258
|
+
FileNotFoundError
|
|
259
|
+
'qmake6' is not installed, which usually means Qt's development
|
|
260
|
+
files are not either.
|
|
261
|
+
|
|
262
|
+
RuntimeError
|
|
263
|
+
'qmake6' ran and reported a failure; its message is included.
|
|
264
|
+
"""
|
|
265
|
+
if cls.__qt_program_folder__ is None:
|
|
266
|
+
if kwargs.get('_recursion', False):
|
|
267
|
+
raise RecursionError
|
|
268
|
+
cls._createQtProgramFolder()
|
|
269
|
+
return cls.getQtProgramFolder(_recursion=True)
|
|
270
|
+
return cls.__qt_program_folder__
|
|
271
|
+
|
|
221
272
|
def getRitualFiles(self) -> Paths:
|
|
222
273
|
"""
|
|
223
274
|
Gives the ritual files this build compiles: the C++ files we write,
|
|
@@ -301,8 +352,9 @@ class Build:
|
|
|
301
352
|
|
|
302
353
|
Call it to see what a build will do, or to paste the command into a
|
|
303
354
|
terminal: "' '.join(build.getCommand())". It is put together from
|
|
304
|
-
what you provided through the three setters,
|
|
305
|
-
|
|
355
|
+
what you provided through the three setters, from the folders of
|
|
356
|
+
Qt, which are found for you, and from what 'System.getHere()' says
|
|
357
|
+
of the system Python runs on.
|
|
306
358
|
|
|
307
359
|
The compiler and its '-std' are those that read Qt's headers when
|
|
308
360
|
the ritual files were generated. A header may give a class other
|
|
@@ -317,18 +369,12 @@ class Build:
|
|
|
317
369
|
A 'Tuple[str, ...]', one argument per entry: 'clang++', then
|
|
318
370
|
'-std=c++17', the standard the headers were read by;
|
|
319
371
|
'-shared', to make a shared object and not a program;
|
|
320
|
-
'-fPIC', so the code can sit at any address;
|
|
321
372
|
'-O2', so the compiler tidies the result;
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
'-Wl,--no-undefined'
|
|
325
|
-
shared
|
|
326
|
-
|
|
327
|
-
'-Wl,-rpath,' with the folder of each Qt shared object, so the
|
|
328
|
-
target file opens the Qt it was built against. Without it the
|
|
329
|
-
target file looks only where the machine keeps its own shared
|
|
330
|
-
objects, as '/usr/lib': a Qt installed elsewhere is not found
|
|
331
|
-
there, and another Qt that is there would be opened instead;
|
|
373
|
+
what the system adds for the compiler and then for the linker,
|
|
374
|
+
which on Linux is '-fPIC', '-fvisibility-inlines-hidden',
|
|
375
|
+
'-Wl,--no-undefined' and '-Wl,-rpath,' with the folder of Qt's
|
|
376
|
+
shared objects. 'getCompilerFlags' and 'getLinkerFlags' of
|
|
377
|
+
'Linux', 'Mac' and 'Windows' say what each is for;
|
|
332
378
|
'-I' with the folder of Qt's headers;
|
|
333
379
|
the path of each ritual file;
|
|
334
380
|
'-o' with the path of the target file;
|
|
@@ -343,17 +389,16 @@ class Build:
|
|
|
343
389
|
|
|
344
390
|
FileNotFoundError
|
|
345
391
|
'qmake6' is not installed.
|
|
392
|
+
|
|
393
|
+
NotImplementedError
|
|
394
|
+
Python runs on a system that 'System' has no subclass for.
|
|
346
395
|
"""
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
qtFolder = os.path.dirname(qtSharedObject)
|
|
350
|
-
if qtFolder not in qtFolders:
|
|
351
|
-
qtFolders.append(qtFolder)
|
|
396
|
+
system = System.getHere()
|
|
397
|
+
qtFolder = self.getQtSharedObjectFolder()
|
|
352
398
|
return (
|
|
353
|
-
'clang++', '-std=c++17', '-shared', '-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
*('-Wl,-rpath,%s' % qtFolder for qtFolder in qtFolders),
|
|
399
|
+
'clang++', '-std=c++17', '-shared', '-O2',
|
|
400
|
+
*system.getCompilerFlags(qtFolder),
|
|
401
|
+
*system.getLinkerFlags(qtFolder),
|
|
357
402
|
'-I%s' % self.getQtHeaderFolder(), *self.getRitualFiles(),
|
|
358
403
|
'-o', self.getTargetFile(), *self.getQtSharedObjects(),
|
|
359
404
|
)
|
|
@@ -449,7 +494,9 @@ class Build:
|
|
|
449
494
|
|
|
450
495
|
Name the file holding each Qt class the ritual files include: 'QObject'
|
|
451
496
|
is in 'libQt6Core.so.6', 'QWidget' in 'libQt6Widgets.so.6'. Those
|
|
452
|
-
files lie in the folder 'getQtSharedObjectFolder' gives.
|
|
497
|
+
files lie in the folder 'getQtSharedObjectFolder' gives. The names
|
|
498
|
+
are those of Linux; 'System.getHere().getQtFileName("QtCore")' gives
|
|
499
|
+
the name on the system Python runs on.
|
|
453
500
|
|
|
454
501
|
Parameters
|
|
455
502
|
----------
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"""Linux says how ritual files are compiled and opened on Linux."""
|
|
2
|
+
# Apache-2.0 license
|
|
3
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
from . import System
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING: # pragma: no cover, no mutate
|
|
11
|
+
from typing import Tuple
|
|
12
|
+
|
|
13
|
+
Paths = Tuple[str, ...]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Linux(System):
|
|
17
|
+
"""
|
|
18
|
+
Answers for Linux what 'System' asks of every system.
|
|
19
|
+
|
|
20
|
+
You do not make one: 'System.getHere()' gives it when Python runs on
|
|
21
|
+
Linux, and 'Build', 'Rituals' and the judge of the trials ask it.
|
|
22
|
+
|
|
23
|
+
What Linux is like
|
|
24
|
+
------------------
|
|
25
|
+
|
|
26
|
+
- Qt keeps each of its parts in one shared object, named as
|
|
27
|
+
'libQt6Core.so.6' for 'QtCore'.
|
|
28
|
+
- A built file can carry the folder of the Qt it was built against.
|
|
29
|
+
The linker writes it in, so nothing has to be done in Python before
|
|
30
|
+
the file is opened.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
34
|
+
# STATIC METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
35
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
36
|
+
|
|
37
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
38
|
+
# NAMESPACE # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
39
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
40
|
+
|
|
41
|
+
# Class Variables
|
|
42
|
+
# What 'sys.platform' is on Linux.
|
|
43
|
+
__platform_name__ = 'linux'
|
|
44
|
+
|
|
45
|
+
# Fallback Variables
|
|
46
|
+
|
|
47
|
+
# Private Variables
|
|
48
|
+
|
|
49
|
+
# Public Variables
|
|
50
|
+
|
|
51
|
+
# Virtual Variables
|
|
52
|
+
|
|
53
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
54
|
+
# GETTERS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
55
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
56
|
+
|
|
57
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
58
|
+
# SETTERS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
59
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
60
|
+
|
|
61
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
62
|
+
# NOTIFIERS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
63
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
64
|
+
|
|
65
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
66
|
+
# Python API # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
67
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
68
|
+
|
|
69
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
70
|
+
# CONSTRUCTORS # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
71
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
72
|
+
|
|
73
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
74
|
+
# DOMAIN SPECIFIC # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
75
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
76
|
+
|
|
77
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
78
|
+
# OPTIONAL METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
79
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
80
|
+
|
|
81
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
82
|
+
# REQUIRED METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
83
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
84
|
+
|
|
85
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
86
|
+
# PARENT METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
87
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
88
|
+
|
|
89
|
+
def getQtFileName(self, part: str) -> str:
|
|
90
|
+
"""
|
|
91
|
+
Gives the shared object of one part of Qt, as 'libQt6Core.so.6' for
|
|
92
|
+
'QtCore'. It lies right in the folder where Qt keeps its shared
|
|
93
|
+
objects.
|
|
94
|
+
"""
|
|
95
|
+
return 'lib%s.so.6' % part.replace('Qt', 'Qt6', 1)
|
|
96
|
+
|
|
97
|
+
def getCompilerFlags(self, qtFolder: str) -> Paths:
|
|
98
|
+
"""
|
|
99
|
+
Gives what 'clang++' is told on Linux. The folder of Qt's shared
|
|
100
|
+
objects is of no use for it.
|
|
101
|
+
|
|
102
|
+
Returns
|
|
103
|
+
-------
|
|
104
|
+
|
|
105
|
+
Paths
|
|
106
|
+
'-fPIC', so the code can sit at any address;
|
|
107
|
+
'-fvisibility-inlines-hidden', so Qt's inline code leaves no
|
|
108
|
+
scrambled names in the built file.
|
|
109
|
+
"""
|
|
110
|
+
return ('-fPIC', '-fvisibility-inlines-hidden',)
|
|
111
|
+
|
|
112
|
+
def getLinkerFlags(self, qtFolder: str) -> Paths:
|
|
113
|
+
"""
|
|
114
|
+
Gives what the linker is told on Linux.
|
|
115
|
+
|
|
116
|
+
Returns
|
|
117
|
+
-------
|
|
118
|
+
|
|
119
|
+
Paths
|
|
120
|
+
'-Wl,--no-undefined', so a ritual calling a function that no Qt
|
|
121
|
+
shared object offers stops the build, and not the first program
|
|
122
|
+
that opens the built file;
|
|
123
|
+
'-Wl,-rpath,' with the folder of Qt's shared objects, so the built
|
|
124
|
+
file opens the Qt it was built against. Without it the built file
|
|
125
|
+
looks only where the machine keeps its own shared objects, as
|
|
126
|
+
'/usr/lib': a Qt installed elsewhere is not found there, and
|
|
127
|
+
another Qt that is there would be opened instead.
|
|
128
|
+
"""
|
|
129
|
+
return ('-Wl,--no-undefined', '-Wl,-rpath,%s' % qtFolder,)
|
|
130
|
+
|
|
131
|
+
def prepareOpening(self) -> None:
|
|
132
|
+
"""
|
|
133
|
+
Does nothing: on Linux the built file carries the folder of its Qt,
|
|
134
|
+
which 'getLinkerFlags' had the linker write into it.
|
|
135
|
+
"""
|
|
136
|
+
|
|
137
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
138
|
+
# PUBLIC METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
139
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"""Mac says how ritual files are compiled and opened on mac."""
|
|
2
|
+
# Apache-2.0 license
|
|
3
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
from . import System
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING: # pragma: no cover, no mutate
|
|
11
|
+
from typing import Tuple
|
|
12
|
+
|
|
13
|
+
Paths = Tuple[str, ...]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Mac(System):
|
|
17
|
+
"""
|
|
18
|
+
Answers for mac what 'System' asks of every system, on Apple's own
|
|
19
|
+
chips and on Intel chips alike.
|
|
20
|
+
|
|
21
|
+
You do not make one: 'System.getHere()' gives it when Python runs on
|
|
22
|
+
mac, and 'Build', 'Rituals' and the judge of the trials ask it.
|
|
23
|
+
|
|
24
|
+
What mac is like
|
|
25
|
+
----------------
|
|
26
|
+
|
|
27
|
+
- Qt keeps each of its parts in a folder of its own, called a
|
|
28
|
+
framework, as 'QtCore.framework'. The shared object lies inside it
|
|
29
|
+
and has no ending: 'QtCore.framework/Versions/A/QtCore'. The same
|
|
30
|
+
file serves both kinds of chip.
|
|
31
|
+
- The headers of a part lie inside its framework as well. Qt's header
|
|
32
|
+
folder holds only a stand-in for each, one line long, that sends
|
|
33
|
+
the compiler on to the header of that name in a framework. So the
|
|
34
|
+
compiler has to be told the folder of the frameworks too.
|
|
35
|
+
- A built file can carry the folder of the Qt it was built against,
|
|
36
|
+
as on Linux, so nothing has to be done in Python before the file is
|
|
37
|
+
opened.
|
|
38
|
+
- 'clang++' is Apple's own there, and its linker has other words for
|
|
39
|
+
some things than the one on Linux.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
43
|
+
# STATIC METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
44
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
45
|
+
|
|
46
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
47
|
+
# NAMESPACE # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
48
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
49
|
+
|
|
50
|
+
# Class Variables
|
|
51
|
+
# What 'sys.platform' is on mac.
|
|
52
|
+
__platform_name__ = 'darwin'
|
|
53
|
+
|
|
54
|
+
# Fallback Variables
|
|
55
|
+
|
|
56
|
+
# Private Variables
|
|
57
|
+
|
|
58
|
+
# Public Variables
|
|
59
|
+
|
|
60
|
+
# Virtual Variables
|
|
61
|
+
|
|
62
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
63
|
+
# GETTERS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
64
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
65
|
+
|
|
66
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
67
|
+
# SETTERS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
68
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
69
|
+
|
|
70
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
71
|
+
# NOTIFIERS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
72
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
73
|
+
|
|
74
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
75
|
+
# Python API # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
76
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
77
|
+
|
|
78
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
79
|
+
# CONSTRUCTORS # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
80
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
81
|
+
|
|
82
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
83
|
+
# DOMAIN SPECIFIC # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
84
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
85
|
+
|
|
86
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
87
|
+
# OPTIONAL METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
88
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
89
|
+
|
|
90
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
91
|
+
# REQUIRED METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
92
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
93
|
+
|
|
94
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
95
|
+
# PARENT METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
96
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
97
|
+
|
|
98
|
+
def getQtFileName(self, part: str) -> str:
|
|
99
|
+
"""
|
|
100
|
+
Gives the shared object of one part of Qt, which on mac lies inside
|
|
101
|
+
the framework of the part: 'QtCore.framework/Versions/A/QtCore' for
|
|
102
|
+
'QtCore'.
|
|
103
|
+
"""
|
|
104
|
+
return '%s.framework/Versions/A/%s' % (part, part)
|
|
105
|
+
|
|
106
|
+
def getCompilerFlags(self, qtFolder: str) -> Paths:
|
|
107
|
+
"""
|
|
108
|
+
Gives what 'clang++' is told on mac: what it is told on Linux, and
|
|
109
|
+
where the frameworks are.
|
|
110
|
+
|
|
111
|
+
Returns
|
|
112
|
+
-------
|
|
113
|
+
|
|
114
|
+
Paths
|
|
115
|
+
'-fPIC', so the code can sit at any address;
|
|
116
|
+
'-fvisibility-inlines-hidden', so Qt's inline code leaves no
|
|
117
|
+
scrambled names in the built file;
|
|
118
|
+
'-F' with the folder of Qt's shared objects, which on mac is the
|
|
119
|
+
folder of the frameworks, so that 'QtCore/qobject.h' is found
|
|
120
|
+
inside 'QtCore.framework'. Without it the compiler finds only the
|
|
121
|
+
stand-in of that name in Qt's header folder, which sends it on to
|
|
122
|
+
the framework and nowhere else.
|
|
123
|
+
"""
|
|
124
|
+
return ('-fPIC', '-fvisibility-inlines-hidden', '-F%s' % qtFolder,)
|
|
125
|
+
|
|
126
|
+
def getLinkerFlags(self, qtFolder: str) -> Paths:
|
|
127
|
+
"""
|
|
128
|
+
Gives what the linker is told on mac.
|
|
129
|
+
|
|
130
|
+
Returns
|
|
131
|
+
-------
|
|
132
|
+
|
|
133
|
+
Paths
|
|
134
|
+
'-Wl,-undefined,error', so a ritual calling a function that no Qt
|
|
135
|
+
shared object offers stops the build. It is what
|
|
136
|
+
'-Wl,--no-undefined' is on Linux, in the words of Apple's linker,
|
|
137
|
+
which does not know the other;
|
|
138
|
+
'-Wl,-rpath,' with the folder of Qt's shared objects, so the built
|
|
139
|
+
file opens the Qt it was built against. Qt's shared objects on mac
|
|
140
|
+
name themselves from that folder on, as
|
|
141
|
+
'QtCore.framework/Versions/A/QtCore', so it is that folder and not
|
|
142
|
+
the framework that the built file has to carry.
|
|
143
|
+
"""
|
|
144
|
+
return ('-Wl,-undefined,error', '-Wl,-rpath,%s' % qtFolder,)
|
|
145
|
+
|
|
146
|
+
def prepareOpening(self) -> None:
|
|
147
|
+
"""
|
|
148
|
+
Does nothing: on mac the built file carries the folder of its Qt,
|
|
149
|
+
which 'getLinkerFlags' had the linker write into it.
|
|
150
|
+
"""
|
|
151
|
+
|
|
152
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
153
|
+
# PUBLIC METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
154
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
@@ -8,7 +8,7 @@ import glob
|
|
|
8
8
|
import os
|
|
9
9
|
from typing import TYPE_CHECKING
|
|
10
10
|
|
|
11
|
-
from . import Build
|
|
11
|
+
from . import Build, System
|
|
12
12
|
|
|
13
13
|
if TYPE_CHECKING: # pragma: no cover, no mutate
|
|
14
14
|
from typing import Any, Dict, Optional, Tuple
|
|
@@ -332,8 +332,9 @@ class Rituals:
|
|
|
332
332
|
'ritual_ZNK6QEvent5cloneEv': (ctypes.c_void_p, ctypes.c_void_p),
|
|
333
333
|
} # type: Dict[str, Tuple[Any, ...]]
|
|
334
334
|
|
|
335
|
-
# The
|
|
336
|
-
|
|
335
|
+
# The parts of Qt the rituals call into. 'System' knows the file of
|
|
336
|
+
# each part on the system Python runs on.
|
|
337
|
+
__qt_parts__ = ('QtCore',)
|
|
337
338
|
|
|
338
339
|
# The opened target file, or None until the first call.
|
|
339
340
|
__opened_target__ = None # type: Optional[ctypes.CDLL]
|
|
@@ -392,8 +393,10 @@ class Rituals:
|
|
|
392
393
|
"""
|
|
393
394
|
Gives the Qt shared objects the rituals call into.
|
|
394
395
|
|
|
395
|
-
Found for you:
|
|
396
|
-
folder where Qt keeps its shared objects.
|
|
396
|
+
Found for you: one file for each part of Qt in '__qt_parts__', in
|
|
397
|
+
the folder where Qt keeps its shared objects. 'System' gives the
|
|
398
|
+
name the file has on the system Python runs on, which on Linux is
|
|
399
|
+
'libQt6Core.so.6' for 'QtCore'.
|
|
397
400
|
|
|
398
401
|
Returns
|
|
399
402
|
-------
|
|
@@ -402,7 +405,8 @@ class Rituals:
|
|
|
402
405
|
A 'Tuple[str, ...]' of full paths.
|
|
403
406
|
"""
|
|
404
407
|
folder = Build.getQtSharedObjectFolder()
|
|
405
|
-
|
|
408
|
+
system = System.getHere()
|
|
409
|
+
names = (*(system.getQtFileName(part) for part in cls.__qt_parts__),)
|
|
406
410
|
return (*(os.path.join(folder, name) for name in names),)
|
|
407
411
|
|
|
408
412
|
@classmethod
|
|
@@ -439,6 +443,7 @@ class Rituals:
|
|
|
439
443
|
infoSpec = """The shared object '%s' is missing, or older than a
|
|
440
444
|
ritual file. Call 'Rituals.build()' first."""
|
|
441
445
|
raise FileNotFoundError(' '.join((infoSpec % target).split()))
|
|
446
|
+
System.getHere().prepareOpening()
|
|
442
447
|
opened = ctypes.CDLL(target)
|
|
443
448
|
for name, (gives, *takes) in cls.__type_signatures__.items():
|
|
444
449
|
try:
|