-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
85 lines (62 loc) · 2.15 KB
/
Copy pathsetup.py
File metadata and controls
85 lines (62 loc) · 2.15 KB
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
from setuptools import Distribution, setup
APP = ["src/hand_tracking_gc/__main__.py"]
DATA_FILES = [("assets/models", ["assets/models/hand_landmarker.task"])]
PLIST = {
"CFBundleName": "Hand Tracking GC",
"CFBundleDisplayName": "Hand Tracking GC",
"CFBundleIdentifier": "com.giovicordova.hand-tracking-gc",
"CFBundleVersion": "0.1.0",
"CFBundleShortVersionString": "0.1.0",
"LSMinimumSystemVersion": "13.0",
"LSUIElement": False,
"NSHighResolutionCapable": True,
"NSCameraUsageDescription": (
"Hand Tracking GC reads your webcam to track your hand "
"and move the cursor."
),
"NSCameraUseContinuityCameraDeviceType": True,
}
OPTIONS = {
"argv_emulation": False,
"plist": PLIST,
"packages": ["mediapipe", "cv2", "numpy", "hand_tracking_gc"],
"includes": ["objc", "Quartz", "Cocoa", "ApplicationServices"],
"excludes": ["tkinter", "PyQt5", "PyQt6", "PySide2", "PySide6"],
"dylib_excludes": ["libmediapipe.dylib"],
}
_orig_parse = Distribution.parse_config_files
def _patched_parse(self, *args, **kwargs):
result = _orig_parse(self, *args, **kwargs)
self.install_requires = None
return result
Distribution.parse_config_files = _patched_parse
class _SkipMachOWrite(Exception):
pass
def _patch_macholib_skip_unrelocatable():
from macholib import MachO
_orig_synchronize = MachO.MachOHeader.synchronize_size
def _safe_synchronize(self):
try:
_orig_synchronize(self)
except ValueError as exc:
msg = str(exc)
if "too large to relocate" in msg:
print(f"py2app: skipping load-command rewrite (header full): {msg}")
raise _SkipMachOWrite()
raise
MachO.MachOHeader.synchronize_size = _safe_synchronize
_orig_write = MachO.MachO.write
def _safe_write(self, f):
try:
_orig_write(self, f)
except _SkipMachOWrite:
return
MachO.MachO.write = _safe_write
_patch_macholib_skip_unrelocatable()
setup(
app=APP,
name="Hand Tracking GC",
data_files=DATA_FILES,
options={"py2app": OPTIONS},
package_dir={"": "src"},
)