Drop Python 3.9 support

Python 3.9 reached its official End-of-Life (EOL) on October 31, 2025
https://devguide.python.org/versions/

PiperOrigin-RevId: 854341311
This commit is contained in:
Jie Luo 2026-01-09 14:18:02 -08:00 committed by Copybara-Service
parent 0262bd688a
commit bbc9dd9e8a
10 changed files with 26 additions and 107 deletions

View file

@ -5,7 +5,6 @@
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd
load("@bazel_skylib//lib:selects.bzl", "selects")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
load("//python:build_targets.bzl", "build_targets")
load("//python:py_extension.bzl", "py_extension")
@ -21,7 +20,6 @@ package(
)
LIMITED_API_FLAG_SELECT = {
":limited_api_3.9": ["-DPy_LIMITED_API=0x03090000"],
":limited_api_3.10": ["-DPy_LIMITED_API=0x030a0000"],
"//conditions:default": [],
}
@ -43,39 +41,13 @@ string_flag(
)
config_setting(
name = "limited_api_3.9",
name = "limited_api_3.10",
flag_values = {
":limited_api": "True",
":python_version": "39",
":python_version": "310",
},
)
config_setting(
name = "full_api_3.9_win32",
flag_values = {
":limited_api": "False",
":python_version": "39",
},
values = {"cpu": "win32"},
)
config_setting(
name = "full_api_3.9_win64",
flag_values = {
":limited_api": "False",
":python_version": "39",
},
values = {"cpu": "win64"},
)
selects.config_setting_group(
name = "full_api_3.9",
match_any = [
"full_api_3.9_win32",
":full_api_3.9_win64",
],
)
config_setting(
name = "limited_api_3.10_win32",
flag_values = {
@ -94,14 +66,6 @@ config_setting(
values = {"cpu": "win64"},
)
selects.config_setting_group(
name = "limited_api_3.10",
match_any = [
":limited_api_3.10_win32",
":limited_api_3.10_win64",
],
)
_message_target_compatible_with = {
"@platforms//os:windows": ["@platforms//:incompatible"],
"@system_python//:none": ["@platforms//:incompatible"],

View file

@ -328,7 +328,6 @@ genrule(
py_wheel(
name = "binary_wheel",
abi = select({
"//python:full_api_3.9": "cp39",
"//conditions:default": "abi3",
}),
author = "protobuf@googlegroups.com",
@ -336,7 +335,6 @@ py_wheel(
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
@ -362,15 +360,13 @@ py_wheel(
":windows_x86_64": "win_amd64",
"//conditions:default": "any",
}),
python_requires = ">=3.9",
python_requires = ">=3.10",
# LINT.IfChange(python_tag)
python_tag = selects.with_or({
("//python:limited_api_3.9", "//python:full_api_3.9"): "cp39",
"//python:limited_api_3.10": "cp310",
"//conditions:default": "cp" + SYSTEM_PYTHON_VERSION,
}),
# LINT.ThenChange(
# :full_api_version,
# :limited_api_wheels,
# )
strip_path_prefixes = [
@ -399,7 +395,6 @@ py_wheel(
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
@ -413,7 +408,7 @@ py_wheel(
homepage = "https://developers.google.com/protocol-buffers/",
license = "3-Clause BSD License",
platform = "any",
python_requires = ">=3.9",
python_requires = ">=3.10",
python_tag = "py3",
strip_path_prefixes = [
"python/",
@ -466,12 +461,6 @@ py_dist(
"win32",
"win64",
],
# Windows needs version-specific wheels until 3.10.
# LINT.IfChange(full_api_version)
full_api_versions = [
"39",
],
# LINT.ThenChange(:python_tag)
# Limited API: these wheels will satisfy any Python version >= the
# given version.
#
@ -482,10 +471,10 @@ py_dist(
limited_api_wheels = {
"win32": "310",
"win64": "310",
"linux-x86_64": "39",
"linux-aarch_64": "39",
"linux-s390_64": "39",
"osx-universal2": "39",
"linux-x86_64": "310",
"linux-aarch_64": "310",
"linux-s390_64": "310",
"osx-universal2": "310",
},
# LINT.ThenChange(:python_tag)
pure_python_wheel = ":pure_python_wheel",

View file

@ -71,7 +71,6 @@ setup(
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
@ -89,5 +88,5 @@ setup(
extra_link_args=extra_link_args,
)
],
python_requires='>=3.9',
python_requires='>=3.10',
)

View file

@ -268,7 +268,7 @@ system_python = repository_rule(
implementation = _system_python_impl,
local = True,
attrs = {
"minimum_python_version": attr.string(default = "3.9"),
"minimum_python_version": attr.string(default = "3.10"),
},
)

View file

@ -30,7 +30,6 @@ setup(
# These Python versions should match the protobuf package:
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',

View file

@ -28,9 +28,7 @@ def py_extension(name, srcs, copts, deps = [], **kwargs):
linkshared = True,
linkstatic = True,
deps = deps + select({
"//python:limited_api_3.9": ["@python-3.9.0//:python_headers"],
"//python:full_api_3.9_win32": ["@nuget_python_i686_3.9.0//:python_full_api"],
"//python:full_api_3.9_win64": ["@nuget_python_x86-64_3.9.0//:python_full_api"],
"//python:limited_api_3.10": ["@python-3.10.0//:python_headers"],
"//python:limited_api_3.10_win32": ["@nuget_python_i686_3.10.0//:python_limited_api"],
"//python:limited_api_3.10_win64": ["@nuget_python_x86-64_3.10.0//:python_limited_api"],
"//conditions:default": ["@system_python//:python_headers"],