Skip to content

Instantly share code, notes, and snippets.

Created May 2, 2020 12:47
What would you like to do?
Compile this file to get a mini python.exe with auto-py-to-exe
This script mimicks part of the python executable, in order for it to be
compiled and shipped using auto-py-to-exe
import sys
import os
thisdir = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(thisdir, 'site-packages'))
sys.path.insert(0, os.path.join(thisdir))
if sys.argv[1] == "--help" or sys.argv[1] == "-h":
print('''usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Options and arguments (and corresponding environment variables):
-c cmd : program passed in as string (terminates option list)
-h : print this help message and exit (also --help)
-V : print the Python version number and exit (also --version)''')
if sys.argv[1] == "--version" or sys.argv[1] == "-V":
print("Python "+('.'.join(str(i) for i in sys.version_info[:3])))
elif sys.argv[1] == "-c":
__file__ = os.path.abspath(sys.argv[1])
sys.argv = sys.argv[1:]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment