|
| 1 | +<!-- Generated with Stardoc: http://skydoc.bazel.build --> |
| 2 | + |
| 3 | +<a name="#pip_repository"></a> |
| 4 | + |
| 5 | +## pip_repository |
| 6 | + |
| 7 | +<pre> |
| 8 | +pip_repository(<a href="#pip_repository-name">name</a>, <a href="#pip_repository-annotations">annotations</a>, <a href="#pip_repository-enable_implicit_namespace_pkgs">enable_implicit_namespace_pkgs</a>, <a href="#pip_repository-environment">environment</a>, <a href="#pip_repository-extra_pip_args">extra_pip_args</a>, |
| 9 | + <a href="#pip_repository-incremental">incremental</a>, <a href="#pip_repository-isolated">isolated</a>, <a href="#pip_repository-pip_data_exclude">pip_data_exclude</a>, <a href="#pip_repository-python_interpreter">python_interpreter</a>, <a href="#pip_repository-python_interpreter_target">python_interpreter_target</a>, |
| 10 | + <a href="#pip_repository-quiet">quiet</a>, <a href="#pip_repository-repo_prefix">repo_prefix</a>, <a href="#pip_repository-requirements">requirements</a>, <a href="#pip_repository-requirements_darwin">requirements_darwin</a>, <a href="#pip_repository-requirements_linux">requirements_linux</a>, |
| 11 | + <a href="#pip_repository-requirements_lock">requirements_lock</a>, <a href="#pip_repository-requirements_windows">requirements_windows</a>, <a href="#pip_repository-timeout">timeout</a>) |
| 12 | +</pre> |
| 13 | + |
| 14 | +A rule for importing `requirements.txt` dependencies into Bazel. |
| 15 | + |
| 16 | +This rule imports a `requirements.txt` file and generates a new |
| 17 | +`requirements.bzl` file. This is used via the `WORKSPACE` pattern: |
| 18 | + |
| 19 | +```python |
| 20 | +pip_repository( |
| 21 | + name = "foo", |
| 22 | + requirements = ":requirements.txt", |
| 23 | +) |
| 24 | +``` |
| 25 | + |
| 26 | +You can then reference imported dependencies from your `BUILD` file with: |
| 27 | + |
| 28 | +```python |
| 29 | +load("@foo//:requirements.bzl", "requirement") |
| 30 | +py_library( |
| 31 | + name = "bar", |
| 32 | + ... |
| 33 | + deps = [ |
| 34 | + "//my/other:dep", |
| 35 | + requirement("requests"), |
| 36 | + requirement("numpy"), |
| 37 | + ], |
| 38 | +) |
| 39 | +``` |
| 40 | + |
| 41 | +Or alternatively: |
| 42 | +```python |
| 43 | +load("@foo//:requirements.bzl", "all_requirements") |
| 44 | +py_binary( |
| 45 | + name = "baz", |
| 46 | + ... |
| 47 | + deps = [ |
| 48 | + ":foo", |
| 49 | + ] + all_requirements, |
| 50 | +) |
| 51 | +``` |
| 52 | + |
| 53 | + |
| 54 | +**ATTRIBUTES** |
| 55 | + |
| 56 | + |
| 57 | +| Name | Description | Type | Mandatory | Default | |
| 58 | +| :-------------: | :-------------: | :-------------: | :-------------: | :-------------: | |
| 59 | +| name | A unique name for this repository. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | | |
| 60 | +| annotations | Optional annotations to apply to packages | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} | |
| 61 | +| enable_implicit_namespace_pkgs | If true, disables conversion of native namespace packages into pkg-util style namespace packages. When set all py_binary and py_test targets must specify either <code>legacy_create_init=False</code> or the global Bazel option <code>--incompatible_default_to_explicit_init_py</code> to prevent <code>__init__.py</code> being automatically generated in every directory.<br><br>This option is required to support some packages which cannot handle the conversion to pkg-util style. | Boolean | optional | False | |
| 62 | +| environment | Environment variables to set in the pip subprocess. Can be used to set common variables such as <code>http_proxy</code>, <code>https_proxy</code> and <code>no_proxy</code> Note that pip is run with "--isolated" on the CLI so PIP_<VAR>_<NAME> style env vars are ignored, but env vars that control requests and urllib3 can be passed. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} | |
| 63 | +| extra_pip_args | Extra arguments to pass on to pip. Must not contain spaces. | List of strings | optional | [] | |
| 64 | +| incremental | Create the repository in incremental mode. | Boolean | optional | False | |
| 65 | +| isolated | 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 <code>RULES_PYTHON_PIP_ISOLATED</code> enviornment varaible can be used to control this flag. | Boolean | optional | True | |
| 66 | +| pip_data_exclude | Additional data exclusion parameters to add to the pip packages BUILD file. | List of strings | optional | [] | |
| 67 | +| python_interpreter | The python interpreter to use. This can either be an absolute path or the name of a binary found on the host's <code>PATH</code> environment variable. If no value is set <code>python3</code> is defaulted for Unix systems and <code>python.exe</code> for Windows. | String | optional | "" | |
| 68 | +| python_interpreter_target | 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. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | |
| 69 | +| quiet | If True, suppress printing stdout and stderr output to the terminal. | Boolean | optional | True | |
| 70 | +| repo_prefix | Prefix for the generated packages. For non-incremental mode the packages will be of the form<br><br>@<name>//<prefix><sanitized-package-name>/...<br><br>For incremental mode the packages will be of the form<br><br>@<prefix><sanitized-package-name>//... | String | optional | "" | |
| 71 | +| requirements | A 'requirements.txt' pip requirements file. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | |
| 72 | +| requirements_darwin | Override the requirements_lock attribute when the host platform is Mac OS | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | |
| 73 | +| requirements_linux | Override the requirements_lock attribute when the host platform is Linux | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | |
| 74 | +| requirements_lock | A fully resolved 'requirements.txt' pip requirement file containing the transitive set of your dependencies. If this file is passed instead of 'requirements' no resolve will take place and pip_repository will create individual repositories for each of your dependencies so that wheels are fetched/built only for the targets specified by 'build/run/test'. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | |
| 75 | +| requirements_windows | Override the requirements_lock attribute when the host platform is Windows | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | |
| 76 | +| timeout | Timeout (in seconds) on the rule's execution duration. | Integer | optional | 600 | |
| 77 | + |
| 78 | + |
| 79 | +<a name="#whl_library"></a> |
| 80 | + |
| 81 | +## whl_library |
| 82 | + |
| 83 | +<pre> |
| 84 | +whl_library(<a href="#whl_library-name">name</a>, <a href="#whl_library-annotation">annotation</a>, <a href="#whl_library-enable_implicit_namespace_pkgs">enable_implicit_namespace_pkgs</a>, <a href="#whl_library-environment">environment</a>, <a href="#whl_library-extra_pip_args">extra_pip_args</a>, <a href="#whl_library-isolated">isolated</a>, |
| 85 | + <a href="#whl_library-pip_data_exclude">pip_data_exclude</a>, <a href="#whl_library-python_interpreter">python_interpreter</a>, <a href="#whl_library-python_interpreter_target">python_interpreter_target</a>, <a href="#whl_library-quiet">quiet</a>, <a href="#whl_library-repo">repo</a>, <a href="#whl_library-repo_prefix">repo_prefix</a>, |
| 86 | + <a href="#whl_library-requirement">requirement</a>, <a href="#whl_library-timeout">timeout</a>) |
| 87 | +</pre> |
| 88 | + |
| 89 | + |
| 90 | +Download and extracts a single wheel based into a bazel repo based on the requirement string passed in. |
| 91 | +Instantiated from pip_repository and inherits config options from there. |
| 92 | + |
| 93 | +**ATTRIBUTES** |
| 94 | + |
| 95 | + |
| 96 | +| Name | Description | Type | Mandatory | Default | |
| 97 | +| :-------------: | :-------------: | :-------------: | :-------------: | :-------------: | |
| 98 | +| name | A unique name for this repository. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | | |
| 99 | +| annotation | Optional json encoded file containing annotation to apply to the extracted wheel. See <code>package_annotation</code> | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | |
| 100 | +| enable_implicit_namespace_pkgs | If true, disables conversion of native namespace packages into pkg-util style namespace packages. When set all py_binary and py_test targets must specify either <code>legacy_create_init=False</code> or the global Bazel option <code>--incompatible_default_to_explicit_init_py</code> to prevent <code>__init__.py</code> being automatically generated in every directory.<br><br>This option is required to support some packages which cannot handle the conversion to pkg-util style. | Boolean | optional | False | |
| 101 | +| environment | Environment variables to set in the pip subprocess. Can be used to set common variables such as <code>http_proxy</code>, <code>https_proxy</code> and <code>no_proxy</code> Note that pip is run with "--isolated" on the CLI so PIP_<VAR>_<NAME> style env vars are ignored, but env vars that control requests and urllib3 can be passed. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} | |
| 102 | +| extra_pip_args | Extra arguments to pass on to pip. Must not contain spaces. | List of strings | optional | [] | |
| 103 | +| isolated | 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 <code>RULES_PYTHON_PIP_ISOLATED</code> enviornment varaible can be used to control this flag. | Boolean | optional | True | |
| 104 | +| pip_data_exclude | Additional data exclusion parameters to add to the pip packages BUILD file. | List of strings | optional | [] | |
| 105 | +| python_interpreter | The python interpreter to use. This can either be an absolute path or the name of a binary found on the host's <code>PATH</code> environment variable. If no value is set <code>python3</code> is defaulted for Unix systems and <code>python.exe</code> for Windows. | String | optional | "" | |
| 106 | +| python_interpreter_target | 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. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | |
| 107 | +| quiet | If True, suppress printing stdout and stderr output to the terminal. | Boolean | optional | True | |
| 108 | +| repo | Pointer to parent repo name. Used to make these rules rerun if the parent repo changes. | String | required | | |
| 109 | +| repo_prefix | Prefix for the generated packages. For non-incremental mode the packages will be of the form<br><br>@<name>//<prefix><sanitized-package-name>/...<br><br>For incremental mode the packages will be of the form<br><br>@<prefix><sanitized-package-name>//... | String | optional | "" | |
| 110 | +| requirement | Python requirement string describing the package to make available | String | required | | |
| 111 | +| timeout | Timeout (in seconds) on the rule's execution duration. | Integer | optional | 600 | |
| 112 | + |
| 113 | + |
| 114 | +<a name="#package_annotation"></a> |
| 115 | + |
| 116 | +## package_annotation |
| 117 | + |
| 118 | +<pre> |
| 119 | +package_annotation(<a href="#package_annotation-additive_build_content">additive_build_content</a>, <a href="#package_annotation-copy_files">copy_files</a>, <a href="#package_annotation-copy_executables">copy_executables</a>, <a href="#package_annotation-data">data</a>, <a href="#package_annotation-data_exclude_glob">data_exclude_glob</a>, |
| 120 | + <a href="#package_annotation-srcs_exclude_glob">srcs_exclude_glob</a>) |
| 121 | +</pre> |
| 122 | + |
| 123 | +Annotations to apply to the BUILD file content from package generated from a `pip_repository` rule. |
| 124 | + |
| 125 | +[cf]: https://github.com/bazelbuild/bazel-skylib/blob/main/docs/copy_file_doc.md |
| 126 | + |
| 127 | + |
| 128 | +**PARAMETERS** |
| 129 | + |
| 130 | + |
| 131 | +| Name | Description | Default Value | |
| 132 | +| :-------------: | :-------------: | :-------------: | |
| 133 | +| additive_build_content | Raw text to add to the generated <code>BUILD</code> file of a package. | <code>None</code> | |
| 134 | +| copy_files | A mapping of <code>src</code> and <code>out</code> files for [@bazel_skylib//rules:copy_file.bzl][cf] | <code>{}</code> | |
| 135 | +| copy_executables | A mapping of <code>src</code> and <code>out</code> files for [@bazel_skylib//rules:copy_file.bzl][cf]. Targets generated here will also be flagged as executable. | <code>{}</code> | |
| 136 | +| data | A list of labels to add as <code>data</code> dependencies to the generated <code>py_library</code> target. | <code>[]</code> | |
| 137 | +| data_exclude_glob | A list of exclude glob patterns to add as <code>data</code> to the generated <code>py_library</code> target. | <code>[]</code> | |
| 138 | +| srcs_exclude_glob | A list of labels to add as <code>srcs</code> to the generated <code>py_library</code> target. | <code>[]</code> | |
| 139 | + |
| 140 | + |
0 commit comments