impl done?

This commit is contained in:
shenjack 2023-06-09 16:57:26 +08:00
parent 0696cfb9f5
commit cd76a27ed0
2 changed files with 35 additions and 3 deletions

View File

@ -19,6 +19,8 @@ class Status(Options):
output_path: Path = Path("./build/nuitka-win")
src_file: Path = Path('DR.py')
python_cmd: str = 'python'
# 以下为 nuitka 的参数
use_lto: bool = False # --lto=yes (no is faster)
use_clang: bool = True # --clang
@ -36,13 +38,13 @@ class Status(Options):
icon_path: Path = Path('textures/icon.png')
follow_import: List[str] = ['pyglet', 'Difficult_Rocket.api']
follow_import: List[str] = ['pyglet']
no_follow_import: List[str] = ['objprint', 'pillow', 'PIL', 'cffi', 'pydoc', 'numpy']
include_data_dir: List[Tuple[Path, Path]] = [(Path('./libs/fonts'), Path('./libs/fonts')),
(Path('./textures'), Path('./textures')),
(Path('./configs'), Path('./configs'))]
include_packages: List[str] = []
include_packages: List[str] = ['Difficult_Rocket.api']
def init(self, **kwargs) -> None:
# 非 windows 平台不使用 msvc
@ -72,7 +74,7 @@ class Status(Options):
return f"{front}\n\n```bash\n{' '.join(gen_cmd)}\n```"
def gen_subprocess_cmd(self) -> List[str]:
cmd_list = ['python', '-m', 'nuitka']
cmd_list = [self.python_cmd, '-m', 'nuitka']
# macos 和 非 macos icon 参数不同
icon_cmd = ""
if platform.system() == 'Darwin':

View File

@ -4,13 +4,43 @@
# All rights reserved
# -------------------------------
import sys
import time
import subprocess
from libs.utils import nuitka
if __name__ == '__main__':
compiler = nuitka.Status()
# 修改 python 执行文件 为 运行时的 python
compiler.python_cmd = sys.executable
# 检测 --output xx 参数
if '--output' in sys.argv:
# 输入的是输出目录
compiler.output_path = sys.argv[sys.argv.index('--output') + 1]
sys.argv.remove('--output')
sys.argv.remove(compiler.output_path)
print(compiler.output_path)
print(compiler)
print(compiler.gen_subprocess_cmd())
# 确认是否需要编译
# 如果包含 -y 参数 则直接编译
if ('-y' or '-n') not in sys.argv:
while (do_compile := input('Do you want to compile this file? (y/n) ')) not in ['y', 'n']:
pass
elif '-y' in sys.argv:
do_compile = 'y'
else:
do_compile = 'n'
if do_compile == 'y':
# 编译
start_time = time.time_ns()
subprocess.run(compiler.gen_subprocess_cmd())
print('Compile Done!')
print(f'Compile Time: {time.time_ns() - start_time} ns ({(time.time_ns() - start_time) / 1000000000} s)')