准备最终的打包版本
Showing
4 changed files
with
43 additions
and
9 deletions
| ... | @@ -19,21 +19,33 @@ pyz = PYZ(a.pure) | ... | @@ -19,21 +19,33 @@ pyz = PYZ(a.pure) |
| 19 | exe = EXE( | 19 | exe = EXE( |
| 20 | pyz, | 20 | pyz, |
| 21 | a.scripts, | 21 | a.scripts, |
| 22 | a.binaries, | ||
| 23 | a.datas, | ||
| 24 | [], | 22 | [], |
| 23 | exclude_binaries=True, | ||
| 25 | name='ZB100ImageGenerator', | 24 | name='ZB100ImageGenerator', |
| 26 | debug=False, | 25 | debug=False, |
| 27 | bootloader_ignore_signals=False, | 26 | bootloader_ignore_signals=False, |
| 28 | strip=False, | 27 | strip=False, |
| 29 | upx=True, | 28 | upx=True, |
| 30 | upx_exclude=[], | ||
| 31 | runtime_tmpdir=None, | ||
| 32 | console=False, | 29 | console=False, |
| 33 | disable_windowed_traceback=False, | 30 | disable_windowed_traceback=False, |
| 34 | argv_emulation=False, | 31 | argv_emulation=False, |
| 35 | target_arch=None, | 32 | target_arch=None, |
| 36 | codesign_identity=None, | 33 | codesign_identity=None, |
| 37 | entitlements_file=None, | 34 | entitlements_file=None, |
| 38 | icon=['zb100_kehuan.ico'], | 35 | icon=['zb100_mac.icns'], |
| 36 | ) | ||
| 37 | coll = COLLECT( | ||
| 38 | exe, | ||
| 39 | a.binaries, | ||
| 40 | a.datas, | ||
| 41 | strip=False, | ||
| 42 | upx=True, | ||
| 43 | upx_exclude=[], | ||
| 44 | name='ZB100ImageGenerator', | ||
| 45 | ) | ||
| 46 | app = BUNDLE( | ||
| 47 | coll, | ||
| 48 | name='ZB100ImageGenerator.app', | ||
| 49 | icon='zb100_mac.icns', | ||
| 50 | bundle_identifier=None, | ||
| 39 | ) | 51 | ) | ... | ... |
build_mac.sh
100644 → 100755
| ... | @@ -27,9 +27,10 @@ rm -rf build dist *.spec | ... | @@ -27,9 +27,10 @@ rm -rf build dist *.spec |
| 27 | # Build executable | 27 | # Build executable |
| 28 | echo "Building executable..." | 28 | echo "Building executable..." |
| 29 | pyinstaller --name="ZB100ImageGenerator" \ | 29 | pyinstaller --name="ZB100ImageGenerator" \ |
| 30 | --onefile \ | 30 | --onedir \ |
| 31 | --windowed \ | 31 | --windowed \ |
| 32 | --add-data "config.json:." \ | 32 | --add-data "config.json:." \ |
| 33 | --icon=zb100_mac.icns \ | ||
| 33 | image_generator.py | 34 | image_generator.py |
| 34 | 35 | ||
| 35 | # Check if build was successful | 36 | # Check if build was successful | ... | ... |
| ... | @@ -29,17 +29,17 @@ if exist "*.spec" del /q *.spec | ... | @@ -29,17 +29,17 @@ if exist "*.spec" del /q *.spec |
| 29 | REM Build executable | 29 | REM Build executable |
| 30 | echo Building executable... | 30 | echo Building executable... |
| 31 | pyinstaller --name="ZB100ImageGenerator" ^ | 31 | pyinstaller --name="ZB100ImageGenerator" ^ |
| 32 | --onefile ^ | 32 | --onedir ^ |
| 33 | --windowed ^ | 33 | --windowed ^ |
| 34 | --icon=zb100_kehuan.ico ^ | 34 | --icon=zb100_kehuan.ico ^ |
| 35 | --add-data "config.json;." ^ | 35 | --add-data "config.json;." ^ |
| 36 | image_generator.py | 36 | image_generator.py |
| 37 | 37 | ||
| 38 | REM Check if build was successful | 38 | REM Check if build was successful |
| 39 | if exist "dist\ZB100ImageGenerator.exe" ( | 39 | if exist "dist\ZB100ImageGenerator\ZB100ImageGenerator.exe" ( |
| 40 | echo ================================ | 40 | echo ================================ |
| 41 | echo Build successful! | 41 | echo Build successful! |
| 42 | echo Executable: dist\ZB100ImageGenerator.exe | 42 | echo Executable: dist\ZB100ImageGenerator\ZB100ImageGenerator.exe |
| 43 | echo ================================ | 43 | echo ================================ |
| 44 | ) else ( | 44 | ) else ( |
| 45 | echo ================================ | 45 | echo ================================ | ... | ... |
| ... | @@ -19,6 +19,7 @@ import io | ... | @@ -19,6 +19,7 @@ import io |
| 19 | import json | 19 | import json |
| 20 | import os | 20 | import os |
| 21 | import sys | 21 | import sys |
| 22 | import shutil | ||
| 22 | import tempfile | 23 | import tempfile |
| 23 | import platform | 24 | import platform |
| 24 | from pathlib import Path | 25 | from pathlib import Path |
| ... | @@ -982,6 +983,26 @@ def main(): | ... | @@ -982,6 +983,26 @@ def main(): |
| 982 | config_dir.mkdir(parents=True, exist_ok=True) | 983 | config_dir.mkdir(parents=True, exist_ok=True) |
| 983 | config_path = config_dir / 'config.json' | 984 | config_path = config_dir / 'config.json' |
| 984 | 985 | ||
| 986 | # If config doesn't exist in user directory, copy from bundled resources | ||
| 987 | if not config_path.exists(): | ||
| 988 | if getattr(sys, 'frozen', False): | ||
| 989 | # Running as bundled app - look in Resources folder (macOS .app bundle) | ||
| 990 | if platform.system() == 'Darwin': | ||
| 991 | # macOS: Contents/Resources/config.json | ||
| 992 | bundled_config = Path(sys.executable).parent.parent / 'Resources' / 'config.json' | ||
| 993 | else: | ||
| 994 | # Windows/Linux: same directory as executable | ||
| 995 | bundled_config = Path(sys.executable).parent / 'config.json' | ||
| 996 | |||
| 997 | if bundled_config.exists(): | ||
| 998 | try: | ||
| 999 | shutil.copy2(bundled_config, config_path) | ||
| 1000 | print(f"✓ Copied config from {bundled_config} to {config_path}") | ||
| 1001 | except Exception as e: | ||
| 1002 | print(f"✗ Failed to copy bundled config: {e}") | ||
| 1003 | else: | ||
| 1004 | print(f"✗ Bundled config not found at {bundled_config}") | ||
| 1005 | |||
| 985 | db_config = None | 1006 | db_config = None |
| 986 | last_user = "" | 1007 | last_user = "" |
| 987 | saved_password_hash = "" | 1008 | saved_password_hash = "" | ... | ... |
-
Please register or sign in to post a comment