Support symlink Python environments
See original GitHub issueHello, we have been using Hermit to install portable versions of python and this is working great except that with VS Code we can not select that python as an interpreter.
For example
/Users/damien/Development/example/bin/python3
because in reality it is:
python3 -> .python3@3.8.pkg
pip3 -> .python3@3.8.pkg
.python3@3.8.pkg -> hermit
I think this is similar to https://github.com/Dart-Code/Dart-Code/issues/3961
❯ code --version
1.67.1
da15b6fd3ef856477bf6f4fb29ba1b7af717770d
arm64
Issue Analytics
- State:
- Created a year ago
- Reactions:21
- Comments:11 (3 by maintainers)
Top Results From Across the Web
venv — Creation of virtual environments — Python 3.11.1 ...
The venv module supports creating lightweight “virtual environments”, each with their ... While symlinks are supported on Windows, they are not recommended.
Read more >Creating a virtual Python environment using venv
Symlinks are a Linux/Unix/Mac thing; instead of copying a file it creates a symbolic link that tells the system where to find the...
Read more >Understanding multiple versions, symlinks, and virtualenv
I know the questions are broad, but anything to help me get a better understanding of this python environment stuff, I would greatly...
Read more >Cannot add symlinked Python/virtualenv as interpreter, e.g. ...
When creating a virtualenv with Python 3's "venv" module, by default on Mac and Linux it symlinks the "bin/python" binary instead of copying....
Read more >28.3. venv — Creation of virtual environments
symlinks – a Boolean value indicating whether to attempt to symlink the Python binary (and any necessary DLLs or other binaries, e.g. pythonw.exe...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there’s enough upvotes then we will consider this feature request in our future planning. If there’s unfortunately not enough upvotes then we will close this issue.
So regarding the conda issues I mentioned above, stepped through the extension host debugger. The way the extension currently works is that when you “Select Interpreter”, it derives an
executablePath
, and aenvPath
. In the functionresolveCondaEnv
, it iterates through all the conda environments, and compares the paths to that environment - if they are the same, per the functionareSameEnv
, then it uses the info of that environment to construct and return aPythonEnvInfo
object. If none of the environments are matched, then it callsresolveSimpleEnv
which then uses the directory name as the name of the environment.areSameEnv
to consider symlinks. However the environment resolution is cached, and I am not aware of any mechanism here that would know to re-resolve the environment if the symlink changes, which it could at any point in time. So I’m not sure this would work without more changes.resolveSimpleEnv
to NOT set the name of the environment, leaving it as an empty string for consistency with non-symlink paths. Later code that invokes conda passes a name if a name is not a null or empty value, but if it is, then it passes a path - this is the behavior we want. BecauseresolveSimpleEnv
is only ever called fromresolveCondaEnv
, the impact of this change would be limited.I’m thinking the second solution is what we need.