You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide the prefix of a possibly activated conda environment in getExecutionDetails API #13044
Would be great if getExecutionDetails were also providing the prefix of a possibly activated conda environment.
That can be identified using the path from execCommand, but then everybody has to do that by his own doing something like
Check if environment variable CONDA_PREFIX is set and if not:
Check, if there is a conda executable in the same path as the interpreter given in execCommand.
I have a use case where I need to get the conda env prefix during runtime of a conda Python process even if the conda env has not been activated. If there is a more stable way to do that, let me know, please.
The extension knows some open website command offering all favorites in a
quick pick UI in Code. When the open website command is run, the extension requests the current
interpreter selection via the API of ms-python.python and calls some external
Python tool.
For that call the interpreter from execCommand cannot be used since this tool depends on several packages that are not always given in the selected environment. The interpreter selection in VS Code (execCommand) is passed as argument to that external tool and the tool needs to know the conda prefix but is itself not being run in the conda environment of interest.
Here, the conda environment is not properly activated (env var CONDA_PREFIX is not set).
The external Python tool needs to know the conda prefix of interest but is being run by some default conda interpreter.
During runtime the tool can NOT check for sys.prefix or sys.executable to identify the conda prefix for the selected interpreter.
The prefix is needed to request versions for all Python packages installed in that
conda environment to populate the ${MAJOR}, ${MINOR}, and ${PATCH} placeholders
in the URLs (see example listing above).
When the processing/ filling of placeholders is completed, the quick pick UI is being shown.
That way, the developer can always and very quick choose to open an API reference for any Python
package version corresponding to the resource/ folder/ workspace he/ she is working on.
I can imagine that this is just one out of multiple imaginable use cases.
This is why I request that this additional information will be exposed by the API of the
Python extension.
Thanks for the suggestion! We talked about it with the team and we have unfortunately decided we will not be moving forward with this idea. We think there isn't an enough widespread need for this to warrant the maintenance cost for the feature.
Activity
jamilraichouni commentedon Jul 19, 2020
Thanks!
Title of issue
Maybe I should have worded it like that and you may want to change the title of the current issue:
„Provide the conda prefix in
getExecutionDetailsAPI when theexecCommandbelongs to a conda environment.“Example
Something like
Use case
There is a Code extension that maintains website favorites (many of them pointing
to API references/ documentations for Python packages).
Projects often work with different Python environments and Python package versions.
Hence, depending on the selected
the URL to these Python package documentation websites must be adapted according to the currently selected Python
interpreter.
To do so all website favorites are maintained in a template JSON file.
Cut-out example:
[ { "fallback_url": "https://numpy.org/doc/stable/user", "url": "https://numpy.org/doc/${MAJOR}.${MINOR}/user/", "pkg_name": "numpy", "title": "NumPy ${MAJOR}.${MINOR} (Documentation)" }, { "fallback_url": "https://pandas.pydata.org/pandas-docs/stable/", "url": "https://pandas.pydata.org/pandas-docs/version/${MAJOR}.${MINOR}.${PATCH}/", "pkg_name": "pandas", "title": "pandas ${MAJOR}.${MINOR}.${PATCH} (Documentation)" } ]The extension knows some
open websitecommand offering all favorites in aquick pick UI in Code. When the
open websitecommand is run, the extension requests the currentinterpreter selection via the API of
ms-python.pythonand calls some externalPython tool.
For that call the interpreter from
execCommandcannot be used since this tool depends on several packages that are not always given in the selected environment. The interpreter selection in VS Code (execCommand) is passed as argument to that external tool and the tool needs to know the conda prefix but is itself not being run in the conda environment of interest.Here, the conda environment is not properly activated (env var
CONDA_PREFIXis not set).The external Python tool needs to know the conda prefix of interest but is being run by some default conda interpreter.
During runtime the tool can NOT check for
sys.prefixorsys.executableto identify the conda prefix for the selected interpreter.The prefix is needed to request versions for all Python packages installed in that
conda environment to populate the
${MAJOR},${MINOR}, and${PATCH}placeholdersin the URLs (see example listing above).
When the processing/ filling of placeholders is completed, the quick pick UI is being shown.
That way, the developer can always and very quick choose to open an API reference for any Python
package version corresponding to the resource/ folder/ workspace he/ she is working on.
I can imagine that this is just one out of multiple imaginable use cases.
This is why I request that this additional information will be exposed by the API of the
Python extension.
jamilraichouni commentedon Jul 19, 2020
I had to rephrase (detail) the use case (see paragraph with bold text above).
luabud commentedon Sep 9, 2020
Thanks for the suggestion! We talked about it with the team and we have unfortunately decided we will not be moving forward with this idea. We think there isn't an enough widespread need for this to warrant the maintenance cost for the feature.
jamilraichouni commentedon Sep 9, 2020
Alright, thanks that this has been considered in discussions!