-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathsetup.py
More file actions
56 lines (42 loc) · 1.86 KB
/
setup.py
File metadata and controls
56 lines (42 loc) · 1.86 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
import os
from setuptools import setup
from setuptools.command.bdist_wheel import bdist_wheel
class PlatformSpecificWheel(bdist_wheel):
"""Custom bdist_wheel to force platform-specific wheel."""
def finalize_options(self):
bdist_wheel.finalize_options(self)
# Force platform-specific wheel
self.root_is_pure = False
# Set platform name from environment if provided
plat_name = os.environ.get("PLAT_NAME")
if plat_name:
self.plat_name = plat_name
def get_tag(self):
# Force platform-specific tags with broader compatibility
python_tag, abi_tag, platform_tag = bdist_wheel.get_tag(self)
# Override platform tag if specified
plat_name = os.environ.get("PLAT_NAME")
if plat_name:
platform_tag = plat_name
# Use py3 for broader Python compatibility since we have pre-built binaries
python_tag = "py3"
abi_tag = "none"
return python_tag, abi_tag, platform_tag
def get_platform_classifiers():
"""Get platform-specific classifiers based on PLAT_NAME environment variable."""
classifier_map = {
"manylinux2014_x86_64": ["Operating System :: POSIX :: Linux"],
"manylinux2014_aarch64": ["Operating System :: POSIX :: Linux"],
"win_amd64": ["Operating System :: Microsoft :: Windows"],
"macosx_10_9_x86_64": ["Operating System :: MacOS"],
"macosx_11_0_arm64": ["Operating System :: MacOS"],
}
plat_name = os.environ.get("PLAT_NAME")
if plat_name and plat_name in classifier_map:
return ["Programming Language :: Python :: 3", classifier_map[plat_name][0]]
raise ValueError(f"Unsupported or missing PLAT_NAME: {plat_name}")
if __name__ == "__main__":
setup(
cmdclass={"bdist_wheel": PlatformSpecificWheel},
classifiers=get_platform_classifiers(),
)