cpython_frontend: Support for ~/.virtualenvs directory on unix. #2978
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a first gentle step for #2974 to acknowledge that "~/.virtualenvs" is a standard directory where we might find python binaries managed by virtualenvwrapper and add support for it into Thonny.
It adds a simple glob expansion of the "~/.virtualenvs" directory to find python binaries managed by virtualenvwrapper.
The "allvirtualenv" function backing "lsvirtualenv" for virtualenvwrapper actually activates each virtual environment in a sub shell to enumerate them and find their "prompt" or "name". I don't think we need to go this far.
This mirrors VSCode's Python extension, which scans this directory for interpreters.
This is an attempt at - in light of pep688 finding its way into distros - cohesion between VScode, Thonny and user (command-line) Python environments with the least amount of friction.
I plan to use "~/.virtualenvs" as the default home for a "pimoroni" virtual environment on Raspberry Pi OS. This is where our software installers (simple helper scripts for users who don't want to care about Python's idiosyncrasies) will install our Python libraries.
It might also be worth checking the
WORKON_HOME
environment variable, since VSCode also supports this and the default virtualenvwrapper directory can be overridden by the user. There is no precedent I could find for grabbing an environment variable incpython_frontend/cp_front.py
however.