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

cpython_frontend: Support for ~/.virtualenvs directory on unix. #2978

Merged

Conversation

Gadgetoid
Copy link
Contributor

@Gadgetoid Gadgetoid commented Oct 24, 2023

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 in cpython_frontend/cp_front.py however.

Add a simple glob expansion of the "~/.virtualenvs" directory to find
python binaries managed by virtualenvwrapper.

This mirrors VSCode's Python extension, which scans this directory for
interpreters.

Signed-off-by: Phil Howard <phil@gadgetoid.com>
@aivarannamaa
Copy link
Member

I think it's worth consulting WORKON_HOME. If my commit looks right to you then I'll merge it and it will be part of Thonny 5.0.0b1

@Gadgetoid
Copy link
Contributor Author

This - famous last words - looks reasonable. Thank you!

@aivarannamaa aivarannamaa merged commit 397679c into thonny:master Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants