8000 `pip_install` fails with empty `requirements.txt` · Issue #36 · bazel-contrib/rules_python · GitHub
[go: up one dir, main page]

Skip to content
pip_install fails with empty requirements.txt #36
Closed
@hwright

Description

@hwright

With an empty requirements.txt file, the generated requirements.bzl looks something like this:

# Install pip requirements.
#
# Generated from /private/var/tmp/_bazel_hwright/a2425324ff1a5e603c63e1b9994a2d28/external/third_party/py/requirements.txt

load("@io_bazel_rules_python//python:whl.bzl", "whl_library")

def pip_install():
  

_requirements = {
  
}

all_requirements = _requirements.values()

def requirement(name):
  name = name.replace("-", "_").lower()
  return _requirements[name]

The lack of any body in the pip_install function yields this kind of error:

$ bazel test ...
..........................................................
ERROR: /private/var/tmp/_bazel_hwright/a2425324ff1a5e603c63e1b9994a2d28/external/pip_deps/requirements.bzl:10:1: expected an indented block.
ERROR: error loading package '': Extension 'requirements.bzl' has errors.
INFO: Elapsed time: 1.741s
ERROR: Couldn't start the build. Unable to run tests.

While an empty requirements.txt is admittedly nonsensical, we should still support this case by inserting a pass statement inside the function body.

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

      0