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

Provide a public API to set the environment to a given path #16994

Closed
brettcannon opened this issue Aug 16, 2021 Discussed in #16504 · 11 comments
Closed

Provide a public API to set the environment to a given path #16994

brettcannon opened this issue Aug 16, 2021 Discussed in #16504 · 11 comments
Assignees
Labels
area-environments Features relating to handling interpreter environments area-internal Label for non-user facing issues community ask Feature request that the community expressed interest in feature-request Request for new features or functionality needs proposal Need to make some design decisions on-testplan Added to test plan

Comments

@brettcannon
Copy link
Member

Discussed in #16504

Originally posted by brettcannon June 16, 2021
I have an extension that currently changes the python executable being used by setting it in the user or workspace settings.json (depending how the user chooses to do it).

In the description of https://github.com/microsoft/vscode-python/wiki/AB-Experiments#deprecatepythonpath, I can't really see any way for an extension to update the python used by the vscode-python extension after the move to stop using the settings.json.

So, this is a request to provide an API/command to provide parity with what was already available prior to this change (or if there is already a way to do it, document it in https://github.com/microsoft/vscode-python/wiki/AB-Experiments#deprecatepythonpath).

Originally posted by @fabioz in a discussion

@brettcannon brettcannon added feature-request Request for new features or functionality triage-needed Needs assignment to the proper sub-team area-internal Label for non-user facing issues needs FR policy and removed triage-needed Needs assignment to the proper sub-team labels Aug 16, 2021
@brettcannon
Copy link
Member Author

Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 5 👍 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.

@brettcannon
Copy link
Member Author

Thank you to everyone who upvoted this issue! Since the community showed interest in this feature request we will leave this issue open as something to consider implementing at some point in the future.

We do encourage people to continue 👍 this issue as it helps us prioritize our work based on what the community seems to want the most.

@brettcannon brettcannon added community ask Feature request that the community expressed interest in needs proposal Need to make some design decisions and removed needs decision needs community feedback Awaiting community feedback labels Oct 15, 2021
@kariharju
Copy link

Hi, any news on this front?

This is causing more and more problems when trying to use isolated Python environments.

For a bit of background why this is a big thing (to us at least) is that in RPA space we cannot assume that the end-users know how to manage and install Python versions on their machines so the normal "works for me" that developers can easily solve makes things impossible when deploying. So we built a toolchain around actually making repeatable, isolated python environment setups so that we can also reliably cache things between different environments: https://github.com/robocorp/rcc/blob/master/docs/environment-caching.md

So this is how we can execute python-based items reliable on just about any platform so now it would be critical that the developer see the same thing in their tooling and actually stop relying on: "I have Python x.y installed and in PATH, you need to do that l as well".

@brettcannon
Copy link
Member Author

The update is we have v1 of our read-only API designed, implemented, and we are starting to use it within the extension to make sure it works (the hope is to have this work done by our next release in February). We are then going to make sure first-party extensions have their needs met with the API. After that validation the API will go public be considered ready for use.

Once our public API has gone out we can discuss providing an API to allow other extensions to set the selected environment. We will very likely lean on the community for proposing a design, justifying it, etc. since we have no need for such an API.

P.S.: I somewhat disagree with using that XKCD comic to prove a point. 😉

@kariharju
Copy link

Pinging here as we saw the Python iteration plan: #18214
So a couple of questions.

Seeing "Implement the proposed public API for the extension and use it internally vscode-python#17905" there and that related issue (#17905) is closed already, leads one to believe that at least some API already done, but is it coming out or..?
..if the plan is to remove the pythonPath support without anything in its place is a bit drastic as we would have to resort to guiding people on how-to copy&paste python paths.

So the other direct question is when is this release planned to happen that drops the experiment phase?

We are also trying to deduce another way based on this: https://github.com/microsoft/vscode-python/wiki/AB-Experiments#tldr
..so if we understand this correctly if we call Python: Clear Workspace Interpreter Setting and then set python.defaultInterpreterPath to point to the location of the python env. should that work?

@brettcannon we have well over 1k active users building RPA bots with VS Code that really kind of depend on this, so I'd like to get ahead of the problem as much as possible 😅

@karthiknadig
Copy link
Member

karthiknadig commented Jan 18, 2022

@kariharju That (#17905) got closed by mistake. I am working on the proposed public API, I will post here when it is in.

@karthiknadig
Copy link
Member

@kariharju This is now in main. The API to set active python interpreter looks like this

setActiveInterpreter(interpreterPath: string, resource?: Resource): Promise<void>;

@karthiknadig
Copy link
Member

This build has the setActiveInterpreter API, please give it a try and let me know:
https://github.com/microsoft/vscode-python/suites/4983385795/artifacts/145624970

@kariharju
Copy link

Awesome!
We'll take a look and test.

@kariharju
Copy link

Great we now have an implementation that uses the API if/when it exists and if not we call Python: Clear Workspace Interpreter Setting and then set python.defaultInterpreterPath way.
Thank you for this @karthiknadig !

@karrtikr karrtikr self-assigned this Aug 16, 2022
@karrtikr karrtikr added the area-environments Features relating to handling interpreter environments label Aug 16, 2022
@karrtikr karrtikr added this to the September 2022 milestone Sep 2, 2022
@karthiknadig karthiknadig removed their assignment Sep 16, 2022
@karrtikr karrtikr added the on-testplan Added to test plan label Sep 26, 2022
@karrtikr
Copy link

Note API name is now changed, see https://github.com/microsoft/vscode-python/blob/main/src/client/proposedApiTypes.ts#L23

Feature (#19841) should be out in the pre-release version of the extension in a day, use the following to try it out:

image

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments area-internal Label for non-user facing issues community ask Feature request that the community expressed interest in feature-request Request for new features or functionality needs proposal Need to make some design decisions on-testplan Added to test plan
Projects
None yet
Development

No branches or pull requests

4 participants