Skip to content

Commit

Permalink
feat: 多系统打包
Browse files Browse the repository at this point in the history
  • Loading branch information
mikumifa committed Sep 6, 2024
1 parent 6424b55 commit f797da0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"""

if __name__ == "__main__":
input("gello")
parser = argparse.ArgumentParser()
parser.add_argument("--port", type=int, default=7860, help="server port")
parser.add_argument("--share", type=bool, default=False, help="create a public link")
Expand Down
28 changes: 26 additions & 2 deletions main.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_data_files

import platform
datas = []
datas += collect_data_files('gradio_client')
datas += collect_data_files('gradio')
Expand Down Expand Up @@ -53,4 +53,28 @@ app = BUNDLE(exe,
name='biliTickerBuy.app',
icon='assets/icon.icns',
bundle_identifier=None
)
)
if platform.system() == "Darwin":
## Make app bundle double-clickable
import plistlib
from pathlib import Path
app_path = Path(app.name)

# read Info.plist
with open(app_path / 'Contents/Info.plist', 'rb') as f:
pl = plistlib.load(f)

# write Info.plist
with open(app_path / 'Contents/Info.plist', 'wb') as f:
pl['CFBundleExecutable'] = 'wrapper'
plistlib.dump(pl, f)

# write new wrapper script
shell_script = """#!/bin/bash
dir=$(dirname $0)
open -a Terminal file://${dir}/%s""" % app.appname
with open(app_path / 'Contents/MacOS/wrapper', 'w') as f:
f.write(shell_script)

# make it executable
(app_path / 'Contents/MacOS/wrapper').chmod(0o755)

0 comments on commit f797da0

Please sign in to comment.