From 1f22e240f962ecf98bac7be5be485f7df67baf5a Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 3 Aug 2024 22:12:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E4=B8=8Acx=5Ffreeze=E7=9A=84=E6=9E=84?= =?UTF-8?q?=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DR.py | 4 ++-- scripts/package.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 scripts/package.py diff --git a/DR.py b/DR.py index e372949..0587054 100644 --- a/DR.py +++ b/DR.py @@ -28,8 +28,8 @@ def print_path() -> None: def modify_path() -> None: - os.chdir(Path(__file__).parent) # 将运行路径切换到文件位置 防止bug - sys.path.append("./libs") # 添加 libs path + os.chdir(Path(sys.argv[0]).parent) # 将运行路径切换到文件位置 防止bug + # sys.path.append("./libs") # 添加 libs path def start(start_time_ns: int) -> None: diff --git a/scripts/package.py b/scripts/package.py new file mode 100644 index 0000000..0bbdd59 --- /dev/null +++ b/scripts/package.py @@ -0,0 +1,50 @@ +from cx_Freeze import setup, Executable +import tomli +import sys +sys.path.append(".") +from Difficult_Rocket import sdk_version + +with open("pyproject.toml", "rb") as f: + py_project = tomli.load(f) + +# Dependencies are automatically detected, but it might need +# fine tuning. +build_options = { + "build_exe": "build/cx", + "packages": [], + "excludes": [ + "test", + "asyncio", + "tkinter", + "unitest", + "http", + "html", + "logging", + "email", + "distutils", + "unittest", + "concurrent", + "pydoc_data", + "lzma", + "zipp", + "nuitka", + "PIL", + "bz2", + "numpy", + "ssl" + ], + "zip_include_packages": ["pyglet"], + "include_files": py_project["tool"]["lndl"]["nuitka"]["cli"]["include-data-dir"], +} + +base = "console" + +executables = [Executable("DR.py", base=base)] + +setup( + name="DR", + version=str(sdk_version), + description=py_project["tool"]["lndl"]["nuitka"]["cli"]["file-description"], + options={"build_exe": build_options}, + executables=executables, +)