Skip to content

Regression in generate whl BUILD in 1.4.0-rc0 and later #2835

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

Closed
emirisman opened this issue Apr 28, 2025 · 2 comments
Closed

Regression in generate whl BUILD in 1.4.0-rc0 and later #2835

emirisman opened this issue Apr 28, 2025 · 2 comments
Labels
type: pip pip/pypi integration

Comments

@emirisman
Copy link

🐞 bug report

Affected Rule

generate_whl_library_build_bazel

Is this a regression?

Yes, the exact same configuration works in rules_python 1.3.0.

Description

The whl library BUILD generation has broken templating in rules_python 1.4.0-rc0 and later, leading to templating such as:

external/pip/aiocsv/BUILD.bazel:5:12: error loading package '@@pip_aiocsv//': Unable to find package for @@pip_//:config.bzl: The repository '@@pip_' could not be resolved: Repository '@@pip_' is not defined. and referenced by '@@pip//aiocsv:whl'

Resulting BUILD file:

load("@rules_python//python/private/pypi:whl_library_targets.bzl", "whl_library_targets_from_requires")
load("@pip_//:config.bzl", "target_platforms")
...

notice the templating error at second load

🔬 Minimal Reproduction

Bazel 7.6.1, bzlmod enabled, but rules_python still used via WORKSPACE.

🔥 Exception or Error


external/pip/aiocsv/BUILD.bazel:5:12: error loading package '@@pip_aiocsv//': Unable to find package for @@pip_//:config.bzl: The repository '@@pip_' could not be resolved: Repository '@@pip_' is not defined. and referenced by '@@pip//aiocsv:whl'

🌍 Your Environment

Operating System:

  
observed both on macOS and Linux
  

Output of bazel version:

  
Bazelisk version: 1.26.0
Build label: 7.6.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Mar 31 17:11:07 2025 (1743441067)
Build timestamp: 1743441067
Build timestamp as int: 1743441067
  

Rules_python version:

  
1.4.0-rc0 and later
  

Anything else relevant?

Looks like this was introduced in #2781

loads = [
"""load("@rules_python//python/private/pypi:whl_library_targets.bzl", "whl_library_targets_from_requires")""",
]
if not kwargs.setdefault("target_platforms", None):
dep_template = kwargs["dep_template"]
loads.append(
"load(\"{}\", \"{}\")".format(
dep_template.format(name = "", target = "config.bzl"),
"target_platforms",
),
)

@aignas
Copy link
Collaborator

aignas commented Apr 28, 2025

Could you please check if #2834 is fixing your issue?

@emirisman
Copy link
Author

Could you please check if #2834 is fixing your issue?

Your PR seems to resolve the issue. Thanks for the quick reply!

@aignas aignas closed this as completed Apr 29, 2025
@aignas aignas added the type: pip pip/pypi integration label Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: pip pip/pypi integration
Projects
None yet
Development

No branches or pull requests

2 participants