pip_import(name, extra_pip_args, python_interpreter, requirements)
A rule for importing requirements.txt dependencies into Bazel.
This rule imports a requirements.txt file and generates a new
requirements.bzl file. This is used via the WORKSPACE pattern:
pip_import(
name = "foo",
requirements = ":requirements.txt",
)
load("@foo//:requirements.bzl", "pip_install")
pip_install()You can then reference imported dependencies from your BUILD file with:
load("@foo//:requirements.bzl", "requirement")
py_library(
name = "bar",
...
deps = [
"//my/other:dep",
requirement("futures"),
requirement("mock"),
],
)Or alternatively:
load("@foo//:requirements.bzl", "all_requirements")
py_binary(
name = "baz",
...
deps = [
":foo",
] + all_requirements,
)name |
Name; required
A unique name for this repository. |
extra_pip_args |
List of strings; optional
Extra arguments to pass on to pip. Must not contain spaces. |
python_interpreter |
String; optional
The command to run the Python interpreter used to invoke pip and unpack the wheels. |
requirements |
Label; required
The label of the requirements.txt file. |
pip3_import(kwargs)
A wrapper around pip_import that uses the python3 system command.
Use this for requirements of PY3 programs.
kwargs |
optional. |
pip_repositories()
Pull in dependencies needed to use the packaging rules.