aboutsummaryrefslogtreecommitdiff
path: root/docs/python.md
diff options
context:
space:
mode:
authorRichard Levasseur <richardlev@gmail.com>2022-12-01 12:21:24 -0800
committerGitHub <noreply@github.com>2022-12-01 12:21:24 -0800
commitce977e10f8564de6361146ff418a136f86629a86 (patch)
tree7ac669787424035149b04c6642848b9a723c80ce /docs/python.md
parentc572cdc1b983c4879a7066e3e28352374a4b9d18 (diff)
downloadbazelbuild-rules_python-ce977e10f8564de6361146ff418a136f86629a86.tar.gz
Fail if Python 2 values are specified (#887)
Fail for py2 python_version, srcs_version, and runtime values. See https://github.com/bazelbuild/rules_python/issues/886
Diffstat (limited to 'docs/python.md')
-rwxr-xr-xdocs/python.md133
1 files changed, 63 insertions, 70 deletions
diff --git a/docs/python.md b/docs/python.md
index 1726ade..6682e48 100755
--- a/docs/python.md
+++ b/docs/python.md
@@ -55,20 +55,73 @@ This rule allows the use of Python packages as dependencies.
| <a id="py_import-srcs"></a>srcs | The list of Python package files provided to Python targets that depend on this target. Note that currently only the .egg format is accepted. For .whl files, try the whl_library rule. We accept contributions to extend py_import to handle .whl. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | <code>[]</code> |
+<a id="py_binary"></a>
+
+## py_binary
+
+<pre>
+py_binary(<a href="#py_binary-attrs">attrs</a>)
+</pre>
+
+See the Bazel core [py_binary](https://docs.bazel.build/versions/master/be/python.html#py_binary) documentation.
+
+**PARAMETERS**
+
+
+| Name | Description | Default Value |
+| :------------- | :------------- | :------------- |
+| <a id="py_binary-attrs"></a>attrs | Rule attributes | none |
+
+
+<a id="py_library"></a>
+
+## py_library
+
+<pre>
+py_library(<a href="#py_library-attrs">attrs</a>)
+</pre>
+
+See the Bazel core [py_library](https://docs.bazel.build/versions/master/be/python.html#py_library) documentation.
+
+**PARAMETERS**
+
+
+| Name | Description | Default Value |
+| :------------- | :------------- | :------------- |
+| <a id="py_library-attrs"></a>attrs | Rule attributes | none |
+
+
+<a id="py_runtime"></a>
+
+## py_runtime
+
+<pre>
+py_runtime(<a href="#py_runtime-attrs">attrs</a>)
+</pre>
+
+See the Bazel core [py_runtime](https://docs.bazel.build/versions/master/be/python.html#py_runtime) documentation.
+
+**PARAMETERS**
+
+
+| Name | Description | Default Value |
+| :------------- | :------------- | :------------- |
+| <a id="py_runtime-attrs"></a>attrs | Rule attributes | none |
+
+
<a id="py_runtime_pair"></a>
## py_runtime_pair
<pre>
-py_runtime_pair(<a href="#py_runtime_pair-name">name</a>, <a href="#py_runtime_pair-py2_runtime">py2_runtime</a>, <a href="#py_runtime_pair-py3_runtime">py3_runtime</a>)
+py_runtime_pair(<a href="#py_runtime_pair-name">name</a>, <a href="#py_runtime_pair-py2_runtime">py2_runtime</a>, <a href="#py_runtime_pair-py3_runtime">py3_runtime</a>, <a href="#py_runtime_pair-attrs">attrs</a>)
</pre>
A toolchain rule for Python.
-This wraps up to two Python runtimes, one for Python 2 and one for Python 3.
-The rule consuming this toolchain will choose which runtime is appropriate.
-Either runtime may be omitted, in which case the resulting toolchain will be
-unusable for building Python code using that version.
+This used to wrap up to two Python runtimes, one for Python 2 and one for Python 3.
+However, Python 2 is no longer supported, so it now only wraps a single Python 3
+runtime.
Usually the wrapped runtimes are declared using the `py_runtime` rule, but any
rule returning a `PyRuntimeInfo` provider may be used.
@@ -78,7 +131,7 @@ schema:
```python
platform_common.ToolchainInfo(
- py2_runtime = &lt;PyRuntimeInfo or None&gt;,
+ py2_runtime = None,
py3_runtime = &lt;PyRuntimeInfo or None&gt;,
)
```
@@ -91,12 +144,6 @@ Example usage:
load("@rules_python//python:defs.bzl", "py_runtime_pair")
py_runtime(
- name = "my_py2_runtime",
- interpreter_path = "/system/python2",
- python_version = "PY2",
-)
-
-py_runtime(
name = "my_py3_runtime",
interpreter_path = "/system/python3",
python_version = "PY3",
@@ -104,7 +151,6 @@ py_runtime(
py_runtime_pair(
name = "my_py_runtime_pair",
- py2_runtime = ":my_py2_runtime",
py3_runtime = ":my_py3_runtime",
)
@@ -123,68 +169,15 @@ register_toolchains("//my_pkg:my_toolchain")
```
-**ATTRIBUTES**
-
-
-| Name | Description | Type | Mandatory | Default |
-| :------------- | :------------- | :------------- | :------------- | :------------- |
-| <a id="py_runtime_pair-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
-| <a id="py_runtime_pair-py2_runtime"></a>py2_runtime | The runtime to use for Python 2 targets. Must have <code>python_version</code> set to <code>PY2</code>. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
-| <a id="py_runtime_pair-py3_runtime"></a>py3_runtime | The runtime to use for Python 3 targets. Must have <code>python_version</code> set to <code>PY3</code>. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |
-
-
-<a id="py_binary"></a>
-
-## py_binary
-
-<pre>
-py_binary(<a href="#py_binary-attrs">attrs</a>)
-</pre>
-
-See the Bazel core [py_binary](https://docs.bazel.build/versions/master/be/python.html#py_binary) documentation.
-
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
-| <a id="py_binary-attrs"></a>attrs | Rule attributes | none |
-
-
-<a id="py_library"></a>
-
-## py_library
-
-<pre>
-py_library(<a href="#py_library-attrs">attrs</a>)
-</pre>
-
-See the Bazel core [py_library](https://docs.bazel.build/versions/master/be/python.html#py_library) documentation.
-
-**PARAMETERS**
-
-
-| Name | Description | Default Value |
-| :------------- | :------------- | :------------- |
-| <a id="py_library-attrs"></a>attrs | Rule attributes | none |
-
-
-<a id="py_runtime"></a>
-
-## py_runtime
-
-<pre>
-py_runtime(<a href="#py_runtime-attrs">attrs</a>)
-</pre>
-
-See the Bazel core [py_runtime](https://docs.bazel.build/versions/master/be/python.html#py_runtime) documentation.
-
-**PARAMETERS**
-
-
-| Name | Description | Default Value |
-| :------------- | :------------- | :------------- |
-| <a id="py_runtime-attrs"></a>attrs | Rule attributes | none |
+| <a id="py_runtime_pair-name"></a>name | str, the name of the target | none |
+| <a id="py_runtime_pair-py2_runtime"></a>py2_runtime | optional Label; must be unset or None; an error is raised otherwise. | <code>None</code> |
+| <a id="py_runtime_pair-py3_runtime"></a>py3_runtime | Label; a target with <code>PyRuntimeInfo</code> for Python 3. | <code>None</code> |
+| <a id="py_runtime_pair-attrs"></a>attrs | Extra attrs passed onto the native rule | none |
<a id="py_test"></a>