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

allow duplicates of the same version of the same package #1552

Closed
raylu opened this issue Feb 16, 2024 · 5 comments · Fixed by #1558
Closed

allow duplicates of the same version of the same package #1552

raylu opened this issue Feb 16, 2024 · 5 comments · Fixed by #1558
Assignees
Labels
compatibility Compatibility with a specification or another tool

Comments

@raylu
Copy link

raylu commented Feb 16, 2024

we have multiple requirements.txt files with the same package at the same version (thanks to pip-sync -c requirements1.txt requirements2.in)

$ uv pip sync <(echo packaging==23.1) <(echo packaging==23.1)
error: Failed to determine installation plan
  Caused by: Detected duplicate package in requirements: packaging

I think the check here is too strict

// If we see the same requirement twice, then we have a conflict.
if !seen.insert(requirement.name.clone()) {
bail!(
"Detected duplicate package in requirements: {}",
requirement.name
);

@ericbn
Copy link

ericbn commented Feb 17, 2024

pip-tools works as expected:

$ pip-sync <(echo packaging==23.1) <(echo packaging==23.1)
...
Installing collected packages: packaging
Successfully installed packaging-23.1

pip-tools will only fail if there are incompatible requirements found:

$ pip-sync <(echo packaging==23.1) <(echo packaging==23.2)
Incompatible requirements found: packaging==23.2 (from -r /dev/fd/12 (line 1)) and packaging==23.1 (from -r /dev/fd/11 (line 1))

I'd like to see both behaviors in uv too.

@charliermarsh charliermarsh added the compatibility Compatibility with a specification or another tool label Feb 17, 2024
@charliermarsh
Copy link
Member

I think this makes sense, though I'm not sure what should happen if the requirements overlap? E.g., packaging==23.2 and packaging<=24 or something.

@charliermarsh charliermarsh self-assigned this Feb 17, 2024
@ericbn
Copy link

ericbn commented Feb 17, 2024

pip-sync seems to work only when the duplicated requirements are exactly the same, otherwise it will fail with Incompatible requirements found. I guess it makes sense because it expects pinned versions generated by pip-compile (like ==23.2), not ranges like <=24 or anything else.

$ pip-sync <(echo 'packaging==23.2') <(echo 'packaging<=24')
Incompatible requirements found: packaging<=24 (from -r /dev/fd/12 (line 1)) and packaging==23.2 (from -r /dev/fd/11 (line 1))

@ericbn
Copy link

ericbn commented Feb 17, 2024

See jazzband/pip-tools#786

@charliermarsh
Copy link
Member

Fixed in #1558.

charliermarsh added a commit that referenced this issue Feb 17, 2024
## Summary

It turns out that it's not uncommon to end up with repeated packages in
requirements files when running `pip-sync`, e.g., you might have
`anyio==4.0.0` specified multiple times. This PR relaxes our assertions
in the install plan to allow such repeated packages, as long as the
requirement markers are exactly the same (i.e., they are truly
duplicates).

Closes #1552.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Compatibility with a specification or another tool
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants