rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

pip_parse generates whl_library without deps

Open alexeagle opened this issue 2 years ago • 1 comments

As observed in https://github.com/Tinder/bazel-diff/issues/134 we currently generate whl_library rules https://github.com/bazelbuild/rules_python/blob/main/python/pip_install/parse_requirements_to_bzl/init.py#L144 which look like

% bazel query --output=build //external:my_deps_testcontainers
# /Users/alex.eagle/repros/pip_bazel-diff/WORKSPACE:31:13
whl_library(
  name = "my_deps_testcontainers",
  generator_name = "my_deps_testcontainers",
  generator_function = "install_deps",
  deps = ["@my_deps_wrapt//:whl"],
  repo = "my_deps",
  requirement = "testcontainers==3.5.4     --hash=sha256:7a5583922cbb3da5ed255975f1927d8b29bf6a638323a85fd41b6e46c48ada8f",
  enable_implicit_namespace_pkgs = False,
  environment = {},
  extra_pip_args = [],
  isolated = True,
  pip_data_exclude = [],
  python_interpreter = "python3",
  python_interpreter_target = "@python3_9_x86_64-apple-darwin//:bin/python3",
  quiet = True,
  repo_prefix = "my_deps_",
  timeout = 600,
)
# Rule my_deps_testcontainers instantiated at (most recent call last):
#   /Users/alex.eagle/repros/pip_bazel-diff/WORKSPACE:31:13                                                     in <toplevel>
#   /private/var/tmp/_bazel_alex.eagle/a060b90d6e0425005f043993b0078cee/external/my_deps/requirements.bzl:45:20 in install_deps
# Rule whl_library defined at (most recent call last):
#   /private/var/tmp/_bazel_alex.eagle/a060b90d6e0425005f043993b0078cee/external/rules_python/python/pip_install/pip_repository.bzl:424:30 in <toplevel>

This works because when that repository rule is executed, it makes a @my_deps_testcontainers//:pkg py_library target with the right deps on transitives like wrapt.

However, based on analysis in that issue, tinder/bazel-diff doesn't look at the result of executing the repository rule, so it misses these dependency edges.

We could generate whl_library targets that point to the whl_library of their dependencies, just as a workaround for that bug.

alexeagle avatar May 19 '22 22:05 alexeagle

This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_python!

github-actions[bot] avatar Nov 16 '22 22:11 github-actions[bot]

This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"

github-actions[bot] avatar Dec 17 '22 22:12 github-actions[bot]