diff --git a/examples/build_file_generation/WORKSPACE b/examples/build_file_generation/WORKSPACE index 8398dfbe75..e283260ea2 100644 --- a/examples/build_file_generation/WORKSPACE +++ b/examples/build_file_generation/WORKSPACE @@ -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. @@ -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", diff --git a/examples/bzlmod/MODULE.bazel b/examples/bzlmod/MODULE.bazel index a2570c4e0f..44d686e3dc 100644 --- a/examples/bzlmod/MODULE.bazel +++ b/examples/bzlmod/MODULE.bazel @@ -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", @@ -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 @@ -111,8 +111,6 @@ pip.parse( }, ) pip.parse( - hub_name = "pip", - python_version = "3.10", experimental_requirement_cycles = { "sphinx": [ "sphinx", @@ -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 diff --git a/examples/pip_parse/WORKSPACE b/examples/pip_parse/WORKSPACE index 2491168ce9..415d064ed6 100644 --- a/examples/pip_parse/WORKSPACE +++ b/examples/pip_parse/WORKSPACE @@ -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"], @@ -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", diff --git a/python/pip_install/pip_repository.bzl b/python/pip_install/pip_repository.bzl index fc215bb521..db50c57167 100644 --- a/python/pip_install/pip_repository.bzl +++ b/python/pip_install/pip_repository.bzl @@ -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 `@//...` -""", - ), "experimental_requirement_cycles": attr.string_list_dict( default = {}, doc = """\ @@ -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 `@//...` """, ), # 600 is documented as default here: https://docs.bazel.build/versions/master/skylark/lib/repository_ctx.html#execute