Skip to content
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

Inconsistency in _ -> - normalization #503

Closed
Conchylicultor opened this issue Jan 3, 2022 · 4 comments
Closed

Inconsistency in _ -> - normalization #503

Conchylicultor opened this issue Jan 3, 2022 · 4 comments

Comments

@Conchylicultor
Copy link

I'm using a PEP 621 toml using flit 3.5 & pip 21.3.1:

My toml has self-refering optional-dependencies:

[build-system]
requires = ["flit_core >=3.5,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "etils"

[project.optional-dependencies]
array_types = ["numpy"]
all = ["etils[array_types]"]

When running pip install -e .[all], this logs:

WARNING: etils 0.2.0 does not provide the extra 'array-types'

It looks like "etils[array_types]" gets normalized to [array-types], but not array_types = ["numpy"].

Manually replacing array_types = ["numpy"] -> array-types = ["numpy"] solve the issue.

But this behavior feels inconsistent.

@takluyver
Copy link
Member

PEP 508, which defines the syntax for specifying extras, allows -_. in the name of an extra, and doesn't specify any normalisation rule, which suggests that array_types and array-types are two separate extras. I'd guess that pip normalises them, probably like distribution names (rule in PEP 503). I don't know if there's any other spec that says this is the right thing to do, or if it's just following something that setuptools/easy_install have done without it ever being written in any spec.

The core metadata spec says that an extra name "must be a valid Python identifier", which implies that array-types is not even a legal value. That conflicts with PEP 508, so at least one of the specs must be wrong. 🤷

@pradyunsg
Copy link
Member

pradyunsg commented Jan 3, 2022

Here's what flit generates (in the METADATA file, that pip reads from):

Requires-Dist: installer[array_types] ; extra == "all"
Requires-Dist: numpy ; extra == "array_types"
Provides-Extra: all
Provides-Extra: array_types

This is definitely a pip bug.

@Conchylicultor
Copy link
Author

Thanks for the fast answer. Closing this. Will open a new issue in pip.

@Conchylicultor
Copy link
Author

As follow up, it seems the inconsistency issue is discussed in https://discuss.python.org/t/7614

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

No branches or pull requests

3 participants