init
This commit is contained in:
87
deploy.py
Normal file
87
deploy.py
Normal file
@@ -0,0 +1,87 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
from shutil import copy, copytree
|
||||
from distutils.sysconfig import get_python_lib
|
||||
|
||||
# 1. activate virtual environment
|
||||
# $ conda activate YOUR_ENV_NAME
|
||||
#
|
||||
# 2. run deploy script
|
||||
# $ python 编译.py
|
||||
|
||||
args = [
|
||||
"nuitka",
|
||||
"--standalone",
|
||||
"--assume-yes-for-downloads",
|
||||
"--mingw64",
|
||||
"--windows-icon-from-ico=C:/Users/Administrator/AppData/Local/Temp/icon.ico",
|
||||
"--nofollow-import-to=numpy,scipy,PIL,colorthief",
|
||||
"--enable-plugins=PyQt6",
|
||||
"--show-progress",
|
||||
"--show-memory",
|
||||
"--disable-console",
|
||||
"--output-dir=G:/meowMebulaDiskRefactor/build",
|
||||
"G:/meowMebulaDiskRefactor/main.py",
|
||||
]
|
||||
|
||||
dist_folder = Path("G:/meowMebulaDiskRefactor/build/main.dist")
|
||||
|
||||
copied_site_packages = [
|
||||
"scipy",
|
||||
"numpy",
|
||||
"numpy.libs",
|
||||
"scipy.libs",
|
||||
"PIL",
|
||||
"colorthief.py",
|
||||
"certifi", # Add certifi to the list of copied site-packages
|
||||
]
|
||||
|
||||
copied_standard_packages = [
|
||||
"random.py",
|
||||
"hmac.py",
|
||||
"hashlib.py",
|
||||
"uuid.py",
|
||||
"ctypes",
|
||||
"secrets.py",
|
||||
"importlib/resources.py", # Add importlib.resources to the list of copied standard packages
|
||||
]
|
||||
|
||||
# Ensure importlib.resources is included in the Nuitka build
|
||||
args.append("--include-module=importlib.resources")
|
||||
|
||||
# run nuitka
|
||||
# https://blog.csdn.net/qq_25262697/article/details/129302819
|
||||
# https://www.cnblogs.com/happylee666/articles/16158458.html
|
||||
os.system(" ".join(args))
|
||||
|
||||
# copy site-packages to dist folder
|
||||
site_packages = Path(get_python_lib())
|
||||
|
||||
for src in copied_site_packages:
|
||||
src = site_packages / src
|
||||
dist = dist_folder / src.name
|
||||
|
||||
print(f"Coping site-packages `{src}` to `{dist}`")
|
||||
|
||||
try:
|
||||
if src.is_file():
|
||||
copy(src, dist)
|
||||
else:
|
||||
copytree(src, dist)
|
||||
except Exception as e:
|
||||
print(f"Failed to copy `{src}`: {e}")
|
||||
|
||||
# copy standard library
|
||||
for file in copied_standard_packages:
|
||||
src = site_packages.parent / file
|
||||
dist = dist_folder / src.name
|
||||
|
||||
print(f"Coping stand library `{src}` to `{dist}`")
|
||||
|
||||
try:
|
||||
if src.is_file():
|
||||
copy(src, dist)
|
||||
else:
|
||||
copytree(src, dist)
|
||||
except Exception as e:
|
||||
print(f"Failed to copy `{src}`: {e}")
|
||||
Reference in New Issue
Block a user