| 17 | |
| 18 | |
| 19 | def package_scripts(): |
| 20 | |
| 21 | if os.path.exists('dist/palworld-python-script.zip'): |
| 22 | os.remove('dist/palworld-python-script.zip') |
| 23 | print('已删除原dist/palworld-python-script.zip') |
| 24 | if os.path.exists('palworld-python-script.zip'): |
| 25 | os.remove('palworld-python-script.zip') |
| 26 | print('已删除原palworld-python-script.zip') |
| 27 | |
| 28 | scripts = ['task_scheduler.py', 'backup.py'] |
| 29 | print('正在打包:', scripts) |
| 30 | |
| 31 | for script in scripts: |
| 32 | |
| 33 | command = 'pyinstaller', '--onefile', script |
| 34 | subprocess.run(command) |
| 35 | |
| 36 | shutil.copy('config.ini', 'dist') |
| 37 | |
| 38 | shutil.make_archive('palworld-python-script', 'zip', 'dist') |
| 39 | print("palworld-python-script 打包成功!") |
| 40 | |
| 41 | shutil.move('palworld-python-script.zip', 'dist') |
| 42 | print("打包后的palworld-python-script.zip已放入dist文件夹!") |
| 43 | |
| 44 | |
| 45 | if __name__ == '__main__': |