Skip to content

Commit

Permalink
allow external python scripts to run when pio is frozen
Browse files Browse the repository at this point in the history
  • Loading branch information
kinsamanka committed Jan 28, 2023
1 parent 2ea0135 commit 4b5e353
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 26 deletions.
4 changes: 2 additions & 2 deletions assets/uploader.spec
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ for c in cmds:
datas += [(dir, '.')]

a = Analysis(
['../bin/start_pio.py'],
['../bin/frozen.py'],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
Expand Down Expand Up @@ -58,7 +58,7 @@ pio_exe = EXE(
a.scripts,
[],
exclude_binaries=True,
name='pio',
name='frozenpy',
debug=False,
bootloader_ignore_signals=False,
strip=False,
Expand Down
25 changes: 25 additions & 0 deletions bin/frozen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
import runpy
import sys
from pathlib import Path


if __name__ == '__main__':

if len(sys.argv) > 2:

sys.argv = sys.argv[1:]

if 'pio' in sys.argv[0]:
from platformio.__main__ import main
sys.exit(main())
else:
try:
runpy.run_path(sys.argv[0], run_name='__main__')
except SystemExit as e:
sys.exit(e.code)
else:
sys.exit(0)
else:
sys.exit(1)

2 changes: 1 addition & 1 deletion bin/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, cwd, e):
self.upload = False

if is_frozen:
self.cmd = [f'{Path(sys._MEIPASS) / "pio"}']
self.cmd = [f'{Path(sys._MEIPASS) / "frozenpy"}', 'pio']
else:
self.cmd = ['pio']

Expand Down
23 changes: 0 additions & 23 deletions bin/start_pio.py

This file was deleted.

0 comments on commit 4b5e353

Please sign in to comment.