Skip to content

Commit 9b73d02

Browse files
authored
chore(pip_parse, gazelle): generate/use hub repo aliases by default (#1525)
This makes `pip_parse.incompatible_generate_aliases = True` the default. This only affects workspace builds; it is already the default for bzlmod. Summary: - Enable the generation of aliases in `pip_repository`. - Flip usage of aliases in `gazelle`. - Remove usage of the old flags from the example code. - Update the `gazelle` manifest generator to leave the `gazelle_python.yaml` manifest unchanged for people who have `use_pip_repository_aliases = True` in their `BUILD.bazel` files. Once they remove the flag, the `gazelle_python.yaml` will be updated. - Update `multi_pip_parse` to handle sub-hub repositories where the `all_requirements` returns aliased targets. Fixes #1498
1 parent 2a074f8 commit 9b73d02

File tree

30 files changed

+124
-663
lines changed

30 files changed

+124
-663
lines changed

CHANGELOG.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,24 @@ A brief description of the categories of changes:
2525
as all of the publicly available symbols (etc. `package_annotation`) are
2626
re-exported via `//python:pip_bzl` `bzl_library`.
2727

28-
* Gazelle Python extension no longer has runtime dependencies. Using
28+
* (gazelle) Gazelle Python extension no longer has runtime dependencies. Using
2929
`GAZELLE_PYTHON_RUNTIME_DEPS` from `@rules_python_gazelle_plugin//:def.bzl` is
3030
no longer necessary.
3131

32-
* The installation of `pip_parse` repository rule toolchain dependencies is now
33-
done as part of `py_repositories` call.
32+
* (pip_parse) The installation of `pip_parse` repository rule toolchain
33+
dependencies is now done as part of `py_repositories` call.
34+
35+
* (pip_parse) The flag `incompatible_generate_aliases` has been flipped to
36+
`True` by default on `non-bzlmod` setups allowing users to use the same label
37+
strings during the transition period. For example, instead of
38+
`@pypi_foo//:pkg`, you can now use `@pypi//foo` or `@pypi//foo:pkg`. Other
39+
labels that are present in the `foo` package are `dist_info`, `whl` and
40+
`data`. Note, that the `@pypi_foo//:pkg` labels are still present for
41+
backwards compatibility.
42+
43+
* (gazelle) The flag `use_pip_repository_aliases` is now set to `True` by
44+
default, which will cause `gazelle` to change third-party dependency labels
45+
from `@pip_foo//:pkg` to `@pip//foo` by default.
3446

3547
Breaking changes:
3648

examples/build_file_generation/BUILD.bazel

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ gazelle_python_manifest(
4343
# NOTE: We can pass a list just like in `bzlmod_build_file_generation` example
4444
# but we keep a single target here for regression testing.
4545
requirements = "//:requirements_lock.txt",
46-
# NOTE: we can use this flag in order to make our setup compatible with
47-
# bzlmod.
48-
use_pip_repository_aliases = True,
4946
)
5047

5148
# Our gazelle target points to the python gazelle binary.

examples/build_file_generation/WORKSPACE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ load("@rules_python//python:pip.bzl", "pip_parse")
9494
# You can instead check this `requirements.bzl` file into your repo.
9595
pip_parse(
9696
name = "pip",
97-
# Generate user friendly alias labels for each dependency that we have.
98-
incompatible_generate_aliases = True,
9997
# (Optional) You can provide a python_interpreter (path) or a python_interpreter_target (a Bazel target, that
10098
# acts as an executable). The latter can be anything that could be used as Python interpreter. E.g.:
10199
# 1. Python interpreter that you compile in the build file.

examples/build_file_generation/gazelle_python.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,4 @@ manifest:
114114
zipp.py310compat: zipp
115115
pip_repository:
116116
name: pip
117-
use_pip_repository_aliases: true
118-
integrity: 030d6d99b56c32d6577e616b617260d0a93588af791269162e43391a5a4fa576
117+
integrity: a88d99bf5ea018bdb052ccda8ea5c98b6bae81312a338f909532285b76026fe1

0 commit comments

Comments
 (0)