Skip to content

Commit 21e7790

Browse files
committed
Merge remote-tracking branch 'upstream/main' into remove-cc-defs
2 parents e5c9230 + 7010148 commit 21e7790

File tree

105 files changed

+6220
-3391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+6220
-3391
lines changed

.bazelci/presubmit.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,6 @@ buildifier:
6565
.reusable_build_test_all: &reusable_build_test_all
6666
build_targets: ["..."]
6767
test_targets: ["..."]
68-
.lockfile_mode_error: &lockfile_mode_error
69-
# For testing lockfile support
70-
skip_in_bazel_downstream_pipeline: "Lockfile depends on the bazel version"
71-
build_flags:
72-
- "--lockfile_mode=error"
73-
test_flags:
74-
- "--lockfile_mode=error"
75-
coverage_flags:
76-
- "--lockfile_mode=error"
7768
.coverage_targets_example_bzlmod: &coverage_targets_example_bzlmod
7869
coverage_targets: ["..."]
7970
.coverage_targets_example_bzlmod_build_file_generation: &coverage_targets_example_bzlmod_build_file_generation
@@ -94,6 +85,8 @@ buildifier:
9485
bazel: "7.x"
9586
environment:
9687
RULES_PYTHON_ENABLE_PYSTAR: "1"
88+
build_flags:
89+
- "--config=bazel7.x"
9790
test_flags:
9891
# The doc check tests fail because the Starlark implementation makes the
9992
# PyInfo and PyRuntimeInfo symbols become documented.
@@ -266,17 +259,23 @@ tasks:
266259
integration_test_bzlmod_ubuntu_lockfile:
267260
<<: *reusable_build_test_all
268261
<<: *coverage_targets_example_bzlmod
269-
<<: *lockfile_mode_error
270262
name: "examples/bzlmod: Ubuntu with lockfile"
271263
working_directory: examples/bzlmod
272264
platform: ubuntu2004
265+
shell_commands:
266+
# Update the lockfiles and fail if it is different.
267+
- "../../tools/private/update_bzlmod_lockfiles.sh"
268+
- "git diff --exit-code"
273269
integration_test_bzlmod_macos_lockfile:
274270
<<: *reusable_build_test_all
275271
<<: *coverage_targets_example_bzlmod
276-
<<: *lockfile_mode_error
277272
name: "examples/bzlmod: macOS with lockfile"
278273
working_directory: examples/bzlmod
279274
platform: macos
275+
shell_commands:
276+
# Update the lockfiles and fail if it is different.
277+
- "../../tools/private/update_bzlmod_lockfiles.sh"
278+
- "git diff --exit-code"
280279

281280
integration_test_bzlmod_generate_build_file_generation_ubuntu_min:
282281
<<: *minimum_supported_version
@@ -302,7 +301,7 @@ tasks:
302301
integration_test_bzlmod_build_file_generation_debian:
303302
<<: *reusable_build_test_all
304303
<<: *coverage_targets_example_bzlmod_build_file_generation
305-
name: "examples/bzlmod_build_file_integration: Debian"
304+
name: "examples/bzlmod_build_file_generation: Debian"
306305
working_directory: examples/bzlmod_build_file_generation
307306
platform: debian11
308307
integration_test_bzlmod_build_file_generation_macos:

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ build:rtd --stamp
3333
# Some bzl files contain repos only available under bzlmod
3434
build:rtd --enable_bzlmod
3535

36+
common:bazel7.x --incompatible_python_disallow_native_rules
37+
3638
build --lockfile_mode=update

.bcr/metadata.template.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
"name": "Thulio Ferraz Assis",
1111
"email": "thulio@aspect.dev",
1212
"github": "f0rmiga"
13+
},
14+
{
15+
"name": "Ignas Anikevicius",
16+
"email": "bcr-ignas@use.startmail.com",
17+
"github": "aignas"
1318
}
1419
],
1520
"repository": [

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
python/features.bzl export-subst
12
tools/publish/*.txt linguist-generated=true

.github/workflows/create_archive_and_notes.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
2525
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
2626

2727
cat > release_notes.txt << EOF
28-
## Using Bzlmod with Bazel 6
2928
30-
**NOTE: bzlmod support is still beta. APIs subject to change.**
29+
For more detailed setup instructions, see https://rules-python.readthedocs.io/en/latest/getting-started.html
30+
31+
## Using Bzlmod
3132
3233
Add to your \`MODULE.bazel\` file:
3334

CHANGELOG.md

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,101 @@ A brief description of the categories of changes:
2727

2828
{#v0-0-0-changed}
2929
### Changed
30-
- Nothing yet
30+
* (deps) bazel_skylib 1.6.1 -> 1.7.1
3131

3232
{#v0-0-0-fixed}
3333
### Fixed
34-
- Nothing yet
34+
* Nothing yet
3535

3636
{#v0-0-0-added}
3737
### Added
38-
- Nothing yet
38+
* Nothing yet
3939

4040
{#v0-0-0-removed}
4141
### Removed
42-
- Nothing yet
42+
* Nothing yet
43+
44+
{#v0-38-0}
45+
## [0.38.0] - 2024-11-08
46+
47+
[0.38.0]: https://github.com/bazelbuild/rules_python/releases/tag/0.38.0
48+
49+
{#v0-38-0-changed}
50+
### Changed
51+
* (deps) (WORKSPACE only) rules_cc 0.0.13 and protobuf 27.0 is now the default
52+
version used; this for Bazel 8+ support (previously version was rules_cc 0.0.9
53+
and no protobuf version specified)
54+
([2310](https://github.com/bazelbuild/rules_python/issues/2310)).
55+
* (publish) The dependencies have been updated to the latest available versions
56+
for the `twine` publishing rule.
57+
* (whl_library) Remove `--no-build-isolation` to allow non-hermetic sdist builds
58+
by default. Users wishing to keep this argument and to enforce more hermetic
59+
builds can do so by passing the argument in
60+
[`pip.parse#extra_pip_args`](https://rules-python.readthedocs.io/en/latest/api/rules_python/python/extensions/pip.html#pip.parse.extra_pip_args)
61+
* (pip.parse) {attr}`pip.parse.whl_modifications` now normalizes the given whl names
62+
and now `pyyaml` and `PyYAML` will both work.
63+
* (bzlmod) `pip.parse` spoke repository naming will be changed in an upcoming
64+
release in places where the users specify different package versions per
65+
platform in the same hub repository. The naming of the spoke repos is
66+
considered an implementation detail and we advise the users to use the `hub`
67+
repository directly and make use of {bzl:obj}`pip.parse.extra_hub_aliases`
68+
feature added in this release.
69+
70+
{#v0-38-0-fixed}
71+
### Fixed
72+
* (pypi) (Bazel 7.4+) Allow spaces in filenames included in `whl_library`s
73+
([617](https://github.com/bazelbuild/rules_python/issues/617)).
74+
* (pypi) When {attr}`pip.parse.experimental_index_url` is set, we need to still
75+
pass the `extra_pip_args` value when building an `sdist`.
76+
* (pypi) The patched wheel filenames from now on are using local version specifiers
77+
which fixes usage of the said wheels using standard package managers.
78+
* (bzlmod) The extension evaluation has been adjusted to always generate the
79+
same lock file irrespective if `experimental_index_url` is set by any module
80+
or not. To opt into this behavior, set
81+
{bzl:obj}`pip.parse.parse_all_requirements_files`, which will become the
82+
default in future releases leading up to `1.0.0`. Fixes
83+
[#2268](https://github.com/bazelbuild/rules_python/issues/2268). A known
84+
issue is that it may break `bazel query` and in these use cases it is
85+
advisable to use `cquery` or switch to `download_only = True`
86+
87+
{#v0-38-0-added}
88+
### Added
89+
* (publish) The requirements file for the `twine` publishing rules have been
90+
updated to have a new convention: `requirements_darwin.txt`,
91+
`requirements_linux.txt`, `requirements_windows.txt` for each respective OS
92+
and one extra file `requirements_universal.txt` if you prefer a single file.
93+
The `requirements.txt` file may be removed in the future.
94+
* The rules_python version is now reported in `//python/features.bzl#features.version`
95+
* (pip.parse) {attr}`pip.parse.extra_hub_aliases` can now be used to expose extra
96+
targets created by annotations in whl repositories.
97+
Fixes [#2187](https://github.com/bazelbuild/rules_python/issues/2187).
98+
* (bzlmod) `pip.parse` now supports `whl-only` setup using
99+
`download_only = True` where users can specify multiple requirements files
100+
and use the `pip` backend to do the downloading. This was only available for
101+
users setting {bzl:obj}`pip.parse.experimental_index_url`, but now users have
102+
more options whilst we continue to work on stabilizing the experimental feature.
103+
104+
{#v0-37-2}
105+
## [0.37.2] - 2024-10-27
106+
107+
[0.37.2]: https://github.com/bazelbuild/rules_python/releases/tag/0.37.2
108+
109+
{#v0-37-2-fixed}
110+
### Fixed
111+
* (bzlmod) Generate `config_setting` values for all available toolchains instead
112+
of only the registered toolchains, which restores the previous behaviour that
113+
`bzlmod` users would have observed.
114+
115+
{#v0-37-1}
116+
## [0.37.1] - 2024-10-22
117+
118+
[0.37.1]: https://github.com/bazelbuild/rules_python/releases/tag/0.37.1
119+
120+
{#v0-37-1-fixed}
121+
### Fixed
122+
* (rules) Setting `--incompatible_python_disallow_native_rules` no longer
123+
causes rules_python rules to fail
124+
([#2326](https://github.com/bazelbuild/rules_python/issues/2326)).
43125

44126
{#v0-37-0}
45127
## [0.37.0] - 2024-10-18

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ and setup. Subsequent runs will be faster, but there are many tests, and some of
6565
them are slow. If you're working on a particular area of code, you can run just
6666
the tests in those directories instead, which can speed up your edit-run cycle.
6767

68+
## Updating tool dependencies
69+
70+
It's suggested to routinely update the tool versions within our repo - some of the
71+
tools are using requirement files compiled by `uv` and others use other means. In order
72+
to have everything self-documented, we have a special target -
73+
`//private:requirements.update`, which uses `rules_multirun` to run in sequence all
74+
of the requirement updating scripts in one go. This can be done once per release as
75+
we prepare for releases.
76+
6877
## Formatting
6978

7079
Starlark files should be formatted by

DEVELOPING.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
1. Modify the `./python/private/pypi/requirements.txt` file and run:
66
```
7-
bazel run //tools/private/update_deps:update_pip_deps
7+
bazel run //private:whl_library_requirements.update
8+
```
9+
1. Run the following target to update `twine` dependencies:
10+
```
11+
bazel run //private:requirements.update
812
```
913
1. Bump the coverage dependencies using the script using:
1014
```
@@ -20,6 +24,8 @@ Start from a clean checkout at `main`.
2024
Before running through the release it's good to run the build and the tests locally, and make sure CI is passing. You can
2125
also test-drive the commit in an existing Bazel workspace to sanity check functionality.
2226

27+
### Releasing from HEAD
28+
2329
#### Steps
2430
1. [Determine the next semantic version number](#determining-semantic-version)
2531
1. Create a tag and push, e.g. `git tag 0.5.0 upstream/main && git push upstream --tags`
@@ -38,9 +44,31 @@ To find if there were any features added or incompatible changes made, review
3844
the commit history. This can be done using github by going to the url:
3945
`https://github.com/bazelbuild/rules_python/compare/<VERSION>...main`.
4046

47+
### Patch release with cherry picks
48+
49+
If a patch release from head would contain changes that aren't appropriate for
50+
a patch release, then the patch release needs to be based on the original
51+
release tag and the patch changes cherry-picked into it.
52+
53+
In this example, release `0.37.0` is being patched to create release `0.37.1`.
54+
The fix being included is commit `deadbeef`.
55+
56+
1. `git checkout -b release/0.37 0.37.0`
57+
1. `git push upstream release/0.37`
58+
1. `git cherry-pick -x deadbeef`
59+
1. Fix merge conflicts, if any. If `MODULE.bazel.lock` conflicts occur, then
60+
run `pre-commit run update-bzlmod-lockfiles -a`
61+
1. `git cherry-pick --continue` (if applicable)
62+
1. `git push upstream`
63+
64+
If multiple commits need to be applied, repeat the `git cherry-pick` step for
65+
each.
66+
67+
Once the release branch is in the desired state, use `git tag` to tag it, as
68+
done with a release from head. Release automation will do the rest.
69+
4170
#### After release creation in Github
4271

43-
1. Ping @philwo to get the new release added to mirror.bazel.build. See [this comment on issue #400](https://github.com/bazelbuild/rules_python/issues/400#issuecomment-779159530) for more context.
4472
1. Announce the release in the #python channel in the Bazel slack (bazelbuild.slack.com).
4573

4674
## Secrets

MODULE.bazel

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module(
55
)
66

77
bazel_dep(name = "bazel_features", version = "1.9.1")
8-
bazel_dep(name = "bazel_skylib", version = "1.6.1")
8+
bazel_dep(name = "bazel_skylib", version = "1.7.1")
99
bazel_dep(name = "rules_cc", version = "0.0.13")
1010
bazel_dep(name = "platforms", version = "0.0.4")
1111

@@ -56,11 +56,15 @@ register_toolchains("@pythons_hub//:all")
5656

5757
pip = use_extension("//python/private/pypi:pip.bzl", "pip_internal")
5858
pip.parse(
59+
# NOTE @aignas 2024-10-26: We have an integration test that depends on us
60+
# being able to build sdists for this hub, so explicitly set this to False.
61+
download_only = False,
62+
experimental_index_url = "https://pypi.org/simple",
5963
hub_name = "rules_python_publish_deps",
6064
python_version = "3.11",
6165
requirements_by_platform = {
62-
"//tools/publish:requirements.txt": "linux_*",
6366
"//tools/publish:requirements_darwin.txt": "osx_*",
67+
"//tools/publish:requirements_linux.txt": "linux_*",
6468
"//tools/publish:requirements_windows.txt": "windows_*",
6569
},
6670
)
@@ -70,14 +74,31 @@ use_repo(pip, "rules_python_publish_deps")
7074
bazel_dep(name = "stardoc", version = "0.6.2", repo_name = "io_bazel_stardoc")
7175

7276
# ===== DEV ONLY DEPS AND SETUP BELOW HERE =====
73-
bazel_dep(name = "rules_bazel_integration_test", version = "0.20.0", dev_dependency = True)
77+
bazel_dep(name = "rules_bazel_integration_test", version = "0.26.1", dev_dependency = True)
7478
bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True)
75-
bazel_dep(name = "rules_shell", version = "0.2.0", dev_dependency = True)
79+
bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True)
80+
bazel_dep(name = "rules_multirun", version = "0.9.0", dev_dependency = True)
81+
bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True)
7682

7783
# Extra gazelle plugin deps so that WORKSPACE.bzlmod can continue including it for e2e tests.
7884
# We use `WORKSPACE.bzlmod` because it is impossible to have dev-only local overrides.
7985
bazel_dep(name = "rules_go", version = "0.41.0", dev_dependency = True, repo_name = "io_bazel_rules_go")
8086
bazel_dep(name = "gazelle", version = "0.33.0", dev_dependency = True, repo_name = "bazel_gazelle")
87+
bazel_dep(name = "rules_python_gazelle_plugin", version = "0", dev_dependency = True)
88+
89+
internal_dev_deps = use_extension(
90+
"//python/private:internal_dev_deps.bzl",
91+
"internal_dev_deps",
92+
dev_dependency = True,
93+
)
94+
use_repo(internal_dev_deps, "buildkite_config", "wheel_for_testing")
95+
96+
# Add gazelle plugin so that we can run the gazelle example as an e2e integration
97+
# test and include the distribution files.
98+
local_path_override(
99+
module_name = "rules_python_gazelle_plugin",
100+
path = "gazelle",
101+
)
81102

82103
dev_python = use_extension(
83104
"//python/extensions:python.bzl",
@@ -89,17 +110,20 @@ dev_python.override(
89110
)
90111

91112
dev_pip = use_extension(
92-
"//python/private/pypi:pip.bzl",
93-
"pip_internal",
113+
"//python/extensions:pip.bzl",
114+
"pip",
94115
dev_dependency = True,
95116
)
96117
dev_pip.parse(
97-
download_only = True, # this will not add the `sdist` values to the transitive closures at all.
118+
download_only = True,
119+
experimental_index_url = "https://pypi.org/simple",
98120
hub_name = "dev_pip",
99121
python_version = "3.11",
100122
requirements_lock = "//docs:requirements.txt",
101123
)
102124
dev_pip.parse(
125+
download_only = True,
126+
experimental_index_url = "https://pypi.org/simple",
103127
hub_name = "pypiserver",
104128
python_version = "3.11",
105129
requirements_lock = "//examples/wheel:requirements_server.txt",
@@ -140,7 +164,7 @@ uv = use_extension(
140164
"uv",
141165
dev_dependency = True,
142166
)
143-
uv.toolchain(uv_version = "0.2.23")
167+
uv.toolchain(uv_version = "0.4.25")
144168
use_repo(uv, "uv_toolchains")
145169

146170
register_toolchains(

0 commit comments

Comments
 (0)