rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

Need to supply transitive dependencies

Open bashtavenko opened this issue 1 year ago β€’ 1 comments

🐞 bug report

Affected Rule

bazel_dep(name = "rules_python", version = "0.32.2")
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
    hub_name = "pip_deps",
    python_version = "3.11",
    requirements_lock = "//:requirements.txt",
)
use_repo(pip, "pip_deps")

Is this a regression?

Not sure

Description

A clear and concise description of the problem...

After bazel buld //... bazel wants to see a transitive dependency. For example, I have "requests" in "requirements.txt" and it wants idna or urllib3 which are transitive dependeancies of the requests.

See full code here https://github.com/bashtavenko/py/tree/pydeps-2

This is the first time I tried using bazel in Python project and it is likely I messed up something.

πŸ”¬ Minimal Reproduction

git clone -b pydeps-2 https://github.com/bashtavenko/py.git
cd py
bazel build //...

πŸ”₯ Exception or Error




Starting local Bazel server and connecting to it...
ERROR: no such package '@@rules_python~~pip~pip_deps//idna': BUILD file not found in directory 'idna' of external repository @@rules_python~~pip~pip_deps. Add a BUILD file to a directory to mark it as a package.
ERROR: C:/users/sb/_bazel_sb/enxgtwle/external/rules_python~~pip~pip_deps_311_requests/BUILD.bazel:28:11: no such package '@@rules_python~~pip~pip_deps//idna': BUILD file not found in directory 'idna' of external repository @@rules_python~~pip~pip_deps. Add a BUILD file to a directory to mark it as a package. and referenced by '@@rules_python~~pip~pip_deps_311_requests//:pkg'
Target //:graph_lib up-to-date (nothing to build)
ERROR: Analysis of target '//:graph_test' failed; build aborted: Analysis failed
INFO: Elapsed time: 76.797s, Critical Path: 0.13s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully

🌍 Your Environment

Operating System:

  
Microsoft Windows 10 Pro
  

Output of bazel version:

  
bazel 7.1.2
  

Rules_python version:

  
0.32.2
  

Anything else relevant? This is most likely not a bug but rather a configuration that I missed.

bashtavenko avatar May 24 '24 17:05 bashtavenko

It seems that the requirement to provide the transitive dependencies has not been documented and the compile_pip_requirements is only mentioned in our docs in the API description page here though we have all of the examples using it, it seems that it is not enough and we should increase the visibility. Leaving this ticket open until we have better user docs.

aignas avatar May 27 '24 02:05 aignas