From a9843d8fd4e6d00320f54f03e222a72a210e4c97 Mon Sep 17 00:00:00 2001 From: Andrey Talman Date: Wed, 22 Jul 2026 17:29:50 -0700 Subject: [PATCH] Allow Python 3.15 / 3.15t builds Bump the supported Python upper bound to <3.16 so ExecuTorch can be built and installed on Python 3.15 (including the free-threaded 3.15t build, which reports version 3.15). Two changes are needed, not just the version bump: - pyproject.toml: requires-python ">=3.10,<3.15" -> ">=3.10,<3.16". - install_utils.py: python_is_compatible() compared the interpreter against the SpecifierSet with the default `in` operator, which excludes pre-releases. A pre-release interpreter such as 3.15.0b4 was therefore rejected even once 3.15 is in range. Use SpecifierSet.contains(..., prereleases=True) so in-range pre-release interpreters are accepted (3.16 pre-releases remain excluded by the <3.16 bound). Surfaced while enabling Python 3.15 / 3.15t Linux wheel builds in pytorch/test-infra#8148. Test Plan: python -c "import packaging.specifiers as S, packaging.version as V; \ ss=S.SpecifierSet('>=3.10,<3.16'); \ print(ss.contains(V.parse('3.15.0b4'), prereleases=True))" # True # 3.9 and 3.16 pre-releases still report False. Authored with assistance from Claude Code (AI assistant). --- install_utils.py | 5 ++++- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/install_utils.py b/install_utils.py index ee4a91aa661..d2e4cffa812 100644 --- a/install_utils.py +++ b/install_utils.py @@ -273,7 +273,10 @@ def python_is_compatible(): python_version = packaging.version.parse(platform.python_version()) version_range = packaging.specifiers.SpecifierSet(version_specifier) - if python_version not in version_range: + # Pass prereleases=True so pre-release interpreters (e.g. 3.15.0b4) are + # accepted when they fall within the supported range; SpecifierSet + # excludes pre-releases by default. + if not version_range.contains(python_version, prereleases=True): print( f'ERROR: ExecuTorch does not support python version {python_version}: must satisfy "{version_specifier}"', file=sys.stderr, diff --git a/pyproject.toml b/pyproject.toml index 1bf343cfd5f..b09b022ca53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ classifiers = [ "Programming Language :: Python :: 3.14", ] -requires-python = ">=3.10,<3.15" +requires-python = ">=3.10,<3.16" # Runtime dependencies are declared dynamically (see `dynamic` above) and # computed in setup.py, so the EXECUTORCH_BUILD_MINIMAL wheel can ship a slimmer