Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Port Python Env Tools #25066

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

Merged
merged 4 commits into from
May 14, 2025
Merged

Port Python Env Tools #25066

merged 4 commits into from
May 14, 2025

Conversation

DonJayamanne
Copy link

@DonJayamanne DonJayamanne commented May 14, 2025

  • Tested with .venv, global conda, local conda and global Python
  • Tested both tools

Screenshot 2025-05-14 at 11 54 44
Screenshot 2025-05-14 at 11 57 39
Screenshot 2025-05-14 at 11 57 49

@DonJayamanne DonJayamanne added no-changelog No news entry required skip package*.json package.json and package-lock.json don't both need updating skip tests Updates to tests unnecessary skip-issue-check labels May 14, 2025
"resourcePath"
]
},
"when": "!pythonEnvExtensionInstalled"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will ensure these tools are disabled when Python Env extension is installed

@@ -162,6 +163,7 @@ async function activateUnsafe(
components.pythonEnvs,
);
const proposedApi = buildProposedApi(components.pythonEnvs, ext.legacyIOC.serviceContainer);
registerTools(context,components.pythonEnvs, api.environments, ext.legacyIOC.serviceContainer);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given these tools are temporary until Env extension goes stable, I didn't want to spend too much effort into moving these into the component registration, that was a lot of work, same with using Python API to get env details (there are too many ways to get env details, else resorted to using the external API as thats the stable way).

env: CondaEnvInfo,
forShellExecution?: boolean,
): Promise<string[] | undefined> {
const args = ['-p', env.prefix];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using -p as thats exactly whats done today in getRunPythonArgs,
See the method right above this.

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

export interface PipPackage {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied from Python Env repo

* Returns a promise that rejects with an {@CancellationError} as soon as the passed token is cancelled.
* @see {@link raceCancellation}
*/
export function raceCancellationError<T>(promise: Promise<T>, token: CancellationToken): Promise<T> {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't move into async.ts as that doesn't allow usage of vscode types for some reason.
Left here for private use, again these will go away when env extension is stable.

ourTools.add(
extensions.onDidChange(() => {
const envExtension = extensions.getExtension(ENVS_EXTENSION_ID);
if (envExtension) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if env extension is installed and disable this.

_token: CancellationToken,
): Promise<PreparedToolInvocation> {
return {
invocationMessage: l10n.t('Fetching Python environment information'),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will port these changes to prepareInvocation into the Python env extension soon

: l10n.t(`Installing packages {0} in {1}`, options.input.packageList.sort().join(', '), envName);
} else {
title =
options.input.packageList.length === 1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will port these changes to prepareInvocation into the Python env extension soon

@DonJayamanne DonJayamanne marked this pull request as ready for review May 14, 2025 20:13
@vs-code-engineering vs-code-engineering bot added this to the May 2025 milestone May 14, 2025
@DonJayamanne DonJayamanne merged commit 4367614 into main May 14, 2025
85 checks passed
@DonJayamanne DonJayamanne deleted the don/teenage-stork branch May 14, 2025 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog No news entry required skip package*.json package.json and package-lock.json don't both need updating skip tests Updates to tests unnecessary skip-issue-check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.