Skip to content

Commit ceb2c35

Browse files
alexeaglef0rmiga
andauthored
Minor code review suggestions (#642)
* Minor code review suggestions * Apply suggestions from code review Co-authored-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com>
1 parent 13ab11e commit ceb2c35

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,14 @@ http_archive(
5454
)
5555
```
5656

57-
To register a hermetic Python toolchain (please refer to
58-
[this link](https://python-build-standalone.readthedocs.io/en/latest/quirks.html) for the list of
59-
quirks you may find while using the toolchain), you can add to the `WORKSPACE` file:
57+
To register a hermetic Python toolchain rather than rely on whatever is already on the machine, you can add to the `WORKSPACE` file:
6058

6159
```python
6260
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
6361

64-
# Multiple versions are available in the @rules_python//python:versions.bzl file.
6562
python_register_toolchains(
6663
name = "python310",
64+
# Available versions are listed in @rules_python//python:versions.bzl.
6765
python_version = "3.10",
6866
)
6967

@@ -78,6 +76,9 @@ pip_parse(
7876
)
7977
```
8078

79+
> You may find some quirks while using this toolchain.
80+
> Please refer to [this link](https://python-build-standalone.readthedocs.io/en/latest/quirks.html) for details.
81+
8182
Once you've imported the rule set into your `WORKSPACE` using any of these
8283
methods, you can then load the core rules in your `BUILD` files with:
8384

@@ -133,8 +134,8 @@ one another, and may result in downloading the same wheels multiple times.
133134

134135
As with any repository rule, if you would like to ensure that `pip_install` is
135136
re-executed in order to pick up a non-hermetic change to your environment (e.g.,
136-
updating your system `python` interpreter), you can completely flush out your
137-
repo cache with `bazel clean --expunge`.
137+
updating your system `python` interpreter), you can force it to re-execute by running
138+
`bazel sync --only [pip_install name]`.
138139

139140
### Fetch `pip` dependencies lazily
140141

WORKSPACE

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ load("//python:versions.bzl", "MINOR_MAPPING")
3030

3131
python_register_toolchains(
3232
name = "python",
33+
# We always use the latest Python internally.
3334
python_version = MINOR_MAPPING.values()[-1],
3435
)
3536

python/private/toolchains_repo.bzl

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ def _toolchains_repo_impl(rctx):
4444

4545
for [platform, meta] in PLATFORMS.items():
4646
build_content += """\
47+
# Bazel selects this toolchain to get a Python interpreter
48+
# for executing build actions.
4749
toolchain(
4850
name = "{platform}_toolchain",
4951
exec_compatible_with = {compatible_with},
50-
target_compatible_with = {compatible_with},
5152
toolchain = "@{user_repository_name}_{platform}//:python_runtimes",
5253
toolchain_type = "@bazel_tools//tools/python:toolchain_type",
5354
)

python/versions.bzl

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""The Python versions we use for the toolchains.
1616
"""
1717

18+
# Values returned by https://bazel.build/rules/lib/repository_os.
1819
MACOS_NAME = "mac os"
1920
LINUX_NAME = "linux"
2021
WINDOWS_NAME = "windows"

0 commit comments

Comments
 (0)