rules_python
rules_python copied to clipboard
compile_pip_requirements does not independently setup its internal pip dependencies (eg. pip-tools)
🐞 bug report
Affected Rule
compile_pip_requirements
Is this a regression?
No
Description
Using compile_pip_requirements without any of the other rules results in an error:
% bazel run requirements.update
...
no such package '@pypi__pip_tools//': The repository '@pypi__pip_tools' could not be resolved and referenced by ...
🔬 Minimal Reproduction
# WORKSPACE
http_archive(
name = "rules_python3",
sha256 = "934c9ceb552e84577b0faf1e5a2f0450314985b4d8712b2b70717dc679fdc01b",
urls = [
"https://github.com/bazelbuild/rules_python/releases/download/0.3.0/rules_python-0.3.0.tar.gz",
],
)
# BUILD
load("@rules_python3//python/pip_install:requirements.bzl", "compile_pip_requirements")
compile_pip_requirements(
name = "requirements",
extra_args = [
"--allow-unsafe",
"--no-emit-index-url",
],
env = {
"PIP_CONFIG_FILE": "~/.pip/pip.conf",
},
)
🔥 Exception or Error
no such package '@pypi__pip_tools//': The repository '@pypi__pip_tools' could not be resolved and referenced by ...
🌍 Your Environment
Operating System:
MacOS 10.15.7
Output of bazel version:
Build label: 4.1.0.188
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Jun 21 23:14:47 2021 (1624317287)
Build timestamp: 1624317287
Build timestamp as int: 1624317287
Rules_python version:
0.3.0
Anything else relevant? Workaround is adding this to WORKSPACE
load("@rules_python3//python/pip_install:repositories.bzl", "pip_install_dependencies")
pip_install_dependencies()
Yes I think because compile_pip_requirements is a macro it can't pull in those deps by itself. We need to document this dependency of the macro, and potentially have the macro do an early check for the required deps and provide a nice error if they're missing.
I'm inclined to agree this is more of a documentation problem than a bug unless you plan to add a repo rule for setting up rules_python dependencies.
I think having to call pip_install_dependencies to install compile_pip_requirements deps is awkward. The names don't match.
What is the solution here?