I want to make a Python script - let's call it exe.py
- which basically behaves exactly like the Python executable (python.exe, /usr/bin/python
, etc.) does. That is:
python exe.py
runs a shellpython exe.py script.py
runs the Python scriptpython exe.py script.py a b c
runs the Python script with argspython exe.py -c ...
runs a commandpython exe.py -m ...
runs a modulepython exe.py -h
prints that help screen- etc...
I could of course re-implement all this, but I wonder if there isn't a programmatic way to simply pass through the command line and all the arguments and have it behave exactly like python.exe does? Much in the same way as it's possible to run an interactive shell without re-implementing the entire interactive shell.
XY PROBLEM: What I'm actually doing is creating a stand-alone executable with certain hard-to-install libraries packaged into it. I'd like to provide a way to run the version of Python being bundled into the stand-alone executable. PyInstaller takes Python scripts as entry points and turns them into executables for whatever target platform it's building for, so I want to make a Python script which just behaves exactly like the python executable does, so it can be turned into a stand-alone and run in the environment of the packaged executable.
As such I can't just invoke the Python executable since that won't be the packaged version's executable.