Skip to content

Commit 0a05404

Browse files
committed
chore: upgrade bzlmod example python versions
This is preparatory work for #2704
1 parent fe43548 commit 0a05404

14 files changed

Lines changed: 1391 additions & 1025 deletions

examples/bzlmod/.python_version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.9
1+
3.11

examples/bzlmod/BUILD.bazel

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
# The `load` statement imports the symbol for the rule, in the defined
44
# ruleset. When the symbol is loaded you can use the rule.
55

6-
# The names @pip and @python_39 are values that are repository
6+
# The names @pip and @python_311 are values that are repository
77
# names. Those names are defined in the MODULES.bazel file.
88
load("@bazel_skylib//rules:build_test.bzl", "build_test")
99
load("@pip//:requirements.bzl", "all_data_requirements", "all_requirements", "all_whl_requirements", "requirement")
10-
load("@python_3_9//:defs.bzl", py_test_with_transition = "py_test")
11-
load("@python_versions//3.10:defs.bzl", compile_pip_requirements_3_10 = "compile_pip_requirements")
10+
load("@python_3_11//:defs.bzl", py_test_with_transition = "py_test")
11+
load("@python_versions//3.12:defs.bzl", compile_pip_requirements_3_12 = "compile_pip_requirements")
1212
load("@rules_python//python:py_binary.bzl", "py_binary")
1313
load("@rules_python//python:py_library.bzl", "py_library")
1414
load("@rules_python//python:py_test.bzl", "py_test")
1515

1616
# This stanza calls a rule that generates targets for managing pip dependencies
1717
# with pip-compile for a particular python version.
18-
compile_pip_requirements_3_10(
19-
name = "requirements_3_10",
18+
compile_pip_requirements_3_12(
19+
name = "requirements_3_12",
2020
timeout = "moderate",
2121
src = "requirements.in",
22-
requirements_txt = "requirements_lock_3_10.txt",
23-
requirements_windows = "requirements_windows_3_10.txt",
22+
requirements_txt = "requirements_lock_3_12.txt",
23+
requirements_windows = "requirements_windows_3_12.txt",
2424
)
2525

2626
# The rules below are language specific rules defined in

examples/bzlmod/MODULE.bazel

Lines changed: 16 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ bazel_dep(name = "rules_rust", version = "0.67.0")
2727
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
2828
python.defaults(
2929
# Use python.defaults if you have defined multiple toolchain versions.
30-
python_version = "3.9",
30+
python_version = "3.11",
3131
python_version_env = "BAZEL_PYTHON_VERSION",
3232
)
3333
python.toolchain(
3434
configure_coverage_tool = True,
35-
python_version = "3.9",
35+
python_version = "3.11",
3636
)
3737

3838
# We are also using a second version of Python in this project.
@@ -42,63 +42,18 @@ python.toolchain(
4242
# work in progress.
4343
python.toolchain(
4444
configure_coverage_tool = True,
45-
python_version = "3.10",
46-
)
47-
48-
# One can override the actual toolchain versions that are available, which can be useful
49-
# when optimizing what gets downloaded and when.
50-
python.override(
51-
# NOTE: These are disabled in the example because transitive dependencies
52-
# require versions not listed here.
53-
# available_python_versions = [
54-
# "3.10.9",
55-
# "3.9.19",
56-
# # The following is used by the `other_module` and we need to include it here
57-
# # as well.
58-
# "3.11.8",
59-
# ],
60-
# Also override the `minor_mapping` so that the root module,
61-
# instead of rules_python's defaulting to the latest available version,
62-
# controls what full version is used when `3.x` is requested.
63-
minor_mapping = {
64-
"3.9": "3.9.25",
65-
},
45+
python_version = "3.12",
6646
)
67-
68-
# Or the sources that the toolchains come from for all platforms
69-
python.single_version_override(
70-
patch_strip = 1,
71-
# The user can specify patches to be applied to all interpreters.
72-
patches = [],
73-
python_version = "3.10.2",
74-
sha256 = {
75-
"aarch64-apple-darwin": "1409acd9a506e2d1d3b65c1488db4e40d8f19d09a7df099667c87a506f71c0ef",
76-
"aarch64-unknown-linux-gnu": "8f351a8cc348bb45c0f95b8634c8345ec6e749e483384188ad865b7428342703",
77-
"x86_64-apple-darwin": "8146ad4390710ec69b316a5649912df0247d35f4a42e2aa9615bffd87b3e235a",
78-
"x86_64-pc-windows-msvc": "a1d9a594cd3103baa24937ad9150c1a389544b4350e859200b3e5c036ac352bd",
79-
"x86_64-unknown-linux-gnu": "9b64eca2a94f7aff9409ad70bdaa7fbbf8148692662e764401883957943620dd",
80-
},
81-
urls = ["20220227/cpython-{python_version}+20220227-{platform}-{build}.tar.gz"],
82-
)
83-
84-
# Or a single platform. This can be used in combination with the
85-
# `single_version_override` and `single_version_platform_override` will be
86-
# applied after `single_version_override`. Any values present in this override
87-
# will overwrite the values set by the `single_version_override`
88-
python.single_version_platform_override(
89-
patch_strip = 1,
90-
patches = [],
91-
platform = "aarch64-apple-darwin",
92-
python_version = "3.10.2",
93-
sha256 = "1409acd9a506e2d1d3b65c1488db4e40d8f19d09a7df099667c87a506f71c0ef",
94-
urls = ["20220227/cpython-{python_version}+20220227-{platform}-{build}.tar.gz"],
47+
python.toolchain(
48+
configure_coverage_tool = True,
49+
python_version = "3.13",
9550
)
9651

9752
# You only need to load this repositories if you are using multiple Python versions.
9853
# See the tests folder for various examples on using multiple Python versions.
99-
# The names "python_3_9" and "python_3_10" are autmatically created by the repo
54+
# The names "python_3_11", "python_3_12" and "python_3_13" are automatically created by the repo
10055
# rules based on the `python_version` arg values.
101-
use_repo(python, "python_3_10", "python_3_9", "python_versions", "pythons_hub")
56+
use_repo(python, "python_3_11", "python_3_12", "python_3_13", "python_versions", "pythons_hub")
10257

10358
# EXPERIMENTAL: This is experimental and may be changed or removed without notice
10459
uv = use_extension(
@@ -207,8 +162,8 @@ pip.parse(
207162
"--index-url=${PIP_INDEX_URL:-https://pypi.org/simple}",
208163
],
209164
hub_name = "pip",
210-
python_version = "3.9",
211-
requirements_lock = "requirements_lock_3_9.txt",
165+
python_version = "3.11",
166+
requirements_lock = "requirements_lock_3_11.txt",
212167
# These modifications were created above and we
213168
# are providing pip.parse with the label of the mod
214169
# and the name of the wheel.
@@ -229,12 +184,12 @@ pip.parse(
229184
],
230185
},
231186
hub_name = "pip",
232-
python_version = "3.10",
187+
python_version = "3.12",
233188
# The requirements files for each platform that we want to support.
234189
requirements_by_platform = {
235190
# Default requirements file for needs to explicitly provide the platforms
236-
"//:requirements_lock_3_10.txt": "linux_*,osx_*",
237-
"//:requirements_windows_3_10.txt": "windows_x86_64",
191+
"//:requirements_lock_3_12.txt": "linux_*,osx_*",
192+
"//:requirements_windows_3_12.txt": "windows_x86_64",
238193
},
239194
# These modifications were created above and we
240195
# are providing pip.parse with the label of the mod
@@ -246,16 +201,16 @@ pip.parse(
246201
)
247202
pip.parse(
248203
hub_name = "pip",
249-
python_version = "3.11",
204+
python_version = "3.13",
250205
requirements_by_platform = {
251206
# Default requirements file for needs to explicitly provide the platforms
252-
"//:requirements_lock_3_11.txt": "linux_*,osx_*",
207+
"//:requirements_lock_3_13.txt": "linux_*,osx_*",
253208
# This API allows one to specify additional platforms that the users
254209
# configure the toolchains for themselves. In this example we add
255210
# `windows_aarch64` to illustrate that `rules_python` won't fail to
256211
# process the value, but it does not mean that this example will work
257212
# on Windows ARM.
258-
"//:requirements_windows_3_11.txt": "windows_x86_64,windows_aarch64",
213+
"//:requirements_windows_3_13.txt": "windows_x86_64,windows_aarch64",
259214
},
260215
# These modifications were created above and we
261216
# are providing pip.parse with the label of the mod

examples/bzlmod/entry_points/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ py_console_script_binary(
2424
)
2525

2626
# A specific Python version can be forced by passing `python_version`
27-
# attribute, e.g. to force Python 3.9:
27+
# attribute, e.g. to force Python 3.11:
2828
py_console_script_binary(
2929
name = "yamllint",
3030
pkg = "@pip//yamllint:pkg",
31-
python_version = "3.9",
31+
python_version = "3.11",
3232
visibility = ["//entry_points:__subpackages__"],
3333
)

examples/bzlmod/other_module/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ load("@rules_python//python:pip.bzl", "compile_pip_requirements")
55
compile_pip_requirements(
66
name = "requirements",
77
src = "requirements.in",
8-
python_version = "3.11",
9-
requirements_txt = "requirements_lock_3_11.txt",
8+
python_version = "3.12",
9+
requirements_txt = "requirements_lock_3_12.txt",
1010
)

examples/bzlmod/other_module/MODULE.bazel

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ local_path_override(
1313
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
1414
python.defaults(
1515
# In a submodule this is ignored
16-
python_version = "3.11",
16+
python_version = "3.12",
1717
)
1818
python.toolchain(
1919
configure_coverage_tool = True,
20-
python_version = "3.12",
20+
python_version = "3.13",
2121
)
2222
python.toolchain(
2323
configure_coverage_tool = True,
24-
python_version = "3.11",
24+
python_version = "3.12",
2525
)
2626

2727
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
@@ -32,7 +32,7 @@ pip.parse(
3232
# This is testing that a sub-module can use pip.parse() and only specify
3333
# Python versions that DON'T include whatever the root-module's default
3434
# Python version is.
35-
python_version = "3.11",
36-
requirements_lock = ":requirements_lock_3_11.txt",
35+
python_version = "3.12",
36+
requirements_lock = ":requirements_lock_3_12.txt",
3737
)
3838
use_repo(pip, "other_module_pip")

examples/bzlmod/other_module/requirements_lock_3_11.txt renamed to examples/bzlmod/other_module/requirements_lock_3_12.txt

File renamed without changes.

0 commit comments

Comments
 (0)