Skip to content

Commit

Permalink
Buildifier
Browse files Browse the repository at this point in the history
  • Loading branch information
arrdem committed Nov 23, 2023
1 parent 0ae5942 commit 4db046a
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 66 deletions.
16 changes: 8 additions & 8 deletions examples/build_file_generation/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ load("@rules_python//python:pip.bzl", "pip_parse")
# You can instead check this `requirements.bzl` file into your repo.
pip_parse(
name = "pip",
# (Optional) You can provide a python_interpreter (path) or a python_interpreter_target (a Bazel target, that
# acts as an executable). The latter can be anything that could be used as Python interpreter. E.g.:
# 1. Python interpreter that you compile in the build file.
# 2. Pre-compiled python interpreter included with http_archive.
# 3. Wrapper script, like in the autodetecting python toolchain.
#
# Here, we use the interpreter constant that resolves to the host interpreter from the default Python toolchain.
python_interpreter_target = interpreter,

# Requirement groups allow Bazel to tolerate PyPi cycles by putting dependencies
# which are known to form cycles into groups together.
Expand All @@ -115,6 +107,14 @@ pip_parse(
"sphinxcontrib-serializinghtml",
],
},
# (Optional) You can provide a python_interpreter (path) or a python_interpreter_target (a Bazel target, that
# acts as an executable). The latter can be anything that could be used as Python interpreter. E.g.:
# 1. Python interpreter that you compile in the build file.
# 2. Pre-compiled python interpreter included with http_archive.
# 3. Wrapper script, like in the autodetecting python toolchain.
#
# Here, we use the interpreter constant that resolves to the host interpreter from the default Python toolchain.
python_interpreter_target = interpreter,
# Set the location of the lock file.
requirements_lock = "//:requirements_lock.txt",
requirements_windows = "//:requirements_windows.txt",
Expand Down
8 changes: 4 additions & 4 deletions examples/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ use_repo(pip, "whl_mods_hub")
# Alternatively, `python_interpreter_target` can be used to directly specify
# the Python interpreter to run to resolve dependencies.
pip.parse(
hub_name = "pip",
python_version = "3.9",
experimental_requirement_cycles = {
"sphinx": [
"sphinx",
Expand All @@ -100,6 +98,8 @@ pip.parse(
"sphinxcontrib-serializinghtml",
],
},
hub_name = "pip",
python_version = "3.9",
requirements_lock = "//:requirements_lock_3_9.txt",
requirements_windows = "//:requirements_windows_3_9.txt",
# These modifications were created above and we
Expand All @@ -111,8 +111,6 @@ pip.parse(
},
)
pip.parse(
hub_name = "pip",
python_version = "3.10",
experimental_requirement_cycles = {
"sphinx": [
"sphinx",
Expand All @@ -123,6 +121,8 @@ pip.parse(
"sphinxcontrib-serializinghtml",
],
},
hub_name = "pip",
python_version = "3.10",
requirements_lock = "//:requirements_lock_3_10.txt",
requirements_windows = "//:requirements_windows_3_10.txt",
# These modifications were created above and we
Expand Down
26 changes: 13 additions & 13 deletions examples/pip_parse/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ pip_parse(
# can be passed
# environment = {"HTTPS_PROXY": "http://my.proxy.fun/"},
name = "pypi",

# Requirement groups allow Bazel to tolerate PyPi cycles by putting dependencies
# which are known to form cycles into groups together.
experimental_requirement_cycles = {
"sphinx": [
"sphinx",
"sphinxcontrib-qthelp",
"sphinxcontrib-htmlhelp",
"sphinxcontrib-devhelp",
"sphinxcontrib-applehelp",
"sphinxcontrib-serializinghtml",
],
},
# (Optional) You can provide extra parameters to pip.
# Here, make pip output verbose (this is usable with `quiet = False`).
# extra_pip_args = ["-v"],
Expand All @@ -41,19 +54,6 @@ pip_parse(
# Here, we use the interpreter constant that resolves to the host interpreter from the default Python toolchain.
python_interpreter_target = interpreter,

# Requirement groups allow Bazel to tolerate PyPi cycles by putting dependencies
# which are known to form cycles into groups together.
experimental_requirement_cycles = {
"sphinx": [
"sphinx",
"sphinxcontrib-qthelp",
"sphinxcontrib-htmlhelp",
"sphinxcontrib-devhelp",
"sphinxcontrib-applehelp",
"sphinxcontrib-serializinghtml",
],
},

# (Optional) You can set quiet to False if you want to see pip output.
#quiet = False,
requirements_lock = "//:requirements_lock.txt",
Expand Down
82 changes: 41 additions & 41 deletions python/pip_install/pip_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -418,47 +418,6 @@ can be passed.
""",
default = {},
),
"extra_pip_args": attr.string_list(
doc = "Extra arguments to pass on to pip. Must not contain spaces.",
),
"isolated": attr.bool(
doc = """\
Whether or not to pass the [--isolated](https://pip.pypa.io/en/stable/cli/pip/#cmdoption-isolated) flag to
the underlying pip command. Alternatively, the `RULES_PYTHON_PIP_ISOLATED` environment variable can be used
to control this flag.
""",
default = True,
),
"pip_data_exclude": attr.string_list(
doc = "Additional data exclusion parameters to add to the pip packages BUILD file.",
),
"python_interpreter": attr.string(
doc = """\
The python interpreter to use. This can either be an absolute path or the name
of a binary found on the host's `PATH` environment variable. If no value is set
`python3` is defaulted for Unix systems and `python.exe` for Windows.
""",
# NOTE: This attribute should not have a default. See `_get_python_interpreter_attr`
# default = "python3"
),
"python_interpreter_target": attr.label(
allow_single_file = True,
doc = """
If you are using a custom python interpreter built by another repository rule,
use this attribute to specify its BUILD target. This allows pip_repository to invoke
pip using the same interpreter as your toolchain. If set, takes precedence over
python_interpreter. An example value: "@python3_x86_64-unknown-linux-gnu//:python".
""",
),
"quiet": attr.bool(
default = True,
doc = "If True, suppress printing stdout and stderr output to the terminal.",
),
"repo_prefix": attr.string(
doc = """
Prefix for the generated packages will be of the form `@<prefix><sanitized-package-name>//...`
""",
),
"experimental_requirement_cycles": attr.string_list_dict(
default = {},
doc = """\
Expand Down Expand Up @@ -513,6 +472,47 @@ Warning:
If a dependency participates in multiple cycles, all of those cycles must be
collapsed down to one. For instance `a <-> b` and `a <-> c` cannot be listed
as two separate cycles.
""",
),
"extra_pip_args": attr.string_list(
doc = "Extra arguments to pass on to pip. Must not contain spaces.",
),
"isolated": attr.bool(
doc = """\
Whether or not to pass the [--isolated](https://pip.pypa.io/en/stable/cli/pip/#cmdoption-isolated) flag to
the underlying pip command. Alternatively, the `RULES_PYTHON_PIP_ISOLATED` environment variable can be used
to control this flag.
""",
default = True,
),
"pip_data_exclude": attr.string_list(
doc = "Additional data exclusion parameters to add to the pip packages BUILD file.",
),
"python_interpreter": attr.string(
doc = """\
The python interpreter to use. This can either be an absolute path or the name
of a binary found on the host's `PATH` environment variable. If no value is set
`python3` is defaulted for Unix systems and `python.exe` for Windows.
""",
# NOTE: This attribute should not have a default. See `_get_python_interpreter_attr`
# default = "python3"
),
"python_interpreter_target": attr.label(
allow_single_file = True,
doc = """
If you are using a custom python interpreter built by another repository rule,
use this attribute to specify its BUILD target. This allows pip_repository to invoke
pip using the same interpreter as your toolchain. If set, takes precedence over
python_interpreter. An example value: "@python3_x86_64-unknown-linux-gnu//:python".
""",
),
"quiet": attr.bool(
default = True,
doc = "If True, suppress printing stdout and stderr output to the terminal.",
),
"repo_prefix": attr.string(
doc = """
Prefix for the generated packages will be of the form `@<prefix><sanitized-package-name>//...`
""",
),
# 600 is documented as default here: https://docs.bazel.build/versions/master/skylark/lib/repository_ctx.html#execute
Expand Down

0 comments on commit 4db046a

Please sign in to comment.