Skip to content

Commit bad86a6

Browse files
authored
bpo-46566: Add new py.exe launcher implementation (GH-32062)
1 parent 5c30388 commit bad86a6

File tree

10 files changed

+2821
-16
lines changed

10 files changed

+2821
-16
lines changed

Doc/using/windows.rst

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,13 @@ minor version. I.e. ``/usr/bin/python2.7-32`` will request usage of the
817817
by the "-64" suffix. Furthermore it is possible to specify a major and
818818
architecture without minor (i.e. ``/usr/bin/python3-64``).
819819

820+
.. versionchanged:: 3.11
821+
822+
The "-64" suffix is deprecated, and now implies "any architecture that is
823+
not provably i386/32-bit". To request a specific environment, use the new
824+
``-V:<TAG>`` argument with the complete tag.
825+
826+
820827
The ``/usr/bin/env`` form of shebang line has one further special property.
821828
Before looking for installed Python interpreters, this form will search the
822829
executable :envvar:`PATH` for a Python executable. This corresponds to the
@@ -937,13 +944,65 @@ For example:
937944
Diagnostics
938945
-----------
939946

940-
If an environment variable ``PYLAUNCH_DEBUG`` is set (to any value), the
947+
If an environment variable :envvar:`PYLAUNCHER_DEBUG` is set (to any value), the
941948
launcher will print diagnostic information to stderr (i.e. to the console).
942949
While this information manages to be simultaneously verbose *and* terse, it
943950
should allow you to see what versions of Python were located, why a
944951
particular version was chosen and the exact command-line used to execute the
945-
target Python.
952+
target Python. It is primarily intended for testing and debugging.
953+
954+
Dry Run
955+
-------
956+
957+
If an environment variable :envvar:`PYLAUNCHER_DRYRUN` is set (to any value),
958+
the launcher will output the command it would have run, but will not actually
959+
launch Python. This may be useful for tools that want to use the launcher to
960+
detect and then launch Python directly. Note that the command written to
961+
standard output is always encoded using UTF-8, and may not render correctly in
962+
the console.
963+
964+
Install on demand
965+
-----------------
966+
967+
If an environment variable :envvar:`PYLAUNCHER_ALLOW_INSTALL` is set (to any
968+
value), and the requested Python version is not installed but is available on
969+
the Microsoft Store, the launcher will attempt to install it. This may require
970+
user interaction to complete, and you may need to run the command again.
971+
972+
An additional :envvar:`PYLAUNCHER_ALWAYS_INSTALL` variable causes the launcher
973+
to always try to install Python, even if it is detected. This is mainly intended
974+
for testing (and should be used with :envvar:`PYLAUNCHER_DRYRUN`).
975+
976+
Return codes
977+
------------
946978

979+
The following exit codes may be returned by the Python launcher. Unfortunately,
980+
there is no way to distinguish these from the exit code of Python itself.
981+
982+
The names of codes are as used in the sources, and are only for reference. There
983+
is no way to access or resolve them apart from reading this page. Entries are
984+
listed in alphabetical order of names.
985+
986+
+-------------------+-------+-----------------------------------------------+
987+
| Name | Value | Description |
988+
+===================+=======+===============================================+
989+
| RC_BAD_VENV_CFG | 107 | A :file:`pyvenv.cfg` was found but is corrupt.|
990+
+-------------------+-------+-----------------------------------------------+
991+
| RC_CREATE_PROCESS | 101 | Failed to launch Python. |
992+
+-------------------+-------+-----------------------------------------------+
993+
| RC_INSTALLING | 111 | An install was started, but the command will |
994+
| | | need to be re-run after it completes. |
995+
+-------------------+-------+-----------------------------------------------+
996+
| RC_INTERNAL_ERROR | 109 | Unexpected error. Please report a bug. |
997+
+-------------------+-------+-----------------------------------------------+
998+
| RC_NO_COMMANDLINE | 108 | Unable to obtain command line from the |
999+
| | | operating system. |
1000+
+-------------------+-------+-----------------------------------------------+
1001+
| RC_NO_PYTHON | 103 | Unable to locate the requested version. |
1002+
+-------------------+-------+-----------------------------------------------+
1003+
| RC_NO_VENV_CFG | 106 | A :file:`pyvenv.cfg` was required but not |
1004+
| | | found. |
1005+
+-------------------+-------+-----------------------------------------------+
9471006

9481007

9491008
.. _windows_finding_modules:

0 commit comments

Comments
 (0)