Skip to content

Commit c613770

Browse files
committed
chore(examples): update bzlmod example to use Python 3.11 minimum version
1 parent 6d3c587 commit c613770

5 files changed

Lines changed: 405 additions & 483 deletions

File tree

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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
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: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,19 @@ 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.
3939
# Typically you will only need a single version of Python, but
4040
# If you need a different vesion we support more than one.
4141
# Note: we do not supporting using multiple pip extensions, this is
4242
# work in progress.
43-
python.toolchain(
44-
configure_coverage_tool = True,
45-
python_version = "3.10",
46-
)
47-
48-
# Adding Python 3.12 version for testing
4943
python.toolchain(
5044
configure_coverage_tool = True,
5145
python_version = "3.12",
@@ -57,24 +51,13 @@ python.toolchain(
5751
python_version = "3.13",
5852
)
5953

60-
# One can override the actual toolchain versions that are available, which can be useful
61-
# when optimizing what gets downloaded and when.
54+
# One can override the actual toolchain versions that are available
6255
python.override(
63-
# NOTE: These are disabled in the example because transitive dependencies
64-
# require versions not listed here.
6556
# available_python_versions = [
66-
# "3.10.9",
67-
# "3.9.19",
68-
# # The following is used by the `other_module` and we need to include it here
69-
# # as well.
70-
# "3.11.8",
57+
# "3.12.9",
58+
# "3.11.19",
59+
# "3.13.4",
7160
# ],
72-
# Also override the `minor_mapping` so that the root module,
73-
# instead of rules_python's defaulting to the latest available version,
74-
# controls what full version is used when `3.x` is requested.
75-
minor_mapping = {
76-
"3.9": "3.9.25",
77-
},
7861
)
7962

8063
# Or the sources that the toolchains come from for all platforms
@@ -110,7 +93,7 @@ python.single_version_platform_override(
11093
# See the tests folder for various examples on using multiple Python versions.
11194
# The names "python_3_9" and "python_3_10" are autmatically created by the repo
11295
# rules based on the `python_version` arg values.
113-
use_repo(python, "python_3_10", "python_3_12", "python_3_13", "python_3_9", "python_versions", "pythons_hub")
96+
use_repo(python, "python_3_11", "python_3_12", "python_3_13", "python_versions", "pythons_hub")
11497

11598
# EXPERIMENTAL: This is experimental and may be changed or removed without notice
11699
uv = use_extension(
@@ -219,7 +202,7 @@ pip.parse(
219202
"--index-url=${PIP_INDEX_URL:-https://pypi.org/simple}",
220203
],
221204
hub_name = "pip",
222-
python_version = "3.9",
205+
python_version = "3.11",
223206
requirements_lock = "requirements_lock_3_9.txt",
224207
# These modifications were created above and we
225208
# are providing pip.parse with the label of the mod
@@ -241,7 +224,7 @@ pip.parse(
241224
],
242225
},
243226
hub_name = "pip",
244-
python_version = "3.10",
227+
python_version = "3.12",
245228
# The requirements files for each platform that we want to support.
246229
requirements_by_platform = {
247230
# Default requirements file for needs to explicitly provide the platforms

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
)

0 commit comments

Comments
 (0)