1 Star 0 Fork 6

蒲公英/Glass-Engine

forked from Time-Coder/Glass-Engine 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build_assimpy.py 2.67 KB
一键复制 编辑 原始数据 按行查看 历史
Time-Coder 提交于 2024-05-30 22:30 . optimize assimpy build scripts
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.1.zip
include assimpy/pybind11-2.12.0.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)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/knight_of_liam/Glass-Engine.git
git@gitee.com:knight_of_liam/Glass-Engine.git
knight_of_liam
Glass-Engine
Glass-Engine
main

搜索帮助