posit-dev / posit-dev/positron

Surface package install origin (editable/local/VCS) in getPackages so requirements can be reconstructed faithfully

Open
#14,522 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: environment enhancement lang: python
Dominant language
TypeScript
Stars
4.3k
Forks
184
Avg merge
1d 11h
Merged PRs (30d)
206

Description

The env-safety fix in #14328 (PR #14520) builds the pip install -r / uv pip install -r requirements file from the kernel's
installed-package list (getPackagesInstalled -> getPackages), naming every installed package so the resolver honors all constraints.
That list is name-only, so packages installed editable (-e), from a local path, or from a VCS URL are emitted as bare names.

That's correct for the common case, but bare-naming a non-PyPI package has edges when the resolver has to move it (a version conflict, or
Update All's --upgrade, which seeks a newer version of everything):

  • A different package with the same name on the configured index could be substituted (name collision).
  • Update All could fail with "no matching distribution" for a local-only package instead of keeping the installed copy.

Proposal

Surface install origin on LanguageRuntimePackage so package operations can emit a faithful requirement line for these packages instead of
a bare name.

  • The Python kernel's _get_packages_installed already walks importlib.metadata.distributions(); it can read each dist's PEP 610
    direct_url.json to determine whether it was installed editable, from a local directory/archive, or from a VCS.
  • Add a field (e.g. editable: boolean and/or source/directUrl) to LanguageRuntimePackage in positron.d.ts.
  • The pip/uv package managers then emit name @ file://... / -e ... for those packages and bare names for the rest, eliminating both
    edges above.

Some of this information is not portable to other languages, so we might want to consider supporting a generic type, like Map<string, string> instead of enumerating every possible field required per language.

Notes

  • Enhancement: current bare-name behavior is correct for normal PyPI packages, which is the overwhelming majority.

See #14328.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing getPackagesInstalled through getPackages and the Python kernel’s _get_packages_installed, then inspect LanguageRuntimePackage in positron.d.ts and the pip/uv package managers. Confirm how PEP 610 direct_url.json represents editable, local, and VCS installs. Done means preserving those origins in package data and emitting faithful requirement lines while keeping ordinary packages as bare names.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, typescript
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.