-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
61 lines (47 loc) · 1.57 KB
/
Copy pathsetup.py
File metadata and controls
61 lines (47 loc) · 1.57 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
"""Build hooks for catap."""
from __future__ import annotations
import os
import subprocess
import sys
from pathlib import Path
if sys.platform == "darwin":
os.environ.setdefault("MACOSX_DEPLOYMENT_TARGET", "14.2")
from setuptools import setup
from setuptools.command.bdist_wheel import bdist_wheel as _bdist_wheel
from setuptools.command.build_py import build_py as _build_py
class build_py(_build_py):
"""Build Python modules and place the native dylib beside them."""
def run(self) -> None:
super().run()
self._build_native_coreaudio()
def _build_native_coreaudio(self) -> None:
output = (
Path(self.build_lib)
/ "catap"
/ "native"
/ "libcatap_coreaudio.dylib"
)
command = [
sys.executable,
"scripts/build_native_coreaudio.py",
"--output",
str(output),
]
self.announce(f"building native CoreAudio dylib: {output}", level=2)
subprocess.run(command, check=True)
class bdist_wheel(_bdist_wheel):
"""Mark wheels as platform wheels while keeping the Python tag generic."""
def finalize_options(self) -> None:
super().finalize_options()
self.root_is_pure = False
def get_tag(self) -> tuple[str, str, str]:
_python, _abi, platform_tag = super().get_tag()
if sys.platform == "darwin":
platform_tag = "macosx_14_0_universal2"
return "py3", "none", platform_tag
setup(
cmdclass={
"build_py": build_py,
"bdist_wheel": bdist_wheel,
},
)