Skip to content

Latest commit

 

History

History
101 lines (85 loc) · 2.26 KB

pip.md

File metadata and controls

101 lines (85 loc) · 2.26 KB

Import pip requirements into Bazel.

Repository Rules

Macros

## pip_repositories
pip_repositories()

Pull in dependencies needed for pulling in pip dependencies.

A placeholder method that will eventually pull in any dependencies needed to install pip dependencies.

pip_import

pip_import(name, 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,
)

Attributes

name

Name; Required

A unique name for this rule.

requirements

Label; Required

The label of a requirements.txt file.