Skip to content

Comments

Add venv package manager support to packages pane#12029

Open
bricestacey wants to merge 6 commits intomainfrom
11662/venv-packages-pane
Open

Add venv package manager support to packages pane#12029
bricestacey wants to merge 6 commits intomainfrom
11662/venv-packages-pane

Conversation

@bricestacey
Copy link
Contributor

@bricestacey bricestacey commented Feb 20, 2026

Adds explicit support for Python venv environments in the packages pane. For clarity, venv is supported out of the box using the PipPackageManager, but this is explicit and sets us up for other package managers that would need wildly different implementations:

  • Create VenvPackageManager class extending PipPackageManager
  • Add PackageManagerFactory for environment-based manager selection
  • Update PythonRuntimeSession to use factory pattern
  • Change PipPackageManager methods from private to protected (so VenvPackageManager can extend)

Some thoughts on code quality, welcome encouragement to do any of them or feedback --

  • I could understand if there was a desire to reuse the PipPackageManager instead of extending it with an identical class. I figured at some point, we're likely to need it so might as well have the stub.
  • I think we want to put all the package code into a new packages subfolder.

See #11662

Release Notes

New Features

  • Add support for venv to the Packages pane.

Bug Fixes

  • N/A

QA Notes

This "just works" for venv environments. In fact, none of these code changes are necessary. However, the Factory design pattern sets us up for adding other package managers.

Adds explicit support for Python venv environments in the packages pane:

- Create VenvPackageManager class extending PipPackageManager
- Add PackageManagerFactory for environment-based manager selection
- Update PythonRuntimeSession to use factory pattern
- Change PipPackageManager methods from private to protected

See #11662
@github-actions
Copy link

github-actions bot commented Feb 20, 2026

E2E Tests 🚀
This PR will run tests tagged with: @:critical

readme  valid tags

* @returns The appropriate package manager for the environment
*/
static create(
runtimeSource: string,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you type this as EnvironmentType?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The value from Positron is a string (runtime metadata).

I went ahead and did the union of the two EnvironmentType | string as its more expressive and type safe.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the PackageManagerFactory pattern in this PR but I don't think the VenvPackageManager is necessary. I think it's important to keep the two distinct concepts of:

  1. Environment type
  2. Package manager

These are sometimes exclusively one-to-one, but often not. I'd consider pip a package manager and not an environment type. And I'd consider venv an environment type but not a package manager.

It should still be okay to do something like "if venv type, then use the pip manager" in the factory.

this._interpreterPathService = serviceContainer.get<IInterpreterPathService>(IInterpreterPathService);
this._envVarsService = serviceContainer.get<IEnvironmentVariablesService>(IEnvironmentVariablesService);
this._pipPackageManager = new PipPackageManager(this._pythonPath, this._messageEmitter, serviceContainer);
this._pipPackageManager = PackageManagerFactory.create(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: rename this to _packageManager?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed that we should put this code in a subdirectory.

Move package management files to a dedicated packages/ subdirectory and extract
IPackageManager interface to decouple session from concrete implementation.

See #11662
No longer needed for inheritance since VenvPackageManager was removed.

See #11662
Copy link
Contributor

@austin3dickey austin3dickey left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!!

*
* This factory examines the Python environment type and returns the corresponding
* package manager implementation:
* - Venv environments use VenvPackageManager
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this docstring is a bit out of date now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants