-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathsetup.py
121 lines (110 loc) · 3.83 KB
/
setup.py
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
from setuptools import setup, find_packages
from wheel.bdist_wheel import bdist_wheel
import platform
import subprocess
import os
def get_version():
"""Get version number"""
version_path = os.path.join(os.path.dirname(__file__), 'version.txt')
with open(version_path, 'r') as f:
return f.read().strip()
def get_wheel_platform_tag():
"""Get wheel package platform tag"""
system = platform.system().lower()
machine = platform.machine().lower()
arch_mapping = {
'x86_64': {
'windows': 'win_amd64',
'linux': 'manylinux2014_x86_64',
'darwin': 'macosx_12_0_x86_64'
},
'amd64': {
'windows': 'win_amd64',
'linux': 'manylinux2014_x86_64',
'darwin': 'macosx_12_0_x86_64'
},
'arm64': {
'windows': 'win_arm64',
'linux': 'manylinux2014_aarch64',
'darwin': 'macosx_11_0_arm64'
},
'aarch64': {
'windows': 'win_arm64',
'linux': 'manylinux2014_aarch64',
'darwin': 'macosx_11_0_arm64'
}
}
platform_arch = arch_mapping.get(machine, {}).get(system)
if not platform_arch:
print("Unsupported platform: {} {}".format(system, machine))
raise RuntimeError("Unsupported platform: {} {}".format(system, machine))
return platform_arch
def get_lib_path_info():
"""Get library file path information"""
system = platform.system().lower()
machine = platform.machine().lower()
if system == 'windows':
arch = 'x64' if machine in ['amd64', 'x86_64'] else 'arm64'
elif system == 'linux':
arch = 'x64' if machine == 'x86_64' else 'arm64'
elif system == 'darwin':
if machine == 'x86_64':
try:
is_rosetta = bool(int(subprocess.check_output(
['sysctl', '-n', 'sysctl.proc_translated']).decode().strip()))
arch = 'arm64' if is_rosetta else 'x64'
except:
arch = 'x64'
else:
arch = 'arm64'
else:
raise RuntimeError(f"Unsupported system: {system}")
return system, arch
class BinaryDistWheel(bdist_wheel):
def finalize_options(self):
super().finalize_options()
# Mark this is not a pure Python package
self.root_is_pure = False
# Set platform tag
self.plat_name = get_wheel_platform_tag()
self.universal = False
# Get current platform information
system, arch = get_lib_path_info()
# Build library file path relative to package
lib_path = os.path.join('modules', 'core', 'libs', system, arch, '*')
setup(
name='inspireface',
version=get_version(),
packages=find_packages(),
# package_data path should be relative to package directory
package_data={
'inspireface': [lib_path]
},
install_requires=[
'numpy',
'loguru'
],
author='Jingyu Yan',
author_email='[email protected]',
description='InspireFace Python SDK',
long_description=open(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'README.md')).read(),
long_description_content_type='text/markdown',
url='https://github.com/HyperInspire/InspireFace',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Operating System :: POSIX :: Linux',
'Operating System :: Microsoft :: Windows',
'Operating System :: MacOS :: MacOS X',
],
python_requires='>=3.7',
cmdclass={
'bdist_wheel': BinaryDistWheel
}
)