diff --git a/assets/uploader.spec b/assets/uploader.spec index f216689..77d4e61 100644 --- a/assets/uploader.spec +++ b/assets/uploader.spec @@ -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, @@ -58,7 +58,7 @@ pio_exe = EXE( a.scripts, [], exclude_binaries=True, - name='pio', + name='frozenpy', debug=False, bootloader_ignore_signals=False, strip=False, diff --git a/bin/frozen.py b/bin/frozen.py new file mode 100644 index 0000000..9475e60 --- /dev/null +++ b/bin/frozen.py @@ -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) + diff --git a/bin/gui.py b/bin/gui.py index 5360639..d911649 100755 --- a/bin/gui.py +++ b/bin/gui.py @@ -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'] diff --git a/bin/start_pio.py b/bin/start_pio.py deleted file mode 100644 index b17aa23..0000000 --- a/bin/start_pio.py +++ /dev/null @@ -1,23 +0,0 @@ -import os -import runpy -import sys -from pathlib import Path - - -if __name__ == '__main__': - - if len(sys.argv) > 2 and 'scons' in sys.argv[1]: - - sys.argv = sys.argv[1:] - - try: - runpy.run_path(sys.argv[0], run_name='__main__') - except SystemExit as e: - sys.exit(e.code) - else: - sys.exit(0) - - else: - - from platformio.__main__ import main - sys.exit(main())