pypa / flit

Simplified packaging of Python modules
https://flit.pypa.io/
BSD 3-Clause "New" or "Revised" License
2.16k stars 132 forks source link

WARNING: project does not provide the extra #680

Closed aaarrti closed 5 months ago

aaarrti commented 6 months ago

Hi, I have a project which has nested optional dependencies, for example

[project.optional-dependencies]
foo_bar = []
dev = ["sampleproject[foo_bar]"]

running pip install .[dev] prints

WARNING: sampleproject 3.0.0 does not provide the extra 'foo-bar'

even though I have never requested extra foo-bar. It seems to me like flit assumes extra dependencies are always in kebab-case. Is this behaviour expected?

kytta commented 5 months ago

(fyi: I am not a flit maintainer, but I figured I can answer this)

flit assumes extra dependencies are always in kebab-case

In this case, it's actually the correct implementation of this specification — see "Name normalization".

But in any case, flit does not do anything here; When you do pip install .[dev], pip itself parses the extras when installing your package: https://github.com/pypa/pip/blob/9ef0fdfc848c7796d10eae436f8880018851555a/src/pip/_internal/req/constructors.py#L330

So, yes, this behaviour is expected, as all package and extras names in Python get normalized to kebab-case

takluyver commented 5 months ago

Thanks @kytta for answering this!

The normalisation to kebab-case isn't actually implemented yet - it's part of PR #676 - but I don't think that will change pip's behaviour on this. I'm not sure whether depending on an extra in your own project is exactly expected - possibly this doesn't work right when you're installing from a local folder rather than a package index.