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

Should pip support named local requirements? #8035

Open
sbidoul opened this issue Apr 13, 2020 · 3 comments
Open

Should pip support named local requirements? #8035

sbidoul opened this issue Apr 13, 2020 · 3 comments
Labels
C: direct url Direct URL references (PEP 440, PEP 508, PEP 610) C: unnamed reqs Handling and processing unnamed requirements state: needs discussion This needs some more discussion

Comments

@sbidoul
Copy link
Member

sbidoul commented Apr 13, 2020

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:

  1. allow a syntax "name @ localdirectory(/localarchive)" for top level requirements only, to help the resolver
  2. improve the resolution algorithm to extract metadata earlier and discover the name of all top level requirement

Additional context

#192 also touches this subject.

@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Apr 13, 2020
@sbidoul sbidoul added C: unnamed reqs Handling and processing unnamed requirements state: needs discussion This needs some more discussion labels Apr 13, 2020
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Apr 13, 2020
@uranusjr
Copy link
Member

pip install --no-index ./toola ./toolb fails with No 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.

@pfmoore
Copy link
Member

pfmoore commented Apr 13, 2020

The new resolver may address this (as we "prepare" unnamed requirements eagerly). Does this still happen f you use master with --unstable-feature=resolver?

@sbidoul
Copy link
Member Author

sbidoul commented Apr 13, 2020

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: direct url Direct URL references (PEP 440, PEP 508, PEP 610) C: unnamed reqs Handling and processing unnamed requirements state: needs discussion This needs some more discussion
Projects
None yet
Development

No branches or pull requests

3 participants