代码拉取完成,页面将自动刷新
同步操作将从 Time-Coder/Glass-Engine 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import platform
import zipfile
import subprocess
import shutil
import sys
import os
try:
import requests
except ImportError:
subprocess.check_call([sys.executable, "-m", "pip", "install", "requests"])
import requests
def public_ip():
try:
response = requests.get("https://httpbin.org/ip")
return response.json().get("origin")
except:
return "127.0.0.1"
def is_China_ip(ip_address):
try:
response = requests.get(f"https://ipinfo.io/{ip_address}/json/")
data = response.json()
return data['country'] == 'CN'
except Exception as e:
return True
_is_China_user = None
def is_China_user():
global _is_China_user
if _is_China_user is None:
_is_China_user = is_China_ip(public_ip())
return _is_China_user
def pip_install(package):
if is_China_user():
subprocess.check_call([sys.executable, "-m", "pip", "install", package, "-i", "https://pypi.tuna.tsinghua.edu.cn/simple"])
else:
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
try:
import setuptools
except ImportError:
pip_install("setuptools")
import setuptools
bits = platform.architecture()[0]
if bits == '64bit':
bits = 'x64'
else:
bits = 'Win32'
extra_flags = []
if platform.system() == "Windows":
extra_flags = ["-A", bits]
library_dirs = [
f"build/assimp-5.4.1/{bits}/lib/MinSizeRel",
f"build/assimp-5.4.1/{bits}/contrib/zlib/MinSizeRel"
]
else:
library_dirs = [
f"build/assimp-5.4.1/{bits}/lib",
f"build/assimp-5.4.1/{bits}/contrib/zlib"
]
if shutil.which("ninja") is not None:
extra_flags = ["-G", "Ninja"]
if (
(
not os.path.isfile(library_dirs[0] + "/assimp.lib") and
not os.path.isfile(library_dirs[0] + "/assimp.a") and
not os.path.isfile(library_dirs[0] + "/libassimp.lib") and
not os.path.isfile(library_dirs[0] + "/libassimp.a")
) or (
not os.path.isfile(library_dirs[1] + "/zlibstatic.lib") and
not os.path.isfile(library_dirs[1] + "/zlibstatic.a") and
not os.path.isfile(library_dirs[1] + "/libzlibstatic.lib") and
not os.path.isfile(library_dirs[1] + "/libzlibstatic.a")
)
):
zip_file = zipfile.ZipFile("assimpy/assimp-5.4.1.zip")
zip_file.extractall("assimpy")
zip_file.close()
zip_file = zipfile.ZipFile("assimpy/pybind11-2.12.0.zip")
zip_file.extractall("assimpy")
zip_file.close()
if shutil.which("cmake") is None:
pip_install("cmake")
subprocess.check_call(
[
"cmake", "assimpy/assimp-5.4.1",
"-B", f"build/assimp-5.4.1/{bits}",
"-DCMAKE_CONFIGURATION_TYPES=MinSizeRel",
"-DBUILD_SHARED_LIBS=OFF",
"-DASSIMP_BUILD_TESTS=OFF",
"-DASSIMP_INJECT_DEBUG_POSTFIX=OFF",
"-DASSIMP_INSTALL=OFF",
"-DASSIMP_INSTALL_PDB=OFF",
"-DASSIMP_WARNINGS_AS_ERRORS=OFF",
"-DLIBRARY_SUFFIX="
] + extra_flags
)
subprocess.check_call(
[
"cmake", "--build", f"build/assimp-5.4.1/{bits}", "--config", "MinSizeRel", "--parallel"
]
)
ext = setuptools.Extension(
"assimpy_ext",
sources=[
"assimpy/assimpy_ext.cpp",
"assimpy/module.cpp"
],
include_dirs=[
"assimpy",
"assimpy/pybind11-2.12.0/include",
"assimpy/assimp-5.4.1/include",
f"build/assimp-5.4.1/{bits}/include"
],
libraries=[
"assimp",
"zlibstatic"
],
library_dirs=library_dirs
)
if platform.system() != "Windows":
ext.extra_compile_args = ["-std=c++11"]
ext_modules = [ext]
extra_files = ["LICENSE", "__pyinstaller/assimp/LICENSE", "__pyinstaller/pybind11/LICENSE"]
with open("assimpy/README_PYPI.md", "r", encoding='utf-8') as in_file:
long_description = in_file.read()
setuptools.setup(
name="assimpy",
version="5.4.1",
author="王炳辉 (BingHui-WANG)",
author_email="binghui.wang@foxmail.com",
description="3D model loader for Glass-Engine",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/Time-Coder/Glass-Engine",
include_package_data=False,
python_requires=">=3.7",
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
'Operating System :: OS Independent',
],
packages=["assimpy", "assimpy/__pyinstaller"],
package_data={
'assimpy': extra_files,
},
ext_modules=ext_modules,
entry_points={'pyinstaller40': ['hook-dirs = assimpy.__pyinstaller:get_hook_dirs']}
)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。