Skip to content

Fetching dependencies lazily is incompatible to '--incompatible_disallow_empty_glob' #476

@martis42

Description

@martis42

🐞 bug report

Affected Rule

The bug is loacted here:
https://github.com/bazelbuild/rules_python/blob/master/python/pip_install/extract_wheels/lib/bazel.py#L42

Is this a regression?

No

Description

Given one uses --incompatible_disallow_empty_glob, lazily fetching Python dependencies via pip_parse(...) and install_deps(...) fails for dependecies which are not available as .whl but are stored on pypi as .tar.gz. An example for such a package is yattag: https://pypi.org/project/yattag/#files

🔬 Minimal Reproduction

Example project

WORKSPACE

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python",
    sha256 = "778197e26c5fbeb07ac2a2c5ae405b30f6cb7ad1f5510ea6fdac03bded96cc6f",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.2.0/rules_python-0.2.0.tar.gz",
)
load("@rules_python//python:pip.bzl", "pip_parse")
pip_parse(
    name = "my_deps",
    requirements_lock = "//:requirements.txt",
)
load("@my_deps//:requirements.bzl", "install_deps")
install_deps()

BUILD

load("@rules_python//python:defs.bzl", "py_binary")
load("@my_deps//:requirements.bzl", "requirement")

py_binary(
    name = "foo",
    srcs = ["foo.py"],
    deps = [requirement("yattag")],
)

requirements.txt

yattag==1.14.0

empty foo.py

Command

bazel run --incompatible_disallow_empty_glob //:foo

🔥 Exception or Error


ERROR: Traceback (most recent call last):
	File "/home/user/.cache/bazel/_bazel_user/a991fbd6be2c759aa7941b1f92e83708/external/my_deps_pypi__yattag/BUILD.bazel", line 7, column 14, in 
		srcs=glob(["*.whl"]),
Error in glob: glob pattern '*.whl' didn't match anything, but allow_empty is set to False (the default value of allow_empty can be set with --incompatible_disallow_empty_glob)

🌍 Your Environment

Operating System:

  
Ubuntu 20.04
  

Output of bazel version:

  
4.1.0
  

Rules_python version:

  
0.2.0
  

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions