| 1 |
This is a simple launcher for Python files, which is functionally equivalent to |
| 2 |
the launchers in setuptools but not based on setuptools code. There are two |
| 3 |
versions of the launcher - console and GUI - built from the same source code. |
| 4 |
|
| 5 |
The launcher has been written as part of the pythonv branch, and is intended |
| 6 |
to facilitate location of the correct Python executable for a script in an |
| 7 |
environment where there may be multiple versions of Python deployed. |
| 8 |
|
| 9 |
The launcher is intended to facilitate script execution under Windows where a |
| 10 |
PEP 397-compatible launcher is not available. The idea is that each Python |
| 11 |
script has a copy of the launcher (symlinks not being generally available |
| 12 |
under Windows). For scripts to work with the launcher, they have to have a name |
| 13 |
ending in -script.py (for a console script) or -script.pyw (for a GUI script). |
| 14 |
The deployment system (e.g. packaging) will ensure that for foo-script.py, a |
| 15 |
console launcher opy named foo.exe is placed in the same directory; for |
| 16 |
bar-script.pyw, a GUI launcher copy named bar.exe is placed in the same |
| 17 |
directory. |
| 18 |
|
| 19 |
Assuming that the relevant directories are on the path, the scripts can be |
| 20 |
invoked using just "foo" or "bar". The foo.exe or bar.exe executable then |
| 21 |
runs: it looks for a script with the appropriate suffix ("-script.py" or |
| 22 |
"-script.pyw") in the same directory, and if found, opens that script to read a |
| 23 |
shebang line indicating which Python executable to use for the script. That |
| 24 |
executable, if found, is launched with the script and other arguments passed: |
| 25 |
|
| 26 |
foo a b c -> c:\path\to\python.exe c:\other\path\to\foo-script.py a b c |
| 27 |
bar d e f -> c:\path\to\pythonw.exe c:\other\path\to\bar-script.pyw d e f |
| 28 |
|
| 29 |
Note: More recently, the launchers have been updated to find their script in an |
| 30 |
archive appended to the executable, rather than a separate file. (This variant |
| 31 |
is enabled when APPENDED_ARCHIVE is #defined). This allows the launchers to be |
| 32 |
used to e.g. run .pyz archives as native Windows executables. |