Skip to content

Conversation

acr92
Copy link
Contributor

@acr92 acr92 commented Dec 30, 2022

This fixes a issue with the repository generation function where it was missing a _clean_pkg_name() for the second reference to the requirement name.

Fixes #952

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #952

requirement("dependency") didn't work if the dependency had any number of hyphens in its name (for example requirement("google-cloud-storage") did not work in a BUILD.bazel file.

The error encountered was, for example:

bazel:106:6: no such package '@[unknown repo 'pip_typing-extensions' requested from 
@rules_python~0.16.1~pip~pip]//': The repository '@[unknown repo 'pip_python-dateutil' requested from 
@rules_python~0.16.1~pip~pip]' could not be resolved: No repository visible 
as '@pip_python-dateutil' from repository '@rules_python~0.16.1~pip~pip' and referenced by 
'@rules_python~0.16.1~pip~pip//:python_dateutil_pkg'

What is the new behavior?

requirement("dependency") now works with hyphens in the name.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This fixes a issue with the repository generation function where it was missing
a _clean_pkg_name() for the second reference to the requirement name.

Fixes bazel-contrib#952
Copy link
Collaborator

@groodt groodt left a comment

Choose a reason for hiding this comment

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

LGTM

For the record, we have discussed simplifying these requirement helpers and converting them into plain macros without a "closure" to the repository. The current implementation causes lots of headaches and causes lots of bugs, as you've discovered.

@groodt groodt merged commit 2c29f40 into bazel-contrib:main Dec 30, 2022
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.

bzlmod: Pip dependencies with hyphen cannot be added as dependency
2 participants