Should pip support named local requirements?
sbidoul opened this issue · 3 comments
Pip cannot install packages from relative local directories that depend on each other.
Assume you have toola/setup.py
:
from setuptools import setup
setup(
name="toola",
install_requires=["toolb"],
)
and toolb/setup.py
from setuptools import setup
setup(
name="toolb",
)
So toola
depends on toolb
.
pip install --no-index ./toola ./toolb
fails with No matching distribution found for toolb (from toola==0.0.0)
.
A workaround is to use PEP 508 direct urls, so this works:
pip install --no-index "toola @ file://$PWD/toola" "toolb @ file://$PWD/toolb"
Note PEP 508 requires absolute paths. This is however inconvenient and it is not possible to put this in a requirement file.
Describe the solution you'd like
It seems the issue stems from limitation of dependency resolution in presence of unnamed requirements.
PEP 508 provides a mechanism to name requirements, but rightly forbids relative file://
URLs with relative paths. This should continue to be forbidden in Requires-Dist
metadata (see discussion).
So I see two approaches:
- allow a syntax "name @ localdirectory(/localarchive)" for top level requirements only, to help the resolver
- improve the resolution algorithm to extract metadata earlier and discover the name of all top level requirement
Additional context
#192 also touches this subject.
pip install --no-index ./toola ./toolb
fails withNo matching distribution found for toolb (from toola==0.0.0)
.
I wonder if this should be attributed to the resolver’s incompetency. Ideally the resolver probably should be smart enough to know that ./toolb
introduces toolb
(by building it and introspecting metadata), without the user needing to supply that information.
The new resolver may address this (as we "prepare" unnamed requirements eagerly). Does this still happen f you use master with --unstable-feature=resolver
?
Ah, yes indeed, the new resolver copes with that example just fine. Great!
So the remaining use case for named local requirements would be #192 (comment)