Skip to content

Commit

Permalink
Added docstrings for pip_lock rule
Browse files Browse the repository at this point in the history
  • Loading branch information
apt-itude committed Jun 11, 2019
1 parent 42b4d17 commit 7e9090a
Showing 1 changed file with 50 additions and 6 deletions.
56 changes: 50 additions & 6 deletions rules/lock.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def _get_path_relative_to_workspace(path, ctx):
else:
return paths.join(ctx.label.package, path)

def _pip_lock(ctx):
def _pip_lock_impl(ctx):
requirements_txt_paths = " ".join([
req_file.path for req_file in ctx.files.requirements
])
Expand Down Expand Up @@ -51,16 +51,60 @@ def _pip_lock(ctx):
)]

pip_lock = rule(
implementation = _pip_lock,
implementation = _pip_lock_impl,
doc = """
Defines a binary target that may be executed via `bazel run` in order to compile
any number of `requirements.txt` files into a single `requirements-lock.json`
file. This binary should be executed on all supported platforms to add the
correct set of requirements to the lock file for each platform.
""",
attrs = {
"requirements": attr.label_list(allow_files = True),
"requirements_lock": attr.string(default = "requirements-lock.json"),
"requirements": attr.label_list(
allow_files = True,
doc = """
Files following the standard requirements file format
(https://pip.pypa.io/en/stable/reference/pip_install/#requirements-file-format)
These should define direct dependencies only, and should not pin
dependency versions unless necessary.
""",
),
"requirements_lock": attr.string(
default = "requirements-lock.json",
doc = """
A path relative to the package in which this rule is defined to which
the compiled lock file should be written. This file should
be source-controlled and provided as input to the `pip_repository` rule.
""",
),
"python_version": attr.string(
values = ["PY2", "PY3", "PY2AND3"],
default = "PY2AND3",
doc = """
The Python versions for which to compile the requirement set. The
requirements lock file will contain one environment per Python version
per platform. Each environment will define its locked requirement set.
""",
),
"wheel_dir": attr.string(
default = "wheels",
doc = """
A path to a directory relative to the package in which this rule is
defined in which built wheels will be stored. If the given directory
does not already exist, it will be created.
Wheels will be built for any required distribution that is not already
available as a wheel for the given environment. These wheels may be
committed to source control or published to a custom Python package
index. If the latter approach is used, this binary should be run again
with the `index_url` attribute set to the URL of that index in order to
resolve the new locations of those wheels.
""",
),
"index_url": attr.string(
default = "https://pypi.org/simple",
doc = "The URL of a custom Python package index to use instead of PyPI.",
),
"wheel_dir": attr.string(default = "wheels"),
"index_url": attr.string(default = "https://pypi.org/simple"),
"_lock_pip_requirements_py2": attr.label(
default = "//src/bin:lock_pip_requirements_py2",
cfg = "target",
Expand Down

0 comments on commit 7e9090a

Please sign in to comment.