Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using the py launcher on Windows #41

Open
zsol opened this issue May 30, 2022 · 1 comment
Open

Consider using the py launcher on Windows #41

zsol opened this issue May 30, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@zsol
Copy link

zsol commented May 30, 2022

Description

While trying to figure out available Python versions, thx attempts to run python3 -V which on Windows generally resolves to %LocalAppData%\Microsoft\WindowsApps\python3.EXE -V, which is not a python interpreter unfortunately (it brings up the Microsoft Store window pointed to the Python "App" when run without args).

This results in the following warning on every thx invocation:

WARNING context:59: running `C:\Users\zsolz\AppData\Local\Microsoft\WindowsApps\python3.EXE -V` gave unexpected version string: ''

Instead of thx trying to figure out all the available python installations, maybe it's worth delegating this task to the py launcher:

> py --help
Python Launcher for Windows Version 3.10.150.1013

usage:
C:\windows\py.exe [launcher-args] [python-args] [script [script-args]]

Launcher arguments:

-2     : Launch the latest Python 2.x version
-3     : Launch the latest Python 3.x version
-X.Y   : Launch the specified Python version
     The above all default to 64 bit if a matching 64 bit python is present.
-X.Y-32: Launch the specified 32bit Python version
-X-32  : Launch the latest 32bit Python X version
-X.Y-64: Launch the specified 64bit Python version
-X-64  : Launch the latest 64bit Python X version
-0  --list       : List the available pythons
-0p --list-paths : List with paths

 If no script is specified the specified interpreter is opened.
If an exact version is not given, using the latest version can be overridden by
any of the following, (in priority order):
 An active virtual environment
 A shebang line in the script (if present)
 With -2 or -3 flag a matching PY_PYTHON2 or PY_PYTHON3 Environment variable
 A PY_PYTHON Environment variable
 From [defaults] in py.ini in your %LOCALAPPDATA%\py.ini
 From [defaults] in py.ini beside py.exe (use `where py` to locate)

Here's an example output:

> py -0p             
Installed Pythons found by C:\windows\py.exe Launcher for Windows
 -3.10-64       C:\Users\zsolz\AppData\Local\Programs\Python\Python310\python.exe *
 -3.9-64        C:\Users\zsolz\AppData\Local\Programs\Python\Python39\python.exe

Details

  • OS: Windows
  • Python version: any
  • thx version: 0.5.0
  • Can you repro on main? probably? :)
  • Can you repro in a clean virtualenv? yes
@amyreese amyreese added the enhancement New feature or request label Sep 18, 2022
@lordmauve
Copy link

There's a Python launcher for unix, so it's not unreasonable to offer this cross-platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants