Is there an easy way to make a script to accurately simulate the functionality of a python executable, for use in deploying PyInstaller?

I want to make a Python script - allow the call exe.py- which basically behaves exactly like the Python executable (python.exe, /usr/bin/pythonetc.). I.e:

  • python exe.py launches a shell
  • python exe.py script.py runs a python script
  • python exe.py script.py a b c runs a python script using args
  • python exe.py -c ... runs the command
  • python exe.py -m ... starts the module
  • python exe.py -h prints a help screen
  • etc...

I could, of course, reimplement all of this, but I wonder if there is a programmatic way to just go through the command line and all the arguments and behave the same as python.exe? In much the same way you can launch an interactive shell without re-implementing the entire interactive shell.

XY : , , , . Python, . PyInstaller Python , , Python script, , python, .

, Python, .

+4
1

- script os.system subprocess. , , . exe.py:

import subprocess
import sys

python_script = sys.argv.pop(0)
call          = [sys.excecutable] + python_script + sys.argv
result        = subprocess.check_call(call)

exe.py python. argparse, / .

@Laurent LAPORTE .

0

Source: https://habr.com/ru/post/1662181/


All Articles