-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_assimpy.py
94 lines (77 loc) · 2.67 KB
/
build_assimpy.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
import subprocess
import os
import platform
import glob
import winreg
def get_python_paths(reg_key):
python_paths = {}
try:
i = 0
while True:
version = winreg.EnumKey(reg_key, i)
version_key = winreg.OpenKey(reg_key, version)
try:
install_key = winreg.OpenKey(version_key, "InstallPath")
except:
i += 1
continue
install_path, _ = winreg.QueryValueEx(install_key, None)
python_paths[version] = install_path.replace("\\", "/") + "python.exe"
i += 1
except OSError:
pass
return python_paths
def get_all_python_paths():
paths = {}
try:
reg_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Python\\PythonCore")
paths.update(get_python_paths(reg_key))
except:
pass
try:
reg_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\WOW6432Node\\Python\\PythonCore")
paths.update(get_python_paths(reg_key))
except:
pass
try:
reg_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, "SOFTWARE\\Python\\PythonCore")
paths.update(get_python_paths(reg_key))
except:
pass
return paths
with open("README_assimpy.rst", "r", encoding="utf-8") as in_file:
content = in_file.read()
with open("README.rst", "w", encoding="utf-8") as out_file:
out_file.write(content)
with open("setup_assimpy.py", "r", encoding="utf-8") as in_file:
content = in_file.read()
with open("setup.py", "w", encoding="utf-8") as out_file:
out_file.write(content)
with open("MANIFEST.in", "w") as out_file:
out_file.write(
"""include assimpy/LICENSE
include assimpy/README_PYPI.md
include assimpy/assimpy_ext.h
include assimpy/assimp-5.4.3.zip
include assimpy/pybind11-2.13.6.zip
include assimpy/__pyinstaller/assimp/LICENSE
include assimpy/__pyinstaller/pybind11/LICENSE
""")
python_paths = get_all_python_paths()
i = 0
for python_path in python_paths.values():
if i == 0:
subprocess.check_call([python_path, "setup.py", "sdist", "bdist_wheel"])
else:
subprocess.check_call([python_path, "setup.py", "bdist_wheel"])
if platform.system() == "Linux":
machine = platform.machine()
files = glob.glob(f"dist/assimpy-*-linux_{machine}.whl")
for file in files:
subprocess.call([python_path, "-m", "auditwheel", "repair", file, f"--plat=manylinux2014_{machine}", "-w", "dist"])
os.remove(file)
i += 1
with open("README_glass_engine.rst", "r", encoding="utf-8") as in_file:
content = in_file.read()
with open("README.rst", "w", encoding="utf-8") as out_file:
out_file.write(content)