-
-
Notifications
You must be signed in to change notification settings - Fork 677
Description
🐞 bug report
Affected Rule
vendored pip_parse dependencies
Is this a regression?
Yes, fixed in #608 and linked issues
Description
Clients of a vendored workspace (e.g., pip_parse_vendored) cannot use the 1-step solution documented in the readme and are instead still required to pip_parse their dependency's dependencies.
🔬 Minimal Reproduction
From slack thread (as of 66550eca4ae9d94be3a32da86e60a54cba13cf74):
Create a directory in use_pip_parse_vendored in rules_python/examples
WORKSPACE:
workspace(name = "use_pip_parse_vendored")
local_repository(
name = "rules_python",
path = "../..",
)
local_repository(
name = "pip_parse_vendored",
path = "../pip_parse_vendored",
)
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
py_repositories()
python_register_toolchains(
name = "python39",
python_version = "3.9",
)
load("@pip_parse_vendored//:requirements.bzl", "install_deps")
install_deps()
hello_world.py in same directory (that wants to use one of the pip_parse_vendored requirements):
#!/usr/bin/env python3
import urllib3
if __name__ == "__main__":
print("Hello world")
http = urllib3.PoolManager()
resp = http.request("GET", "https://httpbin.org/robots.txt")
print(resp.data)
BUILD.bazel file that uses the dependency:
load("@rules_python//python:defs.bzl", "py_binary")
load("@pip_parse_vendored//:requirements.bzl", "requirement")
py_binary(
name = "hello_world",
srcs = ["hello_world.py"],
visibility = ["//:__subpackages__"],
deps = [
requirement("urllib3"),
]
)
🔥 Exception or Error
Bazel 7.1.2:
bazel build ...
ERROR: no such package '@@[unknown repo 'pip' requested from @@]//urllib3': The repository '@@[unknown repo 'pip' requested from @@]' could not be resolved: No repository visible as '@pip' from main repository
ERROR: /Users/davinib/code/git/nonvmware/bazel/rules_python/examples/use_pip_parse_vendored/BUILD.bazel:4:10: no such package '@@[unknown repo 'pip' requested from @@]//urllib3': The repository '@@[unknown repo 'pip' requested from @@]' could not be resolved: No repository visible as '@pip' from main repository and referenced by '//:hello_world'
ERROR: Analysis of target '//:hello_world' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.946s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
Bazel 6.4.0:
ERROR: /Users/davinib/code/git/nonvmware/bazel/rules_python/examples/use_pip_parse_vendored/BUILD.bazel:4:10: no such package '@pip//urllib3': The repository '@pip' could not be resolved: Repository '@pip' is not defined and referenced by '//:hello_world'
ERROR: Analysis of target '//:hello_world' failed; build aborted: Analysis failed
🌍 Your Environment
Mac x86 14.4.1 (23E224)
Output of bazel version:
Both 7.1.2 and 6.4.0
Rules_python version:
ToT on 0.32.2 - 66550eca4ae9d94be3a32da86e60a54cba13cf74
Anything else relevant?
From slack thread:
Yeah, it is unfortunate that it is broken right now and the reason is that we are using aliases in the requirements.bzl for accessing the packages.
I think the targets in https://github.com/bazelbuild/rules_python/blob/main/examples/pip_parse_vendored/requirements.bzl#L9 should look like @pip_certify//:pkg instead of @pip//certify:pkg. Feel free to raise an issue in rules_python and a PR to fix this would be really welcome.
In the mean time the vendoring script could use some shell substitution like: sed 's|\(@pip\)//\(.*\):|\1_\2//:|g in order to get it generate the correct requirements.bzl.