-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Package's VCS dependencies do not build and install when doing a pip install] #10095
Comments
I can raise a PR for this if the proposed solve seems right. Please suggest. |
Thanks for the detailed issue description! Can you provide a minimal reproducer for this? |
I think |
@uranusjr: It doesn't. This feature works for top level packages and will recursively apply to all collected dependencies as well. The problem here is that the code block I referenced above, doesn't even allow VCS packages to be collected as 'buildable/installble' dependencies. |
Okay, so I figured out that this isn't an entirely broken flow. This breaks only(or rather works as expected but sadly doesn't emit sufficient warnings) when a VCS dependency is already installed. The scenario is that if you have a VCS dependency that has already been installed somewhere in your environment, pip silently swallows that detail and skips the package from being built and installed again. The behavior is different for already installed wheels or sdist however: https://github.com/pypa/pip/blob/main/src/pip/_internal/resolution/resolvelib/resolver.py#L160
In my case, I had the VCS package built and installed into a local workspace and no matter how many times I did a We can either a) add a logger/deprecated warning similar to sdist/wheels use-case, b) add a warning but still allow reinstalls for VCS dependencies if pip cannot/doesn't track the last installed commitId/tag. Also confirmed that this is the same behavior even with |
Cool, that's what I expected based on a reading of the code -- so it's good to have a confirmation on this. IDK what the right answer here is, so it's gonna be a while before I respond. FWIW, this is the same problem as the one that lead to us adding those warnings -- we didn't account for this case when we were writing this chunk of code originally, and it's showing through the cracks. :) |
@harshmttl Could you confirm that the behaviour between |
Here's a quick repro:
Actual output
|
@pradyunsg: legacy resolver is behaving the same as default resolver. Verified with the above repro setup. |
The main and dev branches of your dependency both have the same name and version. So pip will see that name/version is already installed and not reinstall. This seems to me like a problem with the code, not with pip. |
Fair point. However:
|
That's not the approach taken anywhere else, so I'd be against special-casing this one situation. Making the uniqueness condition include the branch name globally sounds to me like a much bigger change, so I think it needs more discussion (disclaimer, I'm not that familiar with the rules on how we handle VCS URLs, as they aren't covered by any of the existing standards, so I'm guessing a bit here).
Agreed. |
+1, and I think there is a reason tools do that. Taking VCS revision name into version consideration basically means having two independent versioning schemes, and all hell breaks loose if they don’t agree with each other. It’s definitely better to go there. This thread is more or less #5780 but for VCS, so maybe #5780 (comment) would apply as well. |
Yep, this is basically #5780. I'm OK with consolidating this into that issue, with a note of "hey, remember about VCS links when tackling this". |
Description
When a VCS (git/SVN) package is specified as an 'install_requires' dependency in
setup.py
, the package is downloaded from the version control, but it is never built or installed. The only way to make it work is right now to issue the--force-reinstall
flag.The root cause is a missing check in the loop at https://github.com/pypa/pip/blob/main/src/pip/_internal/resolution/resolvelib/resolver.py#L139.
Candidates such as VCS packages slip through all the checks and land at https://github.com/pypa/pip/blob/main/src/pip/_internal/resolution/resolvelib/resolver.py#L193.
It also explains why
--force-reinstall
works. The check on line https://github.com/pypa/pip/blob/main/src/pip/_internal/resolution/resolvelib/resolver.py#L150 short-circuits and adds the candidate to the req_set.The fix is to add a simple check on
candidate.source_link and candidate.source_link.is_vcs
condition and to setireq.should_reinstall=True
following that.I suspect this would be broken for all possible mechanisms wherever VCS packages are allowed in requirement spec (requirements.txt, etc.), but I haven't tested those flows.
Expected behavior
Including a VCS package in the dependency list should correctly build and install the dependency much like other regular dependencies.
pip version
Reproduced on pip 21.1.2
Python version
Python 3.9.5
OS
macOS Catalina
How to Reproduce
Output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: