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

fix(bzlmod pip.parse): allow requirements with duplicate package lines #1620

Merged
merged 2 commits into from
Dec 19, 2023

Conversation

rickeylev
Copy link
Contributor

Requirements files are permitted to have duplicate lines for the same package. An example
of this is having separate lines for a package and its extras. When we parse requirements,
the parser discards the "extra" portion of the entry and returns a list of all the packages
as-is. When a repository is created for each entry, this means the same name is used for
multiple repositories.

Under WORKSPACE builds, duplicate repository names aren't an error. It appears that last
defined repo takes affect. Under bzlmod, duplicate repo names are an error.

To fix, mimic the last-defined-wins behavior in bzlmod by using a map to dedupe the package names.

Fixes #1615

@rickeylev rickeylev marked this pull request as ready for review December 16, 2023 00:51
Copy link
Collaborator

@aignas aignas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding a test for this!

python/private/bzlmod/pip.bzl Show resolved Hide resolved
@aignas
Copy link
Collaborator

aignas commented Dec 17, 2023

The test failures look like the pre-commit hook may need to be run or something similar?

@AndrewGuenther
Copy link

@rickeylev I patched this to our local environment and can confirm it works!

When a package has extras, the requirements parsing discards the extra
portion of the name and just returns the base name. When a repository
is created for each entry, this means the same name is used for multiple
repositories.

Under WORKSPACE builds, duplicate repository names aren't an error. It
appears the last defined repo takes affect. Under bzlmod, duplicate repo
names are an error.

To fix, mimic the last-defined-wins behavior in bzlmod by using a map to
dedupe the package names.

Fixes bazelbuild#1615
@rickeylev rickeylev added this pull request to the merge queue Dec 18, 2023
Merged via the queue into bazelbuild:main with commit d8f6881 Dec 19, 2023
3 checks passed
@rickeylev rickeylev deleted the dupe.whl.lib.name branch December 19, 2023 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pip.parse does not accept lock files with duplicated dependencies
3 participants