Skip to content

Apply default extras when resolving an already-installed candidate#12

Closed
astrofrog wants to merge 7 commits into
wheelnext:pep_771from
astrofrog:fix-bug-already-installed
Closed

Apply default extras when resolving an already-installed candidate#12
astrofrog wants to merge 7 commits into
wheelnext:pep_771from
astrofrog:fix-bug-already-installed

Conversation

@astrofrog

@astrofrog astrofrog commented May 18, 2026

Copy link
Copy Markdown

This fixes the following scenario:

pip install package[]
pip install package

with this fix here, the second command installs the default extras (before, there was a warning and the default extras didn't get installed)

This is to address the failure in wheelnext/pep_771-Default-Extras#3

astrofrog and others added 6 commits January 21, 2025 12:56
…nt default extras if present and if extras not specified
…ult extras (#1)

* Experimental implementation of supporting [] disabling default extras

* Fix cases of package[...]==version
_make_candidate_from_link picks up default extras via prepare.py mutating
the install requirement's extras during distribution preparation, but the
already-installed path went through _make_candidate_from_dist, which read
nothing from the dist's Default-Extra metadata. Without the same mutation,
the resolvelib _extras sync left the criterion keyed by the bare name, so
default-extra dependencies failed the marker check and were dropped.

Mirror prepare.py here: when the caller and template specify no extras,
read dist.iter_default_extras() and write it back to template.extras and
template.req.extras before wrapping the base in an ExtrasCandidate.
@astrofrog astrofrog closed this May 18, 2026
@astrofrog astrofrog reopened this May 18, 2026
default_extras_require is defined on the base Distribution class but
reads self._parsed_pkg_info, which is only defined on DistInfoDistribution
(the .dist-info subclass). For egg-info-backed distributions the property
raised AttributeError; Python then fell through to __getattr__, which
delegated to the PathMetadata provider and surfaced a confusing error.

Egg-info distributions do not carry PEP 771 metadata, so return an empty
list when _parsed_pkg_info is unavailable.
@astrofrog

Copy link
Copy Markdown
Author

Ok so while this fixes the immediate issue, there are actually a number of CI failures being hidden by the fact the base branch here is out of date with main and the CI isn't running. I think a better solution is #13

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