Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bzlmod): Allowing multiple python.toolchain extension calls #1230

Merged
merged 1 commit into from
May 26, 2023

Conversation

chrislovecnm
Copy link
Collaborator

@chrislovecnm chrislovecnm commented May 17, 2023

We do this work for two reasons.

First, we must support Module dependencies and sub-modules using python.toolchain. There are already two known instances of sub-modules setting up a Python toolchain and colliding with another module (nanobind and rules_testing both run into this).

Second, the upcoming multi-version support is going to work by having each python.toolchain() call register its particular version with the extra toolchain constraint. This also helps unify the version-aware and non-version-aware code paths (the non-version aware paths are just version-aware with a single version registered as the default)

This commit implements various business logic in the toolchain class.

Toolchains in Sub Modules

It will create a toolchain in a sub-module if the toolchain
of the same name does not exist in the root module. The extension stops name
clashing between toolchains in the root module and sub-modules.
You cannot configure more than one toolchain as the default toolchain.

Toolchain set as the default version.

This extension will not create a toolchain in a sub-module
if the sub-module toolchain is marked as the default version. If you have
more than one toolchain in your root module, you need to set one of the
toolchains as the default version. If there is only one toolchain, it
is set as the default toolchain.

See #1229 for more information

@chrislovecnm chrislovecnm force-pushed the multiple-toolchains branch 2 times, most recently from fa0dc38 to 357e383 Compare May 17, 2023 00:45
@chrislovecnm chrislovecnm marked this pull request as draft May 17, 2023 00:54
@chrislovecnm chrislovecnm force-pushed the multiple-toolchains branch 2 times, most recently from 843e922 to 174e744 Compare May 17, 2023 01:18
@chrislovecnm chrislovecnm added the type: bzlmod bzlmod work label May 17, 2023
@chrislovecnm chrislovecnm force-pushed the multiple-toolchains branch 2 times, most recently from e574ad5 to e516a59 Compare May 17, 2023 23:51
@chrislovecnm chrislovecnm marked this pull request as ready for review May 18, 2023 14:39
@chrislovecnm chrislovecnm force-pushed the multiple-toolchains branch 3 times, most recently from 19fe4b1 to a36fdc5 Compare May 18, 2023 15:35
python/extensions/python.bzl Outdated Show resolved Hide resolved
python/extensions/python.bzl Outdated Show resolved Hide resolved
python/extensions/python.bzl Outdated Show resolved Hide resolved
python/extensions/python.bzl Outdated Show resolved Hide resolved
python/repositories.bzl Outdated Show resolved Hide resolved
python/extensions/python.bzl Outdated Show resolved Hide resolved
Comment on lines 98 to 99
# We register the default toolchain last.
_python_register_toolchains(default_toolchain, False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order the repos are created in doesn't matter, it's the order they are seen when register_toolchains() encounters them. i.e. the order of the toolchain_names list needs to put the default toolchain at the end of the list. This doesn't matter right now because of who calls register_toolchains, so I'm fine with just a TODO comment about this for now, too.

Something for another PR: The repo for the default toolchain is essentially a copy of one of the others. I think we can avoid this by just having the hub generate extra toolchain() calls that point to the same targets in the backing repo.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain more

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's two aspects to this: ordering, and compatiblity.

Usually the order targets are defined in doesn't matter, but toolchains are an exception. Basically, all the native.toolchain targets that are found via register_toolchains() calls are searched in the order they're encountered.

For example, say we had this build file:

toolchain(name="foo", ...)
toolchain(name="bar", ...)

And this module:

register_toolchains("//:all")

This will record a list of [foo, bar]. When someone asks for a toolchain, it'll first check foo, and, if it's compatible, will use it. Otherwise it moves onto the next item in the list.

If we change the BUILD file to put "bar" before "foo", bar will be checked first. If we change the register_toolchains call to explicitly name the targets, e.g. register_toolchains("//:bar", "//:foo"), that will also make bar checked first.

Next, compatibility: when iterating over the toolchains, the first compatible toolchain is used, where "compatible" means "are all of the toolchain's constraints satisfied?". For example, say we had this build file:

toolchain(name="default_linux", compatible_with=["//os:linux"])
toolchain(name="py38_linux", compatible_with=["//os:linux", "//py:py38"])

And we do register_toolchains("//:all"), so the ordering is [default_linux, py38_linux]. Note how the first toolchain has fewer constraints than the second -- it just cares about matching linux.

When a multi-version aware rule is used, it's constraints are (os=linux, py=py38). We want it to use the py38_linux toolchain. But, default_linux is checked first and will be matched because all its constraints (it just needs linux) are satisfied, and thus it uses the wrong toolchain.

The toolchain docs explain the algorithm in detail: https://bazel.build/extending/toolchains#toolchain-resolution

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that targets within a package are ordered lexicographically, not in declaration order. That's why rules_go appends a prefix such as 0001_ to all toolchain definitions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right! Is that documented somewhere? I couldn't find a mention of :all or the lexicographic ordering it uses.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, @Wyverald dug this out of the code when I asked him about it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://cs.opensource.google/bazel/bazel/+/refs/heads/master:src/main/java/com/google/devtools/build/lib/packages/Package.java;drc=665a3241f4acf2291d157c76a413d872ae59241e;l=704

All the target pattern resolution stuff eventually go to Package.getTargets(), and it's an ImmutableSortedSet on the target name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Wyverald @fmeum @rickeylev Are these changes that I should have in this PR? If so can someone do a code review?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrislovecnm No, we don't need to address all of this in this PR because there isn't a hub for rules_python to call register_toolchains on.

The changes for this PR are:

  1. Remove L99, the python_register_toolchains() call for the default toolchain.
  2. Remove the skip-if-default logic up around L56 (so that the repo for the default version is still created)

When we do the PR to automatically register toolchains, then we'll need to worry about what this comment thread is about.

python/extensions/python.bzl Outdated Show resolved Hide resolved
python/extensions/python.bzl Outdated Show resolved Hide resolved
@rickeylev
Copy link
Contributor

Mostly LGTM.

This extension will not create a toolchain in a sub-module if the sub-module toolchain is marked as the default version.
TODO: should we create the toolchain anyways,
but set the default version to False?

Yeah, I'm not sure about this. My main concern is, because the repo will sometimes exist and sometimes not, it'll cause headaches. There are two cases I have in mind:

Case 1: Leaky development-only dependencies. I'm doing development. I add python.toolchain(X, default=True); use_repo(X). I run my tests, things work. I deploy. My users break, because my use_repo(X) call fails -- X was never created. I should have marked something dev_only=True, but forgot; instead of some extra work being done, things have broken.

Case 2: Some non-dev-only reason you want the repo, but don't need it to be registered as a toolchain? I don't know what this reason would be....Aha -- won't pip.parse stop working? For example, my module might have a tool, and my tool has dependencies, which it gets through pip.parse() and python_interpreter_target, so the toolchain repo has to be available.

Ok, yeah, I think we need the repo to be created. Just don't let it be registered as a toolchain when we move the register_toolchains() call into rules_python itself. So in this PR, create the repo. In the PR when we refactor where register_toolchains() is called, update the logic to respect this.

This does expose another issue, though: the submodule will use pip.parse() with one interpreter, but its py_binary targets might end up using a different one through toolchain resolution. I think the best we can do here is provide a "default interpreter" repo, so that the sub-module has a way to pass the same interpreter the default toolchain will use into its pip.parse calls. (Something for another PR, though). A default-interpreter repo might also simplify how much config the user has to do in their MODULE file? Haven't thought deeply here.

cc @fmeum as a second pair of eyes on my thinking here.

If you have more than one toolchain in your root module, you need to set one of the
toolchains as the default version.

For posterity, recap of the convo Chris and I had:

Having a dependency allowed to change your Python version is bad because that dependency might be far away. A consumer might unexpectedly change their version updating a seemingly unrelated dependency. A producer might inadvertently break someone changing their python version. Neither has a good insight into the transitive effects.

We talked about the idea of taking the highest version of any toolchains marked default -- we rejected this idea for two reasons. The first is the same rationale as above. The second is: if you're introducing a new python version to a large project, it's beneficial to get the toolchain setup and installed, but leave it in an unused-by-default state. This allows work to progress to test and validate things incrementally. When you're finally ready, you can switch the default.

Copy link
Collaborator Author

@chrislovecnm chrislovecnm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update the example.

examples/bzlmod_build_file_generation/MODULE.bazel Outdated Show resolved Hide resolved
Copy link
Contributor

@rickeylev rickeylev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM; a couple doc nits. Per chat: one of those CI failures looks legit. I've retried it 4 times now and it keeps failing. It's odd that its only failing on windows, though. Our guess is due to the multiple versions in the example; lets just pull that out for now.

I'll give approval so you can merge when ready.

Two closing thoughts; these don't need to be addressed in this PR. I'm just posting them for posterity.

First: I think the creation of the default repo is sort of wrong, but things end up working out anyways. Basically, because it's not being created with version_constraint=True, there's no toolchain that is multi-version aware. However, all the others are, and the default ends up last. The net effect is looking for the same version as the default will fail to match all the versioned toolchains, then land on the default, and end up with the proper toolchain. This is fine for now -- no need to address it in this PR; when we create the toolchain repo, we can address it in that PR.

Second: I'm think we should have a way for the default interpreter to be referenced by the interpreter extension. Because: lets say you're a sub module and you're OK with using the default python version. How do you configure your pip.parse() call to use it? You can't -- you don't know what the root module is using for the default. So we should address that somehow.

python/extensions/python.bzl Show resolved Hide resolved
python/extensions/python.bzl Show resolved Hide resolved
Comment on lines 14 to 28
PYTHON_NAME = "python3_9"

PYTHON_TOOLCHAINS = PYTHON_NAME + "_toolchains"

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
name = "python3_9",
name = PYTHON_NAME,
configure_coverage_tool = True,
python_version = "3.9",
)
use_repo(python, "python3_9")
use_repo(python, "python3_9_toolchains")
use_repo(python, PYTHON_NAME)
use_repo(python, PYTHON_TOOLCHAINS)

register_toolchains(
"@python3_9_toolchains//:all",
"@{}//:all".format(PYTHON_TOOLCHAINS),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I find the usage of constants here making it harder to read. Even though the definition and the usage of the constants is nearby, my eyes need to jump to lines 14 and 16 when reading line 28. Having the text verbatim would be better at the expense of very little duplication.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the example now, we now have multiple versions, and I find that having variables causes me less grief because of typos. Do you have a compromise?

examples/bzlmod_build_file_generation/MODULE.bazel Outdated Show resolved Hide resolved
python/extensions/private/interpreter_hub.bzl Outdated Show resolved Hide resolved
toolchains.append(toolchain_attr.name)
# If we are in the root module we always register the toolchain.
# We wait to register the default toolchain till the end.
if mod.is_root:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: consider inverting the if statement and using continue statement to reduce the indentation for the code that matters.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide more context.

@@ -17,35 +17,117 @@
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
load("@rules_python//python/extensions/private:interpreter_hub.bzl", "hub_repo")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: having _interpreter_hub_repo = "hub_repo" here would make the code below more readable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming of all of this may need to change. The interpreter is just one part of the hub. We will have repos for all of the interpreter symlinks, and also we will have a hub for all of the toolchains. So I am having a problem with the naming in general. @rickeylev thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "interpreter hub" and "toolchain hub" are sufficiently clear.

"interpreter hub" isn't great, but we couldn't think of a better name for it. The interpreter hub name is internal, so we can rename it if we think of a better name.

python/extensions/python.bzl Show resolved Hide resolved
Copy link
Collaborator

@aignas aignas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments on readability. Thanks for the PR, in general LGTM other than the gazelle example modifications which you commented on yourself.

@chrislovecnm chrislovecnm force-pushed the multiple-toolchains branch 2 times, most recently from 87f6ebf to 9cc37ff Compare May 26, 2023 17:34
@chrislovecnm
Copy link
Collaborator Author

chrislovecnm commented May 26, 2023

So this PR is passing CI now, besides a known OSX flake. For some reason, I am getting an error locally on Windows that I saw in a flake earlier. Moreover, the example/bzlmod/.bazelrc did not enable Windows symlinks, so it should not have passed CI. I am confused. cc: @rickeylev @aignas

I have tried:

bazelisk.exe --output_user_root=C:/b build ...

and

 bazelisk.exe --output_user_root=C:/b build --flaky_test_attempts=3 --local_test_jobs=8 --show_progress_rate_limit=5 --curses=yes --color=yes --terminal_columns=143 --show_timestamps --verbose_failures --jobs=30 --announce_rc --experimental_repository_cache_hardlinks --disk_cache= --sandbox_debug --subcommands=pretty_print ...

And I am getting:

ERROR: An error occurred during the fetch of repository 'rules_python~override~pip~pip_requests':
   Traceback (most recent call last):
        File "C:/b/r4du22do/external/rules_python~override/python/pip_install/pip_repository.bzl", line 705, column 13, in _whl_library_impl
                fail("whl_library %s failed: %s (%s)" % (rctx.attr.name, result.stdout, result.stderr))
Error in fail: whl_library rules_python~override~pip~pip_requests failed:  ()
ERROR: <builtin>: fetching whl_library rule @rules_python~override//python/extensions:rules_python~override~pip~pip_requests: Traceback (most recent call last):
        File "C:/b/r4du22do/external/rules_python~override/python/pip_install/pip_repository.bzl", line 705, column 13, in _whl_library_impl
                fail("whl_library %s failed: %s (%s)" % (rctx.attr.name, result.stdout, result.stderr))
Error in fail: whl_library rules_python~override~pip~pip_requests failed:  ()
ERROR: C:/b/r4du22do/external/rules_python~override~pip~pip/BUILD.bazel:286:6: @rules_python~override~pip~pip//:requests_pkg depends on @rules_python~override~pip~pip_requests//:pkg in repository @rules_python~override~pip~pip_requests which failed to fetch. no such package '@rules_python~override~pip~pip_requests//': whl_library rules_python~override~pip~pip_requests failed:  ()
ERROR: Analysis of target '//:all_requirements_14__deps' failed; build aborted:

We do this work for two reasons. First, we must support Module
dependencies and sub-modules using python.toolchain. Second, we
needed this commit to supporting using multiple toolchains with bzlmod.

This commit modifies the python.toolchain extension to handle being
called multiple times. We are modeling how the multiple Python toolchains
work.

This commit implements various business logic in the toolchain class as
follows.

Toolchains in Sub Modules

It will create a toolchain in a sub-module if the toolchain
of the same name does not exist in the root module. The extension stops name
clashing between toolchains in the root module and sub-modules.
You cannot configure more than one toolchain as the default toolchain.

Toolchain set as the default version.

This extension will not create a toolchain in a sub-module
if the sub-module toolchain is marked as the default version. If you have
more than one toolchain in your root module, you need to set one of the
toolchains as the default version. If there is only one toolchain, it
is set as the default toolchain.
@rickeylev
Copy link
Contributor

Thanks for the review, @aignas. We're going to leave the aesthetics stuff for a separate PR so we can get this base functionality merged. There's still several functional pieces we need to get done to make the bzlmod support actually usable.

@chrislovecnm chrislovecnm added this pull request to the merge queue May 26, 2023
Merged via the queue into bazelbuild:main with commit 60c61e5 May 26, 2023
2 checks passed
renovate bot added a commit to bazel-contrib/rules_bazel_integration_test that referenced this pull request Sep 4, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [rules_python](https://togithub.com/bazelbuild/rules_python) |
http_archive | minor | `0.20.0` -> `0.25.0` |

---

### Release Notes

<details>
<summary>bazelbuild/rules_python (rules_python)</summary>

###
[`v0.25.0`](https://togithub.com/bazelbuild/rules_python/blob/HEAD/CHANGELOG.md#0250---2023-08-22)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.24.0...0.25.0)

##### Changed

-   Python version patch level bumps:
    -   3.9.16 -> 3.9.17
    -   3.10.9 -> 3.10.12
    -   3.11.1 -> 3.11.4
-   (bzlmod) `pip.parse` can no longer automatically use the default
    Python version; this was an unreliable and unsafe behavior. The
    `python_version` arg must always be explicitly specified.

##### Fixed

- (docs) Update docs to use correct bzlmod APIs and clarify how and when
to use
    various APIs.
- (multi-version) The `main` arg is now correctly computed and usually
optional.
- (bzlmod) `pip.parse` no longer requires a call for whatever the
configured
    default Python version is.

##### Added

-   Created a changelog.
-   (gazelle) Stop generating unnecessary imports.
-   (toolchains) s390x supported for Python 3.9.17, 3.10.12, and 3.11.4.

[0.25.0]:
https://togithub.com/bazelbuild/rules_python/releases/tag/0.25.0

###
[`v0.24.0`](https://togithub.com/bazelbuild/rules_python/blob/HEAD/CHANGELOG.md#0240---2023-07-11)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.23.1...0.24.0)

##### Changed

-   **BREAKING** (gazelle) Gazelle 0.30.0 or higher is required
-   (bzlmod) `@python_aliases` renamed to \`@python_versions
-   (bzlmod) `pip.parse` arg `name` renamed to `hub_name`
- (bzlmod) `pip.parse` arg `incompatible_generate_aliases` removed and
always
    true.

##### Fixed

-   (bzlmod) Fixing Windows Python Interpreter symlink issues
-   (py_wheel) Allow twine tags and args
-   (toolchain, bzlmod) Restrict coverage tool visibility under bzlmod
-   (pip) Ignore temporary pyc.NNN files in wheels
-   (pip) Add format() calls to glob_exclude templates
-   plugin_output in py_proto_library rule

##### Added

-   Using Gazelle's lifecycle manager to manage external processes
- (bzlmod) `pip.parse` can be called multiple times with different
Python
    versions
- (bzlmod) Allow bzlmod `pip.parse` to reference the default python
toolchain and interpreter
-   (bzlmod) Implementing wheel annotations via `whl_mods`
-   (gazelle) support multiple requirements files in manifest generation
- (py_wheel) Support for specifying `Description-Content-Type` and
`Summary` in METADATA
-   (py_wheel) Support for specifying `Project-URL`
- (compile_pip_requirements) Added `generate_hashes` arg (default True)
to
    control generating hashes
-   (pip) Create all_data_requirements alias
-   Expose Python C headers through the toolchain.

[0.24.0]:
https://togithub.com/bazelbuild/rules_python/releases/tag/0.24.0

###
[`v0.23.1`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.23.1)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.23.0...0.23.1)

#### Using Bzlmod with Bazel 6

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.23.1")

pip = use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "84aec9e21cc56fbc7f1335035a71c850d1b9b5cc6ff497306f84cced9a769841",
    strip_prefix = "rules_python-0.23.1",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.1/rules_python-0.23.1.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "84aec9e21cc56fbc7f1335035a71c850d1b9b5cc6ff497306f84cced9a769841",
    strip_prefix = "rules_python-0.23.1/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.1/rules_python-0.23.1.tar.gz",
)

### To compile the rules_python gazelle extension from source,
### we must fetch some third-party go dependencies that it uses.

load("@&#8203;rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()
```

#### What's Changed

- fix(bzlmod+gazelle): update BCR release presubmit to use correct
example by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1264

**Full Changelog**:
bazelbuild/rules_python@0.23.0...0.23.1

###
[`v0.23.0`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.23.0)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.22.0...0.23.0)

#### Using Bzlmod with Bazel 6

NOTE: bzlmod support is still experimental; apis are still subject to
change

This release introduces two notable changes to bzlmod support:

- A default toolchain is automatically registered for you. You no longer
need to call `register_toolchains()` yourself. Depending
on rules_python through bazel_dep is sufficient. Note, however, the
Python version used for this default toolchain will change
    frequently/unexpectedly to track the a recent Python version.
- The `name` arg of `python.toolchain` has been removed. The toolchain
repo name format is `python_X_Y` e.g. `python_3_11`.

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.23.0")

pip = use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "8272287b125a23bfc79650ecbbc045ebcaee4d632338b1a50aad34357bcbadce",
    strip_prefix = "rules_python-0.23.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.0/rules_python-0.23.0.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "8272287b125a23bfc79650ecbbc045ebcaee4d632338b1a50aad34357bcbadce",
    strip_prefix = "rules_python-0.23.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.0/rules_python-0.23.0.tar.gz",
)

### To compile the rules_python gazelle extension from source,
### we must fetch some third-party go dependencies that it uses.

load("@&#8203;rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()
```

#### What's Changed

- feat(bzlmod): Allowing multiple python.toolchain extension calls by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1230
- build: Upgrade Gazelle to v0.31.0 by
[@&#8203;linzhp](https://togithub.com/linzhp) in
[bazelbuild/rules_python#1240
- fix: make `import python.runfiles` work with
`--experimental_python_import_all_repositories=false` by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1243
- feat(bzlmod): Moving register.toolchains internal by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1238
- docs(compile_pip_requirements): Add note on requirements.txt VC by
[@&#8203;boomanaiden154](https://togithub.com/boomanaiden154) in
[bazelbuild/rules_python#1245
- cleanup: Set toolchain target_setting directly instead of via inline
ternary by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1246
- fix(bzlmod): give precedence to the first seen versioned toolchain by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1244
- chore: add a pre-commit hook to maintain deleted packages by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1208
- chore: auto-publish gazelle module to BCR by
[@&#8203;kormide](https://togithub.com/kormide) in
[bazelbuild/rules_python#1247
- fix(coverage): bump to latest coverage.py and fix import shadowing by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1249
- feat: add ppc64le releases and update to 3.10.11, 3.11.3 for
python-build-standalone by
[@&#8203;clnperez](https://togithub.com/clnperez) in
[bazelbuild/rules_python#1234
- fix(bzlmod)!: Remove ability to specify toolchain repo name. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1258
- fix: update correct requirements lock file when using os specific lock
files by [@&#8203;Rasrack](https://togithub.com/Rasrack) in
[bazelbuild/rules_python#1123
- fix: use `only-binary` for `download_only` `pip download` by
[@&#8203;lpulley](https://togithub.com/lpulley) in
[bazelbuild/rules_python#1219
- feat: Adding variable support for distribution in py_wheel by
[@&#8203;ns-tkonduri](https://togithub.com/ns-tkonduri) in
[bazelbuild/rules_python#1251
- feat(bzlmod): Register a default toolchain by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1259

#### New Contributors

- [@&#8203;boomanaiden154](https://togithub.com/boomanaiden154) made
their first contribution in
[bazelbuild/rules_python#1245
- [@&#8203;clnperez](https://togithub.com/clnperez) made their first
contribution in
[bazelbuild/rules_python#1234
- [@&#8203;lpulley](https://togithub.com/lpulley) made their first
contribution in
[bazelbuild/rules_python#1219
- [@&#8203;ns-tkonduri](https://togithub.com/ns-tkonduri) made their
first contribution in
[bazelbuild/rules_python#1251

**Full Changelog**:
bazelbuild/rules_python@0.22.0...0.23.0

###
[`v0.22.0`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.22.0)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.21.0...0.22.0)

#### Notable and Breaking Changes

##### Bzlmod extension paths have changed

As part of fixing some fundamental issues with the bzlmod support, we
had to change the path to our extensions. Instead of all extensions
being in a single `extensions.bzl` file, each extension is in its own
file. Users must update the file path in their `use_repo()` statements
as follows:

- `use_extension("@&#8203;rules_python//python:extensions.bzl",
"python")` ->
`use_extension("@&#8203;rules_python//python/extensions:python.bzl",
"python")`
- `use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")`
-> `use_extension("@&#8203;rules_python//python/extensions:pip.bzl",
"pip")`

The following `sed` commands should approximate the necessary changes:

```
sed 'sXuse_extension("@&#8203;rules_python//python:extensions.bzl", "python")Xuse_extension("@&#8203;rules_python//python/extensions:python.bzl", "python")X'`
sed 'sXuse_extension("@&#8203;rules_python//python:extensions.bzl", "pip")Xuse_extension("@&#8203;rules_python//python/extensions:pip.bzl", "pip")X'`

```

See `examples/bzlmod_build_file_generation/MODULE.bazel` for an example
of the new paths.

##### Lockfile output churn

The output of lockfiles has slightly changed. Though functionally the
same, their integrity hashes will change.

***

#### Using Bzlmod with Bazel 6

NOTE: Bzlmod support is still in beta.

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.22.0")

pip = use_extension("@&#8203;rules_python//python/extensions:pip.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

### (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@&#8203;rules_python//python/extensions:python.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@&#8203;python3_9_toolchains//:all",
)
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "863ba0fa944319f7e3d695711427d9ad80ba92c6edd0b7c7443b84e904689539",
    strip_prefix = "rules_python-0.22.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.22.0/rules_python-0.22.0.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "863ba0fa944319f7e3d695711427d9ad80ba92c6edd0b7c7443b84e904689539",
    strip_prefix = "rules_python-0.22.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.22.0/rules_python-0.22.0.tar.gz",
)

### To compile the rules_python gazelle extension from source,
### we must fetch some third-party go dependencies that it uses.

load("@&#8203;rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()
```

#### What's Changed

- fix: remove reference to
@&#8203;bazel_tools//tools/python/private:defs.bzl by
[@&#8203;comius](https://togithub.com/comius) in
[bazelbuild/rules_python#1173
- docs: Tell how to use GitHub to find commits in an upcoming release.
by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1092
- fix: compile_pip_requirements test from external repositories by
[@&#8203;Rasrack](https://togithub.com/Rasrack) in
[bazelbuild/rules_python#1124
- feat: add Python 3.8.16 by
[@&#8203;jml-derek](https://togithub.com/jml-derek) in
[bazelbuild/rules_python#1168
- test: Set mac platform for test_mac_requires_darwin_for_execution by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1179
- fix: Don't reference deleted private bazel_tools bzl file by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1180
- docs: Add starlark directive to code snippet by
[@&#8203;blorente](https://togithub.com/blorente) in
[bazelbuild/rules_python#1170
- tests: Upgrade rules_testing to 0.0.5 by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1184
- tests: Set linux platform for
test_non_mac_doesnt_require_darwin_for_execution by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1183
- fix(bzlmod): correctly template repository macros for requirements,
etc by [@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1190
- type:docs Update README.md by
[@&#8203;yuanweixin](https://togithub.com/yuanweixin) in
[bazelbuild/rules_python#1186
- fix: Allow passing a tuple to the `tags` attribute. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1191
- tests: Add skylib to various test dependencies to fix CI by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1199
- feat: removing bzlmod from example by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1200
- feat: propagate visibility attribute for py_wheel publishing by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1203
- docs: fix typos in pip_repository docs by
[@&#8203;martis42](https://togithub.com/martis42) in
[bazelbuild/rules_python#1202
- tests: Force analysis test labels to resolve within
@&#8203;rules_python context by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1187
- fix(update_deleted_packages.sh): allow to run from anywhere in the
repo by [@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1206
- feat(bzlmod): expose platform-agnostic repo target for toolchain
interpreter by [@&#8203;chrislovecnm](https://togithub.com/chrislovecnm)
in
[bazelbuild/rules_python#1155
- fix(update_deleted_packages.sh): wheels example should not be included
in .bazelrc by [@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1207
- fix: Strip trailing newline from python output by
[@&#8203;illicitonion](https://togithub.com/illicitonion) in
[bazelbuild/rules_python#1212
- fix: manually ignore bazel-\* directories to make using custom Bazel
builds easier by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1181
- test(bzlmod): explicitly enable bzlmod in the test harness by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1204
- feat(bzlmod): Cleaning up interpreter resolution by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1218
- feat(bzlmod)!: Move each bzlmod extension into its own file by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1226
- Adding bzlmod support document by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1214
- test(coverage): add a test to check the sys.path under bzlmod by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1223
- fix(toolchain): set correct return attrs to remove non-hermeticity
warning by [@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1231
- fix: allow url fragments in requirements file by
[@&#8203;mattoberle](https://togithub.com/mattoberle) in
[bazelbuild/rules_python#1195
- fix: `example/build_file_generation/README.md` by
[@&#8203;ofey404](https://togithub.com/ofey404) in
[bazelbuild/rules_python#1164
- fix: Using canonical name in requirements.bzl by
[@&#8203;linzhp](https://togithub.com/linzhp) in
[bazelbuild/rules_python#1176
- feat(bzlmod): support entry_point macro by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1220

#### New Contributors

- [@&#8203;Rasrack](https://togithub.com/Rasrack) made their first
contribution in
[bazelbuild/rules_python#1124
- [@&#8203;jml-derek](https://togithub.com/jml-derek) made their first
contribution in
[bazelbuild/rules_python#1168
- [@&#8203;blorente](https://togithub.com/blorente) made their first
contribution in
[bazelbuild/rules_python#1170
- [@&#8203;yuanweixin](https://togithub.com/yuanweixin) made their first
contribution in
[bazelbuild/rules_python#1186
- [@&#8203;ofey404](https://togithub.com/ofey404) made their first
contribution in
[bazelbuild/rules_python#1164

**Full Changelog**:
bazelbuild/rules_python@0.21.0...0.22.0

###
[`v0.21.0`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.21.0)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.20.0...0.21.0)

#### Using Bzlmod with Bazel 6

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.21.0")

pip = use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

### (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@&#8203;rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@&#8203;python3_9_toolchains//:all",
)
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "94750828b18044533e98a129003b6a68001204038dc4749f40b195b24c38f49f",
    strip_prefix = "rules_python-0.21.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.21.0/rules_python-0.21.0.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "94750828b18044533e98a129003b6a68001204038dc4749f40b195b24c38f49f",
    strip_prefix = "rules_python-0.21.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.21.0/rules_python-0.21.0.tar.gz",
)

### To compile the rules_python gazelle extension from source,
### we must fetch some third-party go dependencies that it uses.

load("@&#8203;rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()
```

#### What's Changed

- cleanup: factor reexports.bzl into the respective implementation files
by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1137
- fix: bump installer to handle windows better by
[@&#8203;f0rmiga](https://togithub.com/f0rmiga) in
[bazelbuild/rules_python#1138
- build: Fixing buildifier by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1148
- docs: Updating documentation for bzlmod by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1149
- fix: use a consistent buildifier version for CI and pre-commit by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1151
- chore: bump buildifier to 6.1.0 by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1152
- fix: correct the labels returned by all_requirements lists by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1146
- fix: gazelle correctly adds new py_test rules by
[@&#8203;amartani](https://togithub.com/amartani) in
[bazelbuild/rules_python#1143
- fix: respect kind mapping by
[@&#8203;OniOni](https://togithub.com/OniOni) in
[bazelbuild/rules_python#1158
- test: cleanup gazelle tests and run them in parallel by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1159
- \[docs] Fixing rule name in coverage.md docs by
[@&#8203;anfelbar](https://togithub.com/anfelbar) in
[bazelbuild/rules_python#1162
- feat: Support specifying multiple download URLs in tool_versions. by
[@&#8203;quval](https://togithub.com/quval) in
[bazelbuild/rules_python#1145

#### New Contributors

- [@&#8203;amartani](https://togithub.com/amartani) made their first
contribution in
[bazelbuild/rules_python#1143
- [@&#8203;anfelbar](https://togithub.com/anfelbar) made their first
contribution in
[bazelbuild/rules_python#1162
- [@&#8203;quval](https://togithub.com/quval) made their first
contribution in
[bazelbuild/rules_python#1145

**Full Changelog**:
bazelbuild/rules_python@0.20.0...0.21.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/bazel-contrib/rules_bazel_integration_test).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS41NC4wIiwidXBkYXRlZEluVmVyIjoiMzYuNzguOCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
cgrindel pushed a commit to k1nkreet/rules_bazel_integration_test that referenced this pull request Sep 27, 2023
…#153)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [rules_python](https://togithub.com/bazelbuild/rules_python) |
http_archive | minor | `0.20.0` -> `0.25.0` |

---

### Release Notes

<details>
<summary>bazelbuild/rules_python (rules_python)</summary>

###
[`v0.25.0`](https://togithub.com/bazelbuild/rules_python/blob/HEAD/CHANGELOG.md#0250---2023-08-22)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.24.0...0.25.0)

##### Changed

-   Python version patch level bumps:
    -   3.9.16 -> 3.9.17
    -   3.10.9 -> 3.10.12
    -   3.11.1 -> 3.11.4
-   (bzlmod) `pip.parse` can no longer automatically use the default
    Python version; this was an unreliable and unsafe behavior. The
    `python_version` arg must always be explicitly specified.

##### Fixed

- (docs) Update docs to use correct bzlmod APIs and clarify how and when
to use
    various APIs.
- (multi-version) The `main` arg is now correctly computed and usually
optional.
- (bzlmod) `pip.parse` no longer requires a call for whatever the
configured
    default Python version is.

##### Added

-   Created a changelog.
-   (gazelle) Stop generating unnecessary imports.
-   (toolchains) s390x supported for Python 3.9.17, 3.10.12, and 3.11.4.

[0.25.0]:
https://togithub.com/bazelbuild/rules_python/releases/tag/0.25.0

###
[`v0.24.0`](https://togithub.com/bazelbuild/rules_python/blob/HEAD/CHANGELOG.md#0240---2023-07-11)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.23.1...0.24.0)

##### Changed

-   **BREAKING** (gazelle) Gazelle 0.30.0 or higher is required
-   (bzlmod) `@python_aliases` renamed to \`@python_versions
-   (bzlmod) `pip.parse` arg `name` renamed to `hub_name`
- (bzlmod) `pip.parse` arg `incompatible_generate_aliases` removed and
always
    true.

##### Fixed

-   (bzlmod) Fixing Windows Python Interpreter symlink issues
-   (py_wheel) Allow twine tags and args
-   (toolchain, bzlmod) Restrict coverage tool visibility under bzlmod
-   (pip) Ignore temporary pyc.NNN files in wheels
-   (pip) Add format() calls to glob_exclude templates
-   plugin_output in py_proto_library rule

##### Added

-   Using Gazelle's lifecycle manager to manage external processes
- (bzlmod) `pip.parse` can be called multiple times with different
Python
    versions
- (bzlmod) Allow bzlmod `pip.parse` to reference the default python
toolchain and interpreter
-   (bzlmod) Implementing wheel annotations via `whl_mods`
-   (gazelle) support multiple requirements files in manifest generation
- (py_wheel) Support for specifying `Description-Content-Type` and
`Summary` in METADATA
-   (py_wheel) Support for specifying `Project-URL`
- (compile_pip_requirements) Added `generate_hashes` arg (default True)
to
    control generating hashes
-   (pip) Create all_data_requirements alias
-   Expose Python C headers through the toolchain.

[0.24.0]:
https://togithub.com/bazelbuild/rules_python/releases/tag/0.24.0

###
[`v0.23.1`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.23.1)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.23.0...0.23.1)

#### Using Bzlmod with Bazel 6

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.23.1")

pip = use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "84aec9e21cc56fbc7f1335035a71c850d1b9b5cc6ff497306f84cced9a769841",
    strip_prefix = "rules_python-0.23.1",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.1/rules_python-0.23.1.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "84aec9e21cc56fbc7f1335035a71c850d1b9b5cc6ff497306f84cced9a769841",
    strip_prefix = "rules_python-0.23.1/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.1/rules_python-0.23.1.tar.gz",
)

### To compile the rules_python gazelle extension from source,
### we must fetch some third-party go dependencies that it uses.

load("@&#8203;rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()
```

#### What's Changed

- fix(bzlmod+gazelle): update BCR release presubmit to use correct
example by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1264

**Full Changelog**:
bazelbuild/rules_python@0.23.0...0.23.1

###
[`v0.23.0`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.23.0)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.22.0...0.23.0)

#### Using Bzlmod with Bazel 6

NOTE: bzlmod support is still experimental; apis are still subject to
change

This release introduces two notable changes to bzlmod support:

- A default toolchain is automatically registered for you. You no longer
need to call `register_toolchains()` yourself. Depending
on rules_python through bazel_dep is sufficient. Note, however, the
Python version used for this default toolchain will change
    frequently/unexpectedly to track the a recent Python version.
- The `name` arg of `python.toolchain` has been removed. The toolchain
repo name format is `python_X_Y` e.g. `python_3_11`.

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.23.0")

pip = use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "8272287b125a23bfc79650ecbbc045ebcaee4d632338b1a50aad34357bcbadce",
    strip_prefix = "rules_python-0.23.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.0/rules_python-0.23.0.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "8272287b125a23bfc79650ecbbc045ebcaee4d632338b1a50aad34357bcbadce",
    strip_prefix = "rules_python-0.23.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.0/rules_python-0.23.0.tar.gz",
)

### To compile the rules_python gazelle extension from source,
### we must fetch some third-party go dependencies that it uses.

load("@&#8203;rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()
```

#### What's Changed

- feat(bzlmod): Allowing multiple python.toolchain extension calls by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1230
- build: Upgrade Gazelle to v0.31.0 by
[@&#8203;linzhp](https://togithub.com/linzhp) in
[bazelbuild/rules_python#1240
- fix: make `import python.runfiles` work with
`--experimental_python_import_all_repositories=false` by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1243
- feat(bzlmod): Moving register.toolchains internal by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1238
- docs(compile_pip_requirements): Add note on requirements.txt VC by
[@&#8203;boomanaiden154](https://togithub.com/boomanaiden154) in
[bazelbuild/rules_python#1245
- cleanup: Set toolchain target_setting directly instead of via inline
ternary by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1246
- fix(bzlmod): give precedence to the first seen versioned toolchain by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1244
- chore: add a pre-commit hook to maintain deleted packages by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1208
- chore: auto-publish gazelle module to BCR by
[@&#8203;kormide](https://togithub.com/kormide) in
[bazelbuild/rules_python#1247
- fix(coverage): bump to latest coverage.py and fix import shadowing by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1249
- feat: add ppc64le releases and update to 3.10.11, 3.11.3 for
python-build-standalone by
[@&#8203;clnperez](https://togithub.com/clnperez) in
[bazelbuild/rules_python#1234
- fix(bzlmod)!: Remove ability to specify toolchain repo name. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1258
- fix: update correct requirements lock file when using os specific lock
files by [@&#8203;Rasrack](https://togithub.com/Rasrack) in
[bazelbuild/rules_python#1123
- fix: use `only-binary` for `download_only` `pip download` by
[@&#8203;lpulley](https://togithub.com/lpulley) in
[bazelbuild/rules_python#1219
- feat: Adding variable support for distribution in py_wheel by
[@&#8203;ns-tkonduri](https://togithub.com/ns-tkonduri) in
[bazelbuild/rules_python#1251
- feat(bzlmod): Register a default toolchain by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1259

#### New Contributors

- [@&#8203;boomanaiden154](https://togithub.com/boomanaiden154) made
their first contribution in
[bazelbuild/rules_python#1245
- [@&#8203;clnperez](https://togithub.com/clnperez) made their first
contribution in
[bazelbuild/rules_python#1234
- [@&#8203;lpulley](https://togithub.com/lpulley) made their first
contribution in
[bazelbuild/rules_python#1219
- [@&#8203;ns-tkonduri](https://togithub.com/ns-tkonduri) made their
first contribution in
[bazelbuild/rules_python#1251

**Full Changelog**:
bazelbuild/rules_python@0.22.0...0.23.0

###
[`v0.22.0`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.22.0)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.21.0...0.22.0)

#### Notable and Breaking Changes

##### Bzlmod extension paths have changed

As part of fixing some fundamental issues with the bzlmod support, we
had to change the path to our extensions. Instead of all extensions
being in a single `extensions.bzl` file, each extension is in its own
file. Users must update the file path in their `use_repo()` statements
as follows:

- `use_extension("@&#8203;rules_python//python:extensions.bzl",
"python")` ->
`use_extension("@&#8203;rules_python//python/extensions:python.bzl",
"python")`
- `use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")`
-> `use_extension("@&#8203;rules_python//python/extensions:pip.bzl",
"pip")`

The following `sed` commands should approximate the necessary changes:

```
sed 'sXuse_extension("@&#8203;rules_python//python:extensions.bzl", "python")Xuse_extension("@&#8203;rules_python//python/extensions:python.bzl", "python")X'`
sed 'sXuse_extension("@&#8203;rules_python//python:extensions.bzl", "pip")Xuse_extension("@&#8203;rules_python//python/extensions:pip.bzl", "pip")X'`

```

See `examples/bzlmod_build_file_generation/MODULE.bazel` for an example
of the new paths.

##### Lockfile output churn

The output of lockfiles has slightly changed. Though functionally the
same, their integrity hashes will change.

***

#### Using Bzlmod with Bazel 6

NOTE: Bzlmod support is still in beta.

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.22.0")

pip = use_extension("@&#8203;rules_python//python/extensions:pip.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

### (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@&#8203;rules_python//python/extensions:python.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@&#8203;python3_9_toolchains//:all",
)
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "863ba0fa944319f7e3d695711427d9ad80ba92c6edd0b7c7443b84e904689539",
    strip_prefix = "rules_python-0.22.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.22.0/rules_python-0.22.0.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "863ba0fa944319f7e3d695711427d9ad80ba92c6edd0b7c7443b84e904689539",
    strip_prefix = "rules_python-0.22.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.22.0/rules_python-0.22.0.tar.gz",
)

### To compile the rules_python gazelle extension from source,
### we must fetch some third-party go dependencies that it uses.

load("@&#8203;rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()
```

#### What's Changed

- fix: remove reference to
@&#8203;bazel_tools//tools/python/private:defs.bzl by
[@&#8203;comius](https://togithub.com/comius) in
[bazelbuild/rules_python#1173
- docs: Tell how to use GitHub to find commits in an upcoming release.
by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1092
- fix: compile_pip_requirements test from external repositories by
[@&#8203;Rasrack](https://togithub.com/Rasrack) in
[bazelbuild/rules_python#1124
- feat: add Python 3.8.16 by
[@&#8203;jml-derek](https://togithub.com/jml-derek) in
[bazelbuild/rules_python#1168
- test: Set mac platform for test_mac_requires_darwin_for_execution by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1179
- fix: Don't reference deleted private bazel_tools bzl file by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1180
- docs: Add starlark directive to code snippet by
[@&#8203;blorente](https://togithub.com/blorente) in
[bazelbuild/rules_python#1170
- tests: Upgrade rules_testing to 0.0.5 by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1184
- tests: Set linux platform for
test_non_mac_doesnt_require_darwin_for_execution by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1183
- fix(bzlmod): correctly template repository macros for requirements,
etc by [@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1190
- type:docs Update README.md by
[@&#8203;yuanweixin](https://togithub.com/yuanweixin) in
[bazelbuild/rules_python#1186
- fix: Allow passing a tuple to the `tags` attribute. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1191
- tests: Add skylib to various test dependencies to fix CI by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1199
- feat: removing bzlmod from example by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1200
- feat: propagate visibility attribute for py_wheel publishing by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1203
- docs: fix typos in pip_repository docs by
[@&#8203;martis42](https://togithub.com/martis42) in
[bazelbuild/rules_python#1202
- tests: Force analysis test labels to resolve within
@&#8203;rules_python context by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1187
- fix(update_deleted_packages.sh): allow to run from anywhere in the
repo by [@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1206
- feat(bzlmod): expose platform-agnostic repo target for toolchain
interpreter by [@&#8203;chrislovecnm](https://togithub.com/chrislovecnm)
in
[bazelbuild/rules_python#1155
- fix(update_deleted_packages.sh): wheels example should not be included
in .bazelrc by [@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1207
- fix: Strip trailing newline from python output by
[@&#8203;illicitonion](https://togithub.com/illicitonion) in
[bazelbuild/rules_python#1212
- fix: manually ignore bazel-\* directories to make using custom Bazel
builds easier by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1181
- test(bzlmod): explicitly enable bzlmod in the test harness by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1204
- feat(bzlmod): Cleaning up interpreter resolution by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1218
- feat(bzlmod)!: Move each bzlmod extension into its own file by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1226
- Adding bzlmod support document by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1214
- test(coverage): add a test to check the sys.path under bzlmod by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1223
- fix(toolchain): set correct return attrs to remove non-hermeticity
warning by [@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1231
- fix: allow url fragments in requirements file by
[@&#8203;mattoberle](https://togithub.com/mattoberle) in
[bazelbuild/rules_python#1195
- fix: `example/build_file_generation/README.md` by
[@&#8203;ofey404](https://togithub.com/ofey404) in
[bazelbuild/rules_python#1164
- fix: Using canonical name in requirements.bzl by
[@&#8203;linzhp](https://togithub.com/linzhp) in
[bazelbuild/rules_python#1176
- feat(bzlmod): support entry_point macro by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1220

#### New Contributors

- [@&#8203;Rasrack](https://togithub.com/Rasrack) made their first
contribution in
[bazelbuild/rules_python#1124
- [@&#8203;jml-derek](https://togithub.com/jml-derek) made their first
contribution in
[bazelbuild/rules_python#1168
- [@&#8203;blorente](https://togithub.com/blorente) made their first
contribution in
[bazelbuild/rules_python#1170
- [@&#8203;yuanweixin](https://togithub.com/yuanweixin) made their first
contribution in
[bazelbuild/rules_python#1186
- [@&#8203;ofey404](https://togithub.com/ofey404) made their first
contribution in
[bazelbuild/rules_python#1164

**Full Changelog**:
bazelbuild/rules_python@0.21.0...0.22.0

###
[`v0.21.0`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.21.0)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.20.0...0.21.0)

#### Using Bzlmod with Bazel 6

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.21.0")

pip = use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

### (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@&#8203;rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@&#8203;python3_9_toolchains//:all",
)
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "94750828b18044533e98a129003b6a68001204038dc4749f40b195b24c38f49f",
    strip_prefix = "rules_python-0.21.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.21.0/rules_python-0.21.0.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "94750828b18044533e98a129003b6a68001204038dc4749f40b195b24c38f49f",
    strip_prefix = "rules_python-0.21.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.21.0/rules_python-0.21.0.tar.gz",
)

### To compile the rules_python gazelle extension from source,
### we must fetch some third-party go dependencies that it uses.

load("@&#8203;rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()
```

#### What's Changed

- cleanup: factor reexports.bzl into the respective implementation files
by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1137
- fix: bump installer to handle windows better by
[@&#8203;f0rmiga](https://togithub.com/f0rmiga) in
[bazelbuild/rules_python#1138
- build: Fixing buildifier by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1148
- docs: Updating documentation for bzlmod by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1149
- fix: use a consistent buildifier version for CI and pre-commit by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1151
- chore: bump buildifier to 6.1.0 by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1152
- fix: correct the labels returned by all_requirements lists by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1146
- fix: gazelle correctly adds new py_test rules by
[@&#8203;amartani](https://togithub.com/amartani) in
[bazelbuild/rules_python#1143
- fix: respect kind mapping by
[@&#8203;OniOni](https://togithub.com/OniOni) in
[bazelbuild/rules_python#1158
- test: cleanup gazelle tests and run them in parallel by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1159
- \[docs] Fixing rule name in coverage.md docs by
[@&#8203;anfelbar](https://togithub.com/anfelbar) in
[bazelbuild/rules_python#1162
- feat: Support specifying multiple download URLs in tool_versions. by
[@&#8203;quval](https://togithub.com/quval) in
[bazelbuild/rules_python#1145

#### New Contributors

- [@&#8203;amartani](https://togithub.com/amartani) made their first
contribution in
[bazelbuild/rules_python#1143
- [@&#8203;anfelbar](https://togithub.com/anfelbar) made their first
contribution in
[bazelbuild/rules_python#1162
- [@&#8203;quval](https://togithub.com/quval) made their first
contribution in
[bazelbuild/rules_python#1145

**Full Changelog**:
bazelbuild/rules_python@0.20.0...0.21.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/bazel-contrib/rules_bazel_integration_test).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS41NC4wIiwidXBkYXRlZEluVmVyIjoiMzYuNzguOCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
alexeagle pushed a commit to aspect-build/rules_py that referenced this pull request Nov 14, 2023
…#192)

[![Mend Renovate logo
banner](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[rules_python_gazelle_plugin](https://togithub.com/bazelbuild/rules_python)
| http_archive | minor | `0.18.0` -> `0.26.0` |

---

### Release Notes

<details>
<summary>bazelbuild/rules_python (rules_python_gazelle_plugin)</summary>

###
[`v0.26.0`](https://togithub.com/bazelbuild/rules_python/blob/HEAD/CHANGELOG.md#0260---2023-10-06)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.25.0...0.26.0)

##### Changed

-   Python version patch level bumps:
    -   3.8.15  -> 3.8.18
    -   3.9.17  -> 3.9.18
    -   3.10.12 -> 3.10.13
    -   3.11.4  -> 3.11.6

- (deps) Upgrade rules_go 0.39.1 -> 0.41.0; this is so gazelle
integration works with upcoming Bazel versions

- (multi-version) The `distribs` attribute is no longer propagated. This
    attribute has been long deprecated by Bazel and shouldn't be used.

- Calling `//python:repositories.bzl#py_repositories()` is required. It
has
always been documented as necessary, but it was possible to omit it in
certain
cases. An error about `@rules_python_internal` means the
`py_repositories()`
    call is missing in `WORKSPACE`.

- (bzlmod) The `pip.parse` extension will generate os/arch specific lock
    file entries on `bazel>=6.4`.

##### Added

-   (bzlmod, entry_point) Added
[`py_console_script_binary`](./docs/py_console_script_binary.md), which
allows adding custom dependencies to a package's entry points and
customizing
    the `py_binary` rule used to build it.

-   New Python versions available: `3.8.17`, `3.11.5` using

https://github.com/indygreg/python-build-standalone/releases/tag/20230826.

- (gazelle) New `# gazelle:python_generation_mode file` directive to
support
    generating one `py_library` per file.

- (python_repository) Support `netrc` and `auth_patterns` attributes to
enable
authentication against private HTTP hosts serving Python toolchain
binaries.

-   `//python:packaging_bzl` added, a `bzl_library` for the Starlark
    files `//python:packaging.bzl` requires.

-   (py_wheel) Added the `incompatible_normalize_name` feature flag to
    normalize the package distribution name according to latest Python
    packaging standards. Defaults to `False` for the time being.

-   (py_wheel) Added the `incompatible_normalize_version` feature flag
    to normalize the package version according to PEP440 standard. This
    also adds support for local version specifiers (versions with a `+`
    in them), in accordance with PEP440. Defaults to `False` for the
    time being.

- New Python versions available: `3.8.18`, `3.9.18`, `3.10.13`,
`3.11.6`, `3.12.0` using

https://github.com/indygreg/python-build-standalone/releases/tag/20231002.
    `3.12.0` support is considered beta and may have issues.

##### Removed

- (bzlmod) The `entry_point` macro is no longer supported and has been
removed
in favour of the `py_console_script_binary` macro for `bzlmod` users.

- (bzlmod) The `pip.parse` no longer generates `{hub_name}_{py_version}`
hub repos
as the `entry_point` macro has been superseded by
`py_console_script_binary`.

- (bzlmod) The `pip.parse` no longer generates
`{hub_name}_{distribution}` hub repos.

##### Fixed

- (whl_library) No longer restarts repository rule when fetching
external
dependencies improving initial build times involving external dependency
    fetching.

-   (gazelle) Improve runfiles lookup hermeticity.

###
[`v0.25.0`](https://togithub.com/bazelbuild/rules_python/blob/HEAD/CHANGELOG.md#0250---2023-08-22)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.24.0...0.25.0)

##### Changed

-   Python version patch level bumps:
    -   3.9.16 -> 3.9.17
    -   3.10.9 -> 3.10.12
    -   3.11.1 -> 3.11.4
-   (bzlmod) `pip.parse` can no longer automatically use the default
    Python version; this was an unreliable and unsafe behavior. The
    `python_version` arg must always be explicitly specified.

##### Fixed

- (docs) Update docs to use correct bzlmod APIs and clarify how and when
to use
    various APIs.
- (multi-version) The `main` arg is now correctly computed and usually
optional.
- (bzlmod) `pip.parse` no longer requires a call for whatever the
configured
    default Python version is.

##### Added

-   Created a changelog.
-   (gazelle) Stop generating unnecessary imports.
-   (toolchains) s390x supported for Python 3.9.17, 3.10.12, and 3.11.4.

[0.25.0]:
https://togithub.com/bazelbuild/rules_python/releases/tag/0.25.0

###
[`v0.24.0`](https://togithub.com/bazelbuild/rules_python/blob/HEAD/CHANGELOG.md#0240---2023-07-11)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.23.1...0.24.0)

##### Changed

-   **BREAKING** (gazelle) Gazelle 0.30.0 or higher is required
-   (bzlmod) `@python_aliases` renamed to \`@python_versions
-   (bzlmod) `pip.parse` arg `name` renamed to `hub_name`
- (bzlmod) `pip.parse` arg `incompatible_generate_aliases` removed and
always
    true.

##### Fixed

-   (bzlmod) Fixing Windows Python Interpreter symlink issues
-   (py_wheel) Allow twine tags and args
-   (toolchain, bzlmod) Restrict coverage tool visibility under bzlmod
-   (pip) Ignore temporary pyc.NNN files in wheels
-   (pip) Add format() calls to glob_exclude templates
-   plugin_output in py_proto_library rule

##### Added

-   Using Gazelle's lifecycle manager to manage external processes
- (bzlmod) `pip.parse` can be called multiple times with different
Python
    versions
- (bzlmod) Allow bzlmod `pip.parse` to reference the default python
toolchain and interpreter
-   (bzlmod) Implementing wheel annotations via `whl_mods`
-   (gazelle) support multiple requirements files in manifest generation
- (py_wheel) Support for specifying `Description-Content-Type` and
`Summary` in METADATA
-   (py_wheel) Support for specifying `Project-URL`
- (compile_pip_requirements) Added `generate_hashes` arg (default True)
to
    control generating hashes
-   (pip) Create all_data_requirements alias
-   Expose Python C headers through the toolchain.

[0.24.0]:
https://togithub.com/bazelbuild/rules_python/releases/tag/0.24.0

###
[`v0.23.1`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.23.1)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.23.0...0.23.1)

#### Using Bzlmod with Bazel 6

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.23.1")

pip = use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "84aec9e21cc56fbc7f1335035a71c850d1b9b5cc6ff497306f84cced9a769841",
    strip_prefix = "rules_python-0.23.1",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.1/rules_python-0.23.1.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "84aec9e21cc56fbc7f1335035a71c850d1b9b5cc6ff497306f84cced9a769841",
    strip_prefix = "rules_python-0.23.1/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.1/rules_python-0.23.1.tar.gz",
)

### To compile the rules_python gazelle extension from source,
### we must fetch some third-party go dependencies that it uses.

load("@&#8203;rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()
```

#### What's Changed

- fix(bzlmod+gazelle): update BCR release presubmit to use correct
example by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1264

**Full Changelog**:
bazelbuild/rules_python@0.23.0...0.23.1

###
[`v0.23.0`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.23.0)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.22.0...0.23.0)

#### Using Bzlmod with Bazel 6

NOTE: bzlmod support is still experimental; apis are still subject to
change

This release introduces two notable changes to bzlmod support:

- A default toolchain is automatically registered for you. You no longer
need to call `register_toolchains()` yourself. Depending
on rules_python through bazel_dep is sufficient. Note, however, the
Python version used for this default toolchain will change
    frequently/unexpectedly to track the a recent Python version.
- The `name` arg of `python.toolchain` has been removed. The toolchain
repo name format is `python_X_Y` e.g. `python_3_11`.

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.23.0")

pip = use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "8272287b125a23bfc79650ecbbc045ebcaee4d632338b1a50aad34357bcbadce",
    strip_prefix = "rules_python-0.23.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.0/rules_python-0.23.0.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "8272287b125a23bfc79650ecbbc045ebcaee4d632338b1a50aad34357bcbadce",
    strip_prefix = "rules_python-0.23.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.0/rules_python-0.23.0.tar.gz",
)

### To compile the rules_python gazelle extension from source,
### we must fetch some third-party go dependencies that it uses.

load("@&#8203;rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()
```

#### What's Changed

- feat(bzlmod): Allowing multiple python.toolchain extension calls by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1230
- build: Upgrade Gazelle to v0.31.0 by
[@&#8203;linzhp](https://togithub.com/linzhp) in
[bazelbuild/rules_python#1240
- fix: make `import python.runfiles` work with
`--experimental_python_import_all_repositories=false` by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1243
- feat(bzlmod): Moving register.toolchains internal by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1238
- docs(compile_pip_requirements): Add note on requirements.txt VC by
[@&#8203;boomanaiden154](https://togithub.com/boomanaiden154) in
[bazelbuild/rules_python#1245
- cleanup: Set toolchain target_setting directly instead of via inline
ternary by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1246
- fix(bzlmod): give precedence to the first seen versioned toolchain by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1244
- chore: add a pre-commit hook to maintain deleted packages by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1208
- chore: auto-publish gazelle module to BCR by
[@&#8203;kormide](https://togithub.com/kormide) in
[bazelbuild/rules_python#1247
- fix(coverage): bump to latest coverage.py and fix import shadowing by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1249
- feat: add ppc64le releases and update to 3.10.11, 3.11.3 for
python-build-standalone by
[@&#8203;clnperez](https://togithub.com/clnperez) in
[bazelbuild/rules_python#1234
- fix(bzlmod)!: Remove ability to specify toolchain repo name. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1258
- fix: update correct requirements lock file when using os specific lock
files by [@&#8203;Rasrack](https://togithub.com/Rasrack) in
[bazelbuild/rules_python#1123
- fix: use `only-binary` for `download_only` `pip download` by
[@&#8203;lpulley](https://togithub.com/lpulley) in
[bazelbuild/rules_python#1219
- feat: Adding variable support for distribution in py_wheel by
[@&#8203;ns-tkonduri](https://togithub.com/ns-tkonduri) in
[bazelbuild/rules_python#1251
- feat(bzlmod): Register a default toolchain by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1259

#### New Contributors

- [@&#8203;boomanaiden154](https://togithub.com/boomanaiden154) made
their first contribution in
[bazelbuild/rules_python#1245
- [@&#8203;clnperez](https://togithub.com/clnperez) made their first
contribution in
[bazelbuild/rules_python#1234
- [@&#8203;lpulley](https://togithub.com/lpulley) made their first
contribution in
[bazelbuild/rules_python#1219
- [@&#8203;ns-tkonduri](https://togithub.com/ns-tkonduri) made their
first contribution in
[bazelbuild/rules_python#1251

**Full Changelog**:
bazelbuild/rules_python@0.22.0...0.23.0

###
[`v0.22.0`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.22.0)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.21.0...0.22.0)

#### Notable and Breaking Changes

##### Bzlmod extension paths have changed

As part of fixing some fundamental issues with the bzlmod support, we
had to change the path to our extensions. Instead of all extensions
being in a single `extensions.bzl` file, each extension is in its own
file. Users must update the file path in their `use_repo()` statements
as follows:

- `use_extension("@&#8203;rules_python//python:extensions.bzl",
"python")` ->
`use_extension("@&#8203;rules_python//python/extensions:python.bzl",
"python")`
- `use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")`
-> `use_extension("@&#8203;rules_python//python/extensions:pip.bzl",
"pip")`

The following `sed` commands should approximate the necessary changes:

```
sed 'sXuse_extension("@&#8203;rules_python//python:extensions.bzl", "python")Xuse_extension("@&#8203;rules_python//python/extensions:python.bzl", "python")X'`
sed 'sXuse_extension("@&#8203;rules_python//python:extensions.bzl", "pip")Xuse_extension("@&#8203;rules_python//python/extensions:pip.bzl", "pip")X'`

```

See `examples/bzlmod_build_file_generation/MODULE.bazel` for an example
of the new paths.

##### Lockfile output churn

The output of lockfiles has slightly changed. Though functionally the
same, their integrity hashes will change.

***

#### Using Bzlmod with Bazel 6

NOTE: Bzlmod support is still in beta.

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.22.0")

pip = use_extension("@&#8203;rules_python//python/extensions:pip.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

### (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@&#8203;rules_python//python/extensions:python.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@&#8203;python3_9_toolchains//:all",
)
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "863ba0fa944319f7e3d695711427d9ad80ba92c6edd0b7c7443b84e904689539",
    strip_prefix = "rules_python-0.22.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.22.0/rules_python-0.22.0.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "863ba0fa944319f7e3d695711427d9ad80ba92c6edd0b7c7443b84e904689539",
    strip_prefix = "rules_python-0.22.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.22.0/rules_python-0.22.0.tar.gz",
)

### To compile the rules_python gazelle extension from source,
### we must fetch some third-party go dependencies that it uses.

load("@&#8203;rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()
```

#### What's Changed

- fix: remove reference to
@&#8203;bazel_tools//tools/python/private:defs.bzl by
[@&#8203;comius](https://togithub.com/comius) in
[bazelbuild/rules_python#1173
- docs: Tell how to use GitHub to find commits in an upcoming release.
by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1092
- fix: compile_pip_requirements test from external repositories by
[@&#8203;Rasrack](https://togithub.com/Rasrack) in
[bazelbuild/rules_python#1124
- feat: add Python 3.8.16 by
[@&#8203;jml-derek](https://togithub.com/jml-derek) in
[bazelbuild/rules_python#1168
- test: Set mac platform for test_mac_requires_darwin_for_execution by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1179
- fix: Don't reference deleted private bazel_tools bzl file by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1180
- docs: Add starlark directive to code snippet by
[@&#8203;blorente](https://togithub.com/blorente) in
[bazelbuild/rules_python#1170
- tests: Upgrade rules_testing to 0.0.5 by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1184
- tests: Set linux platform for
test_non_mac_doesnt_require_darwin_for_execution by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1183
- fix(bzlmod): correctly template repository macros for requirements,
etc by [@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1190
- type:docs Update README.md by
[@&#8203;yuanweixin](https://togithub.com/yuanweixin) in
[bazelbuild/rules_python#1186
- fix: Allow passing a tuple to the `tags` attribute. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1191
- tests: Add skylib to various test dependencies to fix CI by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1199
- feat: removing bzlmod from example by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1200
- feat: propagate visibility attribute for py_wheel publishing by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1203
- docs: fix typos in pip_repository docs by
[@&#8203;martis42](https://togithub.com/martis42) in
[bazelbuild/rules_python#1202
- tests: Force analysis test labels to resolve within
@&#8203;rules_python context by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1187
- fix(update_deleted_packages.sh): allow to run from anywhere in the
repo by [@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1206
- feat(bzlmod): expose platform-agnostic repo target for toolchain
interpreter by [@&#8203;chrislovecnm](https://togithub.com/chrislovecnm)
in
[bazelbuild/rules_python#1155
- fix(update_deleted_packages.sh): wheels example should not be included
in .bazelrc by [@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1207
- fix: Strip trailing newline from python output by
[@&#8203;illicitonion](https://togithub.com/illicitonion) in
[bazelbuild/rules_python#1212
- fix: manually ignore bazel-\* directories to make using custom Bazel
builds easier by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1181
- test(bzlmod): explicitly enable bzlmod in the test harness by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1204
- feat(bzlmod): Cleaning up interpreter resolution by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1218
- feat(bzlmod)!: Move each bzlmod extension into its own file by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1226
- Adding bzlmod support document by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1214
- test(coverage): add a test to check the sys.path under bzlmod by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1223
- fix(toolchain): set correct return attrs to remove non-hermeticity
warning by [@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1231
- fix: allow url fragments in requirements file by
[@&#8203;mattoberle](https://togithub.com/mattoberle) in
[bazelbuild/rules_python#1195
- fix: `example/build_file_generation/README.md` by
[@&#8203;ofey404](https://togithub.com/ofey404) in
[bazelbuild/rules_python#1164
- fix: Using canonical name in requirements.bzl by
[@&#8203;linzhp](https://togithub.com/linzhp) in
[bazelbuild/rules_python#1176
- feat(bzlmod): support entry_point macro by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1220

#### New Contributors

- [@&#8203;Rasrack](https://togithub.com/Rasrack) made their first
contribution in
[bazelbuild/rules_python#1124
- [@&#8203;jml-derek](https://togithub.com/jml-derek) made their first
contribution in
[bazelbuild/rules_python#1168
- [@&#8203;blorente](https://togithub.com/blorente) made their first
contribution in
[bazelbuild/rules_python#1170
- [@&#8203;yuanweixin](https://togithub.com/yuanweixin) made their first
contribution in
[bazelbuild/rules_python#1186
- [@&#8203;ofey404](https://togithub.com/ofey404) made their first
contribution in
[bazelbuild/rules_python#1164

**Full Changelog**:
bazelbuild/rules_python@0.21.0...0.22.0

###
[`v0.21.0`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.21.0)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.20.0...0.21.0)

#### Using Bzlmod with Bazel 6

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.21.0")

pip = use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

### (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@&#8203;rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@&#8203;python3_9_toolchains//:all",
)
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "94750828b18044533e98a129003b6a68001204038dc4749f40b195b24c38f49f",
    strip_prefix = "rules_python-0.21.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.21.0/rules_python-0.21.0.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "94750828b18044533e98a129003b6a68001204038dc4749f40b195b24c38f49f",
    strip_prefix = "rules_python-0.21.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.21.0/rules_python-0.21.0.tar.gz",
)

### To compile the rules_python gazelle extension from source,
### we must fetch some third-party go dependencies that it uses.

load("@&#8203;rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()
```

#### What's Changed

- cleanup: factor reexports.bzl into the respective implementation files
by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1137
- fix: bump installer to handle windows better by
[@&#8203;f0rmiga](https://togithub.com/f0rmiga) in
[bazelbuild/rules_python#1138
- build: Fixing buildifier by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1148
- docs: Updating documentation for bzlmod by
[@&#8203;chrislovecnm](https://togithub.com/chrislovecnm) in
[bazelbuild/rules_python#1149
- fix: use a consistent buildifier version for CI and pre-commit by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1151
- chore: bump buildifier to 6.1.0 by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1152
- fix: correct the labels returned by all_requirements lists by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1146
- fix: gazelle correctly adds new py_test rules by
[@&#8203;amartani](https://togithub.com/amartani) in
[bazelbuild/rules_python#1143
- fix: respect kind mapping by
[@&#8203;OniOni](https://togithub.com/OniOni) in
[bazelbuild/rules_python#1158
- test: cleanup gazelle tests and run them in parallel by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1159
- \[docs] Fixing rule name in coverage.md docs by
[@&#8203;anfelbar](https://togithub.com/anfelbar) in
[bazelbuild/rules_python#1162
- feat: Support specifying multiple download URLs in tool_versions. by
[@&#8203;quval](https://togithub.com/quval) in
[bazelbuild/rules_python#1145

#### New Contributors

- [@&#8203;amartani](https://togithub.com/amartani) made their first
contribution in
[bazelbuild/rules_python#1143
- [@&#8203;anfelbar](https://togithub.com/anfelbar) made their first
contribution in
[bazelbuild/rules_python#1162
- [@&#8203;quval](https://togithub.com/quval) made their first
contribution in
[bazelbuild/rules_python#1145

**Full Changelog**:
bazelbuild/rules_python@0.20.0...0.21.0

###
[`v0.20.0`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.20.0)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.19.0...0.20.0)

#### Using Bzlmod with Bazel 6

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.20.0")

pip = use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

### (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@&#8203;rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@&#8203;python3_9_toolchains//:all",
)
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "a644da969b6824cc87f8fe7b18101a8a6c57da5db39caa6566ec6109f37d2141",
    strip_prefix = "rules_python-0.20.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.20.0/rules_python-0.20.0.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "a644da969b6824cc87f8fe7b18101a8a6c57da5db39caa6566ec6109f37d2141",
    strip_prefix = "rules_python-0.20.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.20.0/rules_python-0.20.0.tar.gz",
)

### To compile the rules_python gazelle extension from source,
### we must fetch some third-party go dependencies that it uses.

load("@&#8203;rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()
```

#### What's Changed

- chore: fix some lingering GH archive URLs by
[@&#8203;alexeagle](https://togithub.com/alexeagle) in
[bazelbuild/rules_python#1108
- feat: add bzlmod support for gazelle plugin by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1077
- docs: Simplify pull request template by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1100
- chore: fix syntax that stardoc misunderstands as HTML by
[@&#8203;alexeagle](https://togithub.com/alexeagle) in
[bazelbuild/rules_python#1110
- fix: update gazelle to properly handle dot in package name. by
[@&#8203;OniOni](https://togithub.com/OniOni) in
[bazelbuild/rules_python#1083
- fix(bzlmod): expose ignore_root_user_error attribute from
python_register_toolchains by
[@&#8203;alexeagle](https://togithub.com/alexeagle) in
[bazelbuild/rules_python#1114
- feat: add bzl_library for defs.bzl and its dependencies by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1115
- fix: docs for ignore_root_user_error at the module level by
[@&#8203;stonier](https://togithub.com/stonier) in
[bazelbuild/rules_python#1112
- fix: generation of toolchain aliases //:defs.bzl file. by
[@&#8203;oxidase](https://togithub.com/oxidase) in
[bazelbuild/rules_python#1088
- feat: make variable substitution for py_wheel abi, python_tag args by
[@&#8203;stonier](https://togithub.com/stonier) in
[bazelbuild/rules_python#1113
- feat: add bzl_library for proto.bzl by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1116
- cleanup: Remove license comment in proto build file by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1118
- fix: restrict proto package visibility to private by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1117
- cleanup: rename proto BUILD -> BUILD.bazel by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1119
- feat: bzl file per rule/provider by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1122
- cleanup: fix typo: libraries, not libaries by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1127
- feat: add public entry point for PyCcLinkParamsInfo by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1128
- cleanup: reformat defs.bzl doc string. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1126
- fix: Include filename when parsing imports for gazelle by
[@&#8203;jlaxson](https://togithub.com/jlaxson) in
[bazelbuild/rules_python#1133

#### New Contributors

- [@&#8203;OniOni](https://togithub.com/OniOni) made their first
contribution in
[bazelbuild/rules_python#1083
- [@&#8203;stonier](https://togithub.com/stonier) made their first
contribution in
[bazelbuild/rules_python#1112

**Full Changelog**:
bazelbuild/rules_python@0.19.0...0.20.0

###
[`v0.19.0`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.19.0)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.18.1...0.19.0)

#### Using Bzlmod with Bazel 6

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.19.0")

pip = use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

### (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@&#8203;rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@&#8203;python3_9_toolchains//:all",
)
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "ffc7b877c95413c82bfd5482c017edcf759a6250d8b24e82f41f3c8b8d9e287e",
    strip_prefix = "rules_python-0.19.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.19.0/rules_python-0.19.0.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "ffc7b877c95413c82bfd5482c017edcf759a6250d8b24e82f41f3c8b8d9e287e",
    strip_prefix = "rules_python-0.19.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.19.0/rules_python-0.19.0.tar.gz",
)
```

#### What's Changed

- Making exclusions more strict by
[@&#8203;linzhp](https://togithub.com/linzhp) in
[bazelbuild/rules_python#1054
- docs: fix requirement line for runfiles example by
[@&#8203;alexeagle](https://togithub.com/alexeagle) in
[bazelbuild/rules_python#1052
- fix: make py_proto_library respect PyInfo imports by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1046
- Make toolchain acceptance tests work with latest Bazel build CI
pipeline by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1062
- Only set `py_runtime.coverage_tool` for Bazel 6 and higher. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1061
- Allow building with unreleased Bazel versions. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1063
- Extending server process timeout by
[@&#8203;linzhp](https://togithub.com/linzhp) in
[bazelbuild/rules_python#1060
- chore: regenerate gazelle_python.yaml manifest by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1066
- feat: wheel publishing by
[@&#8203;alexeagle](https://togithub.com/alexeagle) in
[bazelbuild/rules_python#1015
- fix: checked-in requirements imports generated requirements by
[@&#8203;f0rmiga](https://togithub.com/f0rmiga) in
[bazelbuild/rules_python#1053
- fix: Propagate testonly et al for wheel `.dist` targets by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1064
- fix: correctly advertise minimum supported version by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1065
- refactor: starlark reimplementation of pip_repository by
[@&#8203;aignas](https://togithub.com/aignas) in
[bazelbuild/rules_python#1043
- Add some docs about how to configure coverage. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1074
- Remove empty line between copyright and build file docstring. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1084
- cleanup: Remove license type comment; they're no longer required by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1078
- fix: Use GitHub download URL for BCR URL instead of archive URL. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1093
- Add a script to add missing license headers by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1094
- fix: Update pre-commit dependency versions so isort works. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1096
- docs: doc that the Conventional Commit style should be used for merged
commits and PRs by [@&#8203;rickeylev](https://togithub.com/rickeylev)
in
[bazelbuild/rules_python#1099
- test(core): Add analysis tests for base Python rules. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[bazelbuild/rules_python#1102

**Full Changelog**:
bazelbuild/rules_python@0.18.0...0.19.0

###
[`v0.18.1`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.18.1)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.18.0...0.18.1)

#### Using Bzlmod with Bazel 6

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.18.1")

pip = use_extension("@&#8203;rules_python//python:extensions.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

### (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@&#8203;rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@&#8203;python3_9_toolchains//:all",
)
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "29a801171f7ca190c543406f9894abf2d483c206e14d6acbd695623662320097",
    strip_prefix = "rules_python-0.18.1",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.18.1/rules_python-0.18.1.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "29a801171f7ca190c543406f9894abf2d483c206e14d6acbd695623662320097",
    strip_prefix = "rules_python-0.18.1/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.18.1/rules_python-0.18.1.tar.gz",
)
```

### Relevant Changes

- Only set `py_runtime.coverage_tool` for Bazel 6 and higher.
([#&#8203;1061](https://togithub.com/bazelbuild/rules_python/issues/1061))

**Full Changelog**:
bazelbuild/rules_python@0.18.0...0.18.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/aspect-build/rules_py).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi45Ny4xIiwidXBkYXRlZEluVmVyIjoiMzcuNDYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bzlmod bzlmod work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants