diff --git a/MODULE.bazel b/MODULE.bazel index 027277ab64..931fabe626 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -47,14 +47,14 @@ python = use_extension("//python/extensions:python.bzl", "python") # NOTE: There must be a corresponding `python.toolchain()` call for the version # specified here. python.defaults( - python_version = "3.11", + python_version = "3.14", ) python.toolchain( - python_version = "3.11", + python_version = "3.14", ) use_repo( python, - "python_3_11", + "python_3_14", "pythons_hub", python = "python_versions", ) @@ -68,7 +68,7 @@ register_toolchains("@pythons_hub//:all") pip = use_extension("//python/extensions:pip.bzl", "pip") pip.parse( hub_name = "rules_python_publish_deps", - python_version = "3.11", + python_version = "3.14", requirements_by_platform = { "//tools/publish:requirements_darwin.txt": "osx_*", "//tools/publish:requirements_linux.txt": "linux_*", @@ -215,17 +215,17 @@ dev_pip = use_extension( dev_pip.parse( download_only = True, hub_name = "pypiserver", - python_version = "3.11", + python_version = "3.14", requirements_lock = "//examples/wheel:requirements_server.txt", ) dev_pip.parse( hub_name = "pypi_alpha", - python_version = "3.11", + python_version = "3.14", requirements_lock = "//tests/multi_pypi/alpha:requirements.txt", ) dev_pip.parse( hub_name = "pypi_beta", - python_version = "3.11", + python_version = "3.14", requirements_lock = "//tests/multi_pypi/beta:requirements.txt", ) use_repo(dev_pip, "dev_pip", "pypi", "pypi_alpha", "pypi_beta", "pypiserver") diff --git a/WORKSPACE b/WORKSPACE index a692f1b289..46b26b8a9a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -72,7 +72,7 @@ py_repositories() python_register_multi_toolchains( name = "python", - default_version = "3.11", + default_version = "3.14", # Integration tests verify each version, so register all of them. python_versions = PYTHON_VERSIONS, ) @@ -112,7 +112,7 @@ load("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps _py_gazelle_deps() # This interpreter is used for various rules_python dev-time tools -interpreter = "@python_3_11_9_host//:python" +interpreter = "@python_3_14_4_host//:python" ##################### # Install twine for our own runfiles wheel publishing. diff --git a/docs/getting-started.md b/docs/getting-started.md index 6494b37c51..4de87d02ed 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -26,7 +26,7 @@ bazel_dep(name = "rules_python", version = "0.0.0") pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") pip.parse( hub_name = "pypi", - python_version = "3.11", + python_version = "3.14", requirements_lock = "//:requirements.txt", ) use_repo(pip, "pypi") @@ -57,17 +57,17 @@ py_repositories() load("@rules_python//python:repositories.bzl", "python_register_toolchains") python_register_toolchains( - name = "python_3_11", + name = "python_3_14", # Available versions are listed in @rules_python//python:versions.bzl. # We recommend using the same version your team is already standardized on. - python_version = "3.11", + python_version = "3.14", ) load("@rules_python//python:pip.bzl", "pip_parse") pip_parse( name = "pypi", - python_interpreter_target = "@python_3_11_host//:python", + python_interpreter_target = "@python_3_14_host//:python", requirements_lock = "//:requirements.txt", ) ``` diff --git a/docs/toolchains.md b/docs/toolchains.md index f154fc29ed..2ac9476f19 100644 --- a/docs/toolchains.md +++ b/docs/toolchains.md @@ -200,9 +200,9 @@ folder. Look for the examples that contain a `MODULE.bazel` file. The `python.toolchain()` call makes its contents available under a repo named `python_X_Y`, where X and Y are the major and minor versions. For example, -`python.toolchain(python_version="3.11")` creates the repo `@python_3_11`. +`python.toolchain(python_version="3.14")` creates the repo `@python_3_14`. Remember to call `use_repo()` to make repos visible to your module: -`use_repo(python, "python_3_11")`. +`use_repo(python, "python_3_14")`. :::{deprecated} 1.1.0 diff --git a/python/extensions/python.bzl b/python/extensions/python.bzl index b8b755ebca..ef1ef10ca5 100644 --- a/python/extensions/python.bzl +++ b/python/extensions/python.bzl @@ -20,9 +20,9 @@ The simplest way to configure the toolchain with `rules_python` is as follows. ```starlark python = use_extension("@rules_python//python/extensions:python.bzl", "python") -python.defaults(python_version = "3.11") -python.toolchain(python_version = "3.11") -use_repo(python, "python_3_11") +python.defaults(python_version = "3.14") +python.toolchain(python_version = "3.14") +use_repo(python, "python_3_14") ``` :::{seealso} diff --git a/python/private/pypi/whl_extract.bzl b/python/private/pypi/whl_extract.bzl index 0d61b9a07b..7cbde9c174 100644 --- a/python/private/pypi/whl_extract.bzl +++ b/python/private/pypi/whl_extract.bzl @@ -61,6 +61,30 @@ def whl_extract(rctx, *, whl_path, logger): logger.debug(lambda: "Renaming: {} -> {}".format(src, dest)) repo_utils.rename(rctx, src, dest) + record_file = dist_info_dir.get_child("RECORD") + if record_file.exists: + record_content = rctx.read(record_file) + prefix_purelib = data_dir.basename + "/purelib/" + prefix_platlib = data_dir.basename + "/platlib/" + prefix_data = data_dir.basename + "/data/" + prefix_scripts = data_dir.basename + "/scripts/" + prefix_headers = data_dir.basename + "/headers/" + + lines = [] + for line in record_content.splitlines(): + if line.startswith(prefix_purelib): + line = line[len(prefix_purelib):] + elif line.startswith(prefix_platlib): + line = line[len(prefix_platlib):] + elif line.startswith(prefix_data): + line = "../data/" + line[len(prefix_data):] + elif line.startswith(prefix_scripts): + line = "../bin/" + line[len(prefix_scripts):] + elif line.startswith(prefix_headers): + line = "../include/" + line[len(prefix_headers):] + lines.append(line) + rctx.file(record_file, "\n".join(lines) + "\n") + # Ensure that there is no data dir left rctx.delete(data_dir) diff --git a/python/private/python.bzl b/python/private/python.bzl index 8932d00e1b..70a3bd9770 100644 --- a/python/private/python.bzl +++ b/python/private/python.bzl @@ -1210,10 +1210,10 @@ In order to use a different name than the above, you can use the following `MODU syntax: ```starlark python = use_extension("@rules_python//python/extensions:python.bzl", "python") -python.defaults(python_version = "3.11") -python.toolchain(python_version = "3.11") +python.defaults(python_version = "3.14") +python.toolchain(python_version = "3.14") -use_repo(python, my_python_name = "python_3_11") +use_repo(python, my_python_name = "python_3_14") ``` Then the python interpreter will be available as `my_python_name`. diff --git a/tests/cc/py_extension/py_extension/py_extension_tests.bzl b/tests/cc/py_extension/py_extension/py_extension_tests.bzl index ef2a2d8b6e..991a43d9a2 100644 --- a/tests/cc/py_extension/py_extension/py_extension_tests.bzl +++ b/tests/cc/py_extension/py_extension/py_extension_tests.bzl @@ -27,7 +27,7 @@ def _test_static_deps_impl(env, target): # The extension should be in PyInfo env.expect.that_collection(py_info.transitive_sources.to_list()).has_size(1) env.expect.that_depset_of_files(py_info.transitive_sources).contains_predicate( - matching.file_path_matches("ext_static.*311-*"), + matching.file_path_matches("ext_static.*314-*"), ) def _test_static_deps(name): @@ -64,7 +64,7 @@ def _test_dynamic_deps_impl(env, target): # The extension should be in PyInfo env.expect.that_collection(py_info.transitive_sources.to_list()).has_size(1) env.expect.that_depset_of_files(py_info.transitive_sources).contains_predicate( - matching.file_path_matches("ext_shared.*311-*"), + matching.file_path_matches("ext_shared.*314-*"), ) def _test_dynamic_deps(name): @@ -80,7 +80,7 @@ def _test_musl_platform_impl(env, target): env.expect.that_target(target).has_provider(PyInfo) py_info = target[PyInfo] env.expect.that_depset_of_files(py_info.transitive_sources).contains_predicate( - matching.file_path_matches("ext_static.*311-*"), + matching.file_path_matches("ext_static.*314-*"), ) def _test_musl_platform(name): diff --git a/tests/deprecated/BUILD.bazel b/tests/deprecated/BUILD.bazel index 4b920679f1..d3f1c53114 100644 --- a/tests/deprecated/BUILD.bazel +++ b/tests/deprecated/BUILD.bazel @@ -1,13 +1,13 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test") load( - "@python//3.11:defs.bzl", + "@python//3.14:defs.bzl", hub_compile_pip_requirements = "compile_pip_requirements", hub_py_binary = "py_binary", hub_py_console_script_binary = "py_console_script_binary", hub_py_test = "py_test", ) load( - "@python_3_11//:defs.bzl", + "@python_3_14//:defs.bzl", versioned_compile_pip_requirements = "compile_pip_requirements", versioned_py_binary = "py_binary", versioned_py_console_script_binary = "py_console_script_binary", @@ -21,14 +21,14 @@ transition_py_binary( name = "transition_py_binary", srcs = ["dummy.py"], main = "dummy.py", - python_version = "3.11", + python_version = "3.14", ) transition_py_test( name = "transition_py_test", srcs = ["dummy.py"], main = "dummy.py", - python_version = "3.11", + python_version = "3.14", ) versioned_py_binary( diff --git a/tests/deprecated/requirements.txt b/tests/deprecated/requirements.txt index 4d53f7c4e3..4d8b76c9e4 100644 --- a/tests/deprecated/requirements.txt +++ b/tests/deprecated/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.14 # by the following command: # # bazel run //tests/deprecated:versioned_compile_pip_requirements.update diff --git a/tests/deprecated/requirements_hub.txt b/tests/deprecated/requirements_hub.txt index 444beb63a5..73eae10a65 100644 --- a/tests/deprecated/requirements_hub.txt +++ b/tests/deprecated/requirements_hub.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.14 # by the following command: # # bazel run //tests/deprecated:hub_compile_pip_requirements.update diff --git a/tests/interpreter/BUILD.bazel b/tests/interpreter/BUILD.bazel index 5d89ede28a..4eb6721878 100644 --- a/tests/interpreter/BUILD.bazel +++ b/tests/interpreter/BUILD.bazel @@ -43,7 +43,7 @@ py_reconfig_interpreter_tests( # Since we're grabbing the interpreter from a binary with a fixed # version, we expect to always see that version. It doesn't matter what # Python version the test itself is running with. - "EXPECTED_INTERPRETER_VERSION": "3.11", + "EXPECTED_INTERPRETER_VERSION": "3.14", "PYTHON_BIN": "$(rootpath //python/bin:python)", }, main = "interpreter_test.py", diff --git a/tests/multiple_inputs/multiple_inputs.txt b/tests/multiple_inputs/multiple_inputs.txt index e6fdcf12d3..800b91a7df 100644 --- a/tests/multiple_inputs/multiple_inputs.txt +++ b/tests/multiple_inputs/multiple_inputs.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.14 # by the following command: # # bazel run //tests/multiple_inputs:multiple_inputs.update diff --git a/tests/multiple_inputs/multiple_pyproject_toml.txt b/tests/multiple_inputs/multiple_pyproject_toml.txt index cd9bc59f25..90426b5e84 100644 --- a/tests/multiple_inputs/multiple_pyproject_toml.txt +++ b/tests/multiple_inputs/multiple_pyproject_toml.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.14 # by the following command: # # bazel run //tests/multiple_inputs:multiple_pyproject_toml.update diff --git a/tests/multiple_inputs/multiple_requirements_in.txt b/tests/multiple_inputs/multiple_requirements_in.txt index 19586efa58..9e2a1435f2 100644 --- a/tests/multiple_inputs/multiple_requirements_in.txt +++ b/tests/multiple_inputs/multiple_requirements_in.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.14 # by the following command: # # bazel run //tests/multiple_inputs:multiple_requirements_in.update diff --git a/tests/python/python_tests.bzl b/tests/python/python_tests.bzl index cbef5637fd..5636b7e32c 100644 --- a/tests/python/python_tests.bzl +++ b/tests/python/python_tests.bzl @@ -27,8 +27,8 @@ def _rules_python_module(is_root = False): """A mock of what the real rules_python MODULE.bazel looks like.""" return python_ext.module( name = "rules_python", - defaults = [python_ext.defaults(python_version = "3.11")], - toolchain = [python_ext.toolchain(python_version = "3.11")], + defaults = [python_ext.defaults(python_version = "3.14")], + toolchain = [python_ext.toolchain(python_version = "3.14")], is_root = is_root, ) @@ -51,11 +51,11 @@ def _test_default_from_rules_python_when_rules_python_is_root(env): "tool_versions", "platforms", ]) - env.expect.that_str(py.default_python_version).equals("3.11") + env.expect.that_str(py.default_python_version).equals("3.14") want_toolchain = struct( - name = "python_3_11", - python_version = "3.11", + name = "python_3_14", + python_version = "3.14", register_coverage_tool = False, ) env.expect.that_collection(py.toolchains).contains_exactly([want_toolchain]) @@ -71,11 +71,11 @@ def _test_default_from_rules_python_when_rules_python_is_not_root(env): logger = repo_utils.logger(verbosity_level = 0, name = "python"), ) - env.expect.that_str(py.default_python_version).equals("3.11") + env.expect.that_str(py.default_python_version).equals("3.14") want_toolchain = struct( - name = "python_3_11", - python_version = "3.11", + name = "python_3_14", + python_version = "3.14", register_coverage_tool = False, ) env.expect.that_collection(py.toolchains).contains_exactly([want_toolchain]) @@ -146,7 +146,7 @@ def _test_toolchain_ordering(env): # the default match will be somewhere in the first bunch. "3.10", MINOR_MAPPING["3.10"], - "3.11", + "3.14", MINOR_MAPPING["3.11"], # Next, the rest, where we will match things based on the `python_version` being # the same @@ -284,8 +284,8 @@ def _test_defaults_overrides_single_toolchain(env): python_ext.module( name = "my_root_module", defaults = [ - # This relies on rules_python registering 3.11 - python_ext.defaults(python_version = "3.11"), + # This relies on rules_python registering 3.14 + python_ext.defaults(python_version = "3.14"), ], is_root = True, toolchain = [python_ext.toolchain(python_version = "3.12")], @@ -294,7 +294,7 @@ def _test_defaults_overrides_single_toolchain(env): ), logger = repo_utils.logger(verbosity_level = 0, name = "python"), ) - env.expect.that_str(py.default_python_version).equals("3.11") + env.expect.that_str(py.default_python_version).equals("3.14") _tests.append(_test_defaults_overrides_single_toolchain) @@ -359,8 +359,8 @@ def _test_first_occurance_of_the_toolchain_wins(env): register_coverage_tool = False, ) rules_python_toolchain = struct( - name = "python_3_11", - python_version = "3.11", + name = "python_3_14", + python_version = "3.14", register_coverage_tool = False, ) env.expect.that_collection(py.toolchains).contains_exactly([ @@ -371,7 +371,7 @@ def _test_first_occurance_of_the_toolchain_wins(env): env.expect.that_dict(py.debug_info).contains_exactly({ "toolchains_registered": [ {"module": {"is_root": True, "name": "my_module"}, "name": "python_3_12"}, - {"module": {"is_root": False, "name": "rules_python"}, "name": "python_3_11"}, + {"module": {"is_root": False, "name": "rules_python"}, "name": "python_3_14"}, ], }) @@ -408,8 +408,8 @@ def _test_auth_overrides(env): register_coverage_tool = False, ) rules_python_toolchain = struct( - name = "python_3_11", - python_version = "3.11", + name = "python_3_14", + python_version = "3.14", register_coverage_tool = False, ) env.expect.that_collection(py.toolchains).contains_exactly([ diff --git a/tests/toolchains/BUILD.bazel b/tests/toolchains/BUILD.bazel index b336a06269..9455cc1bbd 100644 --- a/tests/toolchains/BUILD.bazel +++ b/tests/toolchains/BUILD.bazel @@ -36,7 +36,7 @@ py_reconfig_test( build_test( name = "build_test", targets = [ - "@python_3_11//:python_headers", + "@python_3_14//:python_headers", ], ) diff --git a/tools/publish/BUILD.bazel b/tools/publish/BUILD.bazel index 2f02809ccd..a1c947e060 100644 --- a/tools/publish/BUILD.bazel +++ b/tools/publish/BUILD.bazel @@ -6,7 +6,7 @@ py_console_script_binary( # We transition to a specific python version in order to ensure that we # don't rely on the default version configured by the root module. pkg = "@rules_python_publish_deps//twine", - python_version = "3.11", + python_version = "3.14", script = "twine", visibility = ["//visibility:public"], )