Skip to content

Let a project override the PyPI to conda name map - #21

Merged
timkpaine merged 1 commit into
mainfrom
tkp/name-map-overrides
Aug 28, 2026
Merged

Let a project override the PyPI to conda name map#21
timkpaine merged 1 commit into
mainfrom
tkp/name-map-overrides

Conversation

@timkpaine

@timkpaine timkpaine commented Aug 28, 2026

Copy link
Copy Markdown
Member

The vendored PyPI→conda table only covers what conda-forge knows about. A project depending on distributions packaged elsewhere — or packaging its own — had no way to say how those names translate, short of waiting for the table to be regenerated from grayskull.

Adds two optional tables to the [tool.nepenthe] stanza:

[tool.nepenthe.package-mappings]
example-package = "example-conda-package"

[tool.nepenthe.extras-mappings]
"example-package[extra]" = ["example-package", "example-package-extra"]

package-mappings renames a distribution, taking precedence over the vendored entry (or supplying one where there is none).

extras-mappings covers a case a rename cannot express. conda has no equivalent of a PyPI extras group, so a distribution that splits its optional features into separate conda packages is a one-to-many translation. parse_requirement previously discarded the extras group outright, which made this invisible.

Behaviour

  • check requires every package an extras group expands to, reporting the first that is missing or in conflict.
  • try adds one conda spec per package, each carrying the requirement's specifier.
  • An extras group with no mapping still resolves to the distribution name alone — the same result as before, so nothing changes for existing projects.
  • Keys are normalized, so casing, separator style and extras order are irrelevant. An extras-mappings key with no […] group is ignored.
  • try --project reads both tables without requiring the rest of the stanza.

API

check_dependencies and requirements_to_conda_specs take a &name_map::Overrides; parse_requirement returns the extras group. New: name_map::Overrides, name_map::extras_key, ProjectRef::name_overrides, project::read_name_overrides. The Python surface is unchanged.

The vendored table only covers what conda-forge knows about. A project
depending on distributions packaged elsewhere had no way to say how those
names translate, short of waiting for the table to be regenerated.

Add two optional tables to the [tool.nepenthe] stanza. package-mappings
renames a distribution, taking precedence over the vendored entry.
extras-mappings maps a requirement's extras group onto several conda
packages, which a rename cannot express: conda has no equivalent of an
extras group, so a distribution that splits its optional features into
separate packages is a one-to-many translation.

parse_requirement now returns the extras group instead of discarding it.
check requires every package an extras group expands to, reporting the
first that is missing or in conflict, and try adds one spec per package.
An extras group with no mapping still resolves to the distribution name
alone, so existing behaviour is unchanged.
@github-actions

Copy link
Copy Markdown

Test Results

189 tests  +7   189 ✅ +7   8s ⏱️ +2s
  5 suites ±0     0 💤 ±0 
  2 files   ±0     0 ❌ ±0 

Results for commit 0925860. ± Comparison against base commit d5202b1.

This pull request removes 1 and adds 8 tests. Note that renamed tests count towards both.
nepenthe-core ‑ project::tests::parse_requirement_extracts_name_and_specifier
nepenthe-core ‑ name_map::tests::a_package_override_wins_over_the_vendored_table
nepenthe-core ‑ name_map::tests::an_extras_override_expands_to_several_packages
nepenthe-core ‑ name_map::tests::an_unmapped_extras_group_resolves_to_the_name_alone
nepenthe-core ‑ name_map::tests::extras_keys_without_a_group_are_ignored
nepenthe-core ‑ name_map::tests::overrides_default_to_the_vendored_table
nepenthe-core ‑ project::tests::check_expands_an_extras_group_and_requires_every_package
nepenthe-core ‑ project::tests::check_prefers_a_package_override_over_the_vendored_table
nepenthe-core ‑ project::tests::parse_requirement_extracts_name_extras_and_specifier

@timkpaine
timkpaine merged commit c1630ed into main Aug 28, 2026
5 checks passed
@timkpaine
timkpaine deleted the tkp/name-map-overrides branch August 28, 2026 20:12
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.

1 participant