question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support symlink Python environments

See original GitHub issue

Hello, 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:open
  • Created a year ago
  • Reactions:21
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
karthiknadigcommented, May 19, 2022

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.

0reactions
gandhis1commented, Oct 19, 2022

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 a envPath. In the function resolveCondaEnv, it iterates through all the conda environments, and compares the paths to that environment - if they are the same, per the function areSameEnv, then it uses the info of that environment to construct and return a PythonEnvInfo object. If none of the environments are matched, then it calls resolveSimpleEnv which then uses the directory name as the name of the environment.

  • One possible fix might be to update the function 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.
  • The other possible fix is to update 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. Because resolveSimpleEnv is only ever called from resolveCondaEnv, the impact of this change would be limited.

I’m thinking the second solution is what we need.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found