Skip to content

Commit

Permalink
Stop passing args to pyinstaller through sys.argv
Browse files Browse the repository at this point in the history
It pretty much works the same way
  • Loading branch information
brentvollebregt committed Jun 1, 2024
1 parent 9bab850 commit 3b77993
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"name": "Run auto-py-to-exe",
"type": "python",
"request": "launch",
"module": "auto_py_to_exe"
"module": "auto_py_to_exe",
"justMyCode": false
}
]
}
9 changes: 3 additions & 6 deletions auto_py_to_exe/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,13 @@ def package(pyinstaller_command, options):
# Run PyInstaller
fail = False
try:
# Since we allow manual argument input, we cannot pass arguments to PyInstaller as a list as we can't
# guarantee that the arguments will be parsed correctly. To get around this, we can set sys.argv here with our
# command to trick PyInstaller to reading the command as if we are using the cli tool.
sys.argv = shlex.split(pyinstaller_command) + extra_args # Put command into sys.argv and extra args
pyinstaller_args = shlex.split(pyinstaller_command) + extra_args

# Display the command we are using and leave a space to separate out PyInstallers logs
logger.info("Executing: {}".format(" ".join(sys.argv)))
logger.info("Executing: {}".format(" ".join(pyinstaller_args)))
logger.info("")

run_pyinstaller()
run_pyinstaller(pyinstaller_args[1:])
except: # noqa: E722
fail = True
logger.exception("An error occurred while packaging")
Expand Down

0 comments on commit 3b77993

Please sign in to comment.