Skip to content

Commit

Permalink
feat: add support for free-threaded (no-gil) Python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeut committed May 18, 2024
1 parent 78bca57 commit eebc852
Show file tree
Hide file tree
Showing 18 changed files with 159 additions and 65 deletions.
29 changes: 21 additions & 8 deletions bin/update_pythons.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ConfigMacOS(TypedDict):


class WindowsVersions:
def __init__(self, arch_str: ArchStr) -> None:
def __init__(self, arch_str: ArchStr, free_threaded: bool) -> None:
response = requests.get("https://api.nuget.org/v3/index.json")
response.raise_for_status()
api_info = response.json()
Expand All @@ -72,7 +72,11 @@ def __init__(self, arch_str: ArchStr) -> None:

self.arch_str = arch_str
self.arch = ARCH_DICT[arch_str]
self.free_threaded = free_threaded

package = PACKAGE_DICT[arch_str]
if free_threaded:
package = f"{package}-freethreaded"

response = requests.get(f"{endpoint}{package}/index.json")
response.raise_for_status()
Expand All @@ -92,8 +96,9 @@ def update_version_windows(self, spec: Specifier) -> ConfigWinCP | None:
if not versions:
return None

flags = "t" if self.free_threaded else ""
version = versions[0]
identifier = f"cp{version.major}{version.minor}-{self.arch}"
identifier = f"cp{version.major}{version.minor}{flags}-{self.arch}"
return ConfigWinCP(
identifier=identifier,
version=self.version_dict[version],
Expand Down Expand Up @@ -233,9 +238,12 @@ def update_version_macos(

class AllVersions:
def __init__(self) -> None:
self.windows_32 = WindowsVersions("32")
self.windows_64 = WindowsVersions("64")
self.windows_arm64 = WindowsVersions("ARM64")
self.windows_32 = WindowsVersions("32", False)
self.windows_t_32 = WindowsVersions("32", True)
self.windows_64 = WindowsVersions("64", False)
self.windows_t_64 = WindowsVersions("64", True)
self.windows_arm64 = WindowsVersions("ARM64", False)
self.windows_t_arm64 = WindowsVersions("ARM64", True)
self.windows_pypy_64 = PyPyVersions("64")

self.macos_cpython = CPythonVersions()
Expand All @@ -259,14 +267,19 @@ def update_config(self, config: MutableMapping[str, str]) -> None:
config_update = self.macos_pypy.update_version_macos(spec)
elif "macosx_arm64" in identifier:
config_update = self.macos_pypy_arm64.update_version_macos(spec)
elif "win32" in identifier:
if identifier.startswith("cp"):
config_update = self.windows_32.update_version_windows(spec)
elif "t-win32" in identifier and identifier.startswith("cp"):
config_update = self.windows_t_32.update_version_windows(spec)
elif "win32" in identifier and identifier.startswith("cp"):
config_update = self.windows_32.update_version_windows(spec)
elif "t-win_amd64" in identifier and identifier.startswith("cp"):
config_update = self.windows_t_64.update_version_windows(spec)
elif "win_amd64" in identifier:
if identifier.startswith("cp"):
config_update = self.windows_64.update_version_windows(spec)
elif identifier.startswith("pp"):
config_update = self.windows_pypy_64.update_version_windows(spec)
elif "t-win_arm64" in identifier and identifier.startswith("cp"):
config_update = self.windows_t_arm64.update_version_windows(spec)
elif "win_arm64" in identifier and identifier.startswith("cp"):
config_update = self.windows_arm64.update_version_windows(spec)

Expand Down
4 changes: 4 additions & 0 deletions cibuildwheel/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ def build_in_container(
virtualenv_env = env.copy()
virtualenv_env["PATH"] = f"{venv_dir / 'bin'}:{virtualenv_env['PATH']}"

# TODO remove me once virtualenv provides pip>=24.1b1
if config.version == "3.13":
container.call(["pip", "install", "pip>=24.1b1"], env=virtualenv_env)

if build_options.before_test:
before_test_prepared = prepare_command(
build_options.before_test,
Expand Down
4 changes: 4 additions & 0 deletions cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,10 @@ def build(options: Options, tmp_path: Path) -> None:
# check that we are using the Python from the virtual environment
call_with_arch("which", "python", env=virtualenv_env)

# TODO remove me once virtualenv provides pip>=24.1b1
if config.version == "3.13":
call("python", "-m", "pip", "install", "pip>=24.1b1", env=virtualenv_env)

if build_options.before_test:
before_test_prepared = prepare_command(
build_options.before_test,
Expand Down
13 changes: 13 additions & 0 deletions cibuildwheel/resources/build-platforms.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ python_configurations = [
{ identifier = "cp311-manylinux_x86_64", version = "3.11", path_str = "/opt/python/cp311-cp311" },
{ identifier = "cp312-manylinux_x86_64", version = "3.12", path_str = "/opt/python/cp312-cp312" },
{ identifier = "cp313-manylinux_x86_64", version = "3.13", path_str = "/opt/python/cp313-cp313" },
{ identifier = "cp313t-manylinux_x86_64", version = "3.13", path_str = "/opt/python/cp313-cp313t" },
{ identifier = "cp36-manylinux_i686", version = "3.6", path_str = "/opt/python/cp36-cp36m" },
{ identifier = "cp37-manylinux_i686", version = "3.7", path_str = "/opt/python/cp37-cp37m" },
{ identifier = "cp38-manylinux_i686", version = "3.8", path_str = "/opt/python/cp38-cp38" },
Expand All @@ -16,6 +17,7 @@ python_configurations = [
{ identifier = "cp311-manylinux_i686", version = "3.11", path_str = "/opt/python/cp311-cp311" },
{ identifier = "cp312-manylinux_i686", version = "3.12", path_str = "/opt/python/cp312-cp312" },
{ identifier = "cp313-manylinux_i686", version = "3.13", path_str = "/opt/python/cp313-cp313" },
{ identifier = "cp313t-manylinux_i686", version = "3.13", path_str = "/opt/python/cp313-cp313t" },
{ identifier = "pp37-manylinux_x86_64", version = "3.7", path_str = "/opt/python/pp37-pypy37_pp73" },
{ identifier = "pp38-manylinux_x86_64", version = "3.8", path_str = "/opt/python/pp38-pypy38_pp73" },
{ identifier = "pp39-manylinux_x86_64", version = "3.9", path_str = "/opt/python/pp39-pypy39_pp73" },
Expand All @@ -28,6 +30,7 @@ python_configurations = [
{ identifier = "cp311-manylinux_aarch64", version = "3.11", path_str = "/opt/python/cp311-cp311" },
{ identifier = "cp312-manylinux_aarch64", version = "3.12", path_str = "/opt/python/cp312-cp312" },
{ identifier = "cp313-manylinux_aarch64", version = "3.13", path_str = "/opt/python/cp313-cp313" },
{ identifier = "cp313t-manylinux_aarch64", version = "3.13", path_str = "/opt/python/cp313-cp313t" },
{ identifier = "cp36-manylinux_ppc64le", version = "3.6", path_str = "/opt/python/cp36-cp36m" },
{ identifier = "cp37-manylinux_ppc64le", version = "3.7", path_str = "/opt/python/cp37-cp37m" },
{ identifier = "cp38-manylinux_ppc64le", version = "3.8", path_str = "/opt/python/cp38-cp38" },
Expand All @@ -36,6 +39,7 @@ python_configurations = [
{ identifier = "cp311-manylinux_ppc64le", version = "3.11", path_str = "/opt/python/cp311-cp311" },
{ identifier = "cp312-manylinux_ppc64le", version = "3.12", path_str = "/opt/python/cp312-cp312" },
{ identifier = "cp313-manylinux_ppc64le", version = "3.13", path_str = "/opt/python/cp313-cp313" },
{ identifier = "cp313t-manylinux_ppc64le", version = "3.13", path_str = "/opt/python/cp313-cp313t" },
{ identifier = "cp36-manylinux_s390x", version = "3.6", path_str = "/opt/python/cp36-cp36m" },
{ identifier = "cp37-manylinux_s390x", version = "3.7", path_str = "/opt/python/cp37-cp37m" },
{ identifier = "cp38-manylinux_s390x", version = "3.8", path_str = "/opt/python/cp38-cp38" },
Expand All @@ -44,6 +48,7 @@ python_configurations = [
{ identifier = "cp311-manylinux_s390x", version = "3.11", path_str = "/opt/python/cp311-cp311" },
{ identifier = "cp312-manylinux_s390x", version = "3.12", path_str = "/opt/python/cp312-cp312" },
{ identifier = "cp313-manylinux_s390x", version = "3.13", path_str = "/opt/python/cp313-cp313" },
{ identifier = "cp313t-manylinux_s390x", version = "3.13", path_str = "/opt/python/cp313-cp313t" },
{ identifier = "pp37-manylinux_aarch64", version = "3.7", path_str = "/opt/python/pp37-pypy37_pp73" },
{ identifier = "pp38-manylinux_aarch64", version = "3.8", path_str = "/opt/python/pp38-pypy38_pp73" },
{ identifier = "pp39-manylinux_aarch64", version = "3.9", path_str = "/opt/python/pp39-pypy39_pp73" },
Expand All @@ -60,6 +65,7 @@ python_configurations = [
{ identifier = "cp311-musllinux_x86_64", version = "3.11", path_str = "/opt/python/cp311-cp311" },
{ identifier = "cp312-musllinux_x86_64", version = "3.12", path_str = "/opt/python/cp312-cp312" },
{ identifier = "cp313-musllinux_x86_64", version = "3.13", path_str = "/opt/python/cp313-cp313" },
{ identifier = "cp313t-musllinux_x86_64", version = "3.13", path_str = "/opt/python/cp313-cp313t" },
{ identifier = "cp36-musllinux_i686", version = "3.6", path_str = "/opt/python/cp36-cp36m" },
{ identifier = "cp37-musllinux_i686", version = "3.7", path_str = "/opt/python/cp37-cp37m" },
{ identifier = "cp38-musllinux_i686", version = "3.8", path_str = "/opt/python/cp38-cp38" },
Expand All @@ -68,6 +74,7 @@ python_configurations = [
{ identifier = "cp311-musllinux_i686", version = "3.11", path_str = "/opt/python/cp311-cp311" },
{ identifier = "cp312-musllinux_i686", version = "3.12", path_str = "/opt/python/cp312-cp312" },
{ identifier = "cp313-musllinux_i686", version = "3.13", path_str = "/opt/python/cp313-cp313" },
{ identifier = "cp313t-musllinux_i686", version = "3.13", path_str = "/opt/python/cp313-cp313t" },
{ identifier = "cp36-musllinux_aarch64", version = "3.6", path_str = "/opt/python/cp36-cp36m" },
{ identifier = "cp37-musllinux_aarch64", version = "3.7", path_str = "/opt/python/cp37-cp37m" },
{ identifier = "cp38-musllinux_aarch64", version = "3.8", path_str = "/opt/python/cp38-cp38" },
Expand All @@ -76,6 +83,7 @@ python_configurations = [
{ identifier = "cp311-musllinux_aarch64", version = "3.11", path_str = "/opt/python/cp311-cp311" },
{ identifier = "cp312-musllinux_aarch64", version = "3.12", path_str = "/opt/python/cp312-cp312" },
{ identifier = "cp313-musllinux_aarch64", version = "3.13", path_str = "/opt/python/cp313-cp313" },
{ identifier = "cp313t-musllinux_aarch64", version = "3.13", path_str = "/opt/python/cp313-cp313t" },
{ identifier = "cp36-musllinux_ppc64le", version = "3.6", path_str = "/opt/python/cp36-cp36m" },
{ identifier = "cp37-musllinux_ppc64le", version = "3.7", path_str = "/opt/python/cp37-cp37m" },
{ identifier = "cp38-musllinux_ppc64le", version = "3.8", path_str = "/opt/python/cp38-cp38" },
Expand All @@ -84,6 +92,7 @@ python_configurations = [
{ identifier = "cp311-musllinux_ppc64le", version = "3.11", path_str = "/opt/python/cp311-cp311" },
{ identifier = "cp312-musllinux_ppc64le", version = "3.12", path_str = "/opt/python/cp312-cp312" },
{ identifier = "cp313-musllinux_ppc64le", version = "3.13", path_str = "/opt/python/cp313-cp313" },
{ identifier = "cp313t-musllinux_ppc64le", version = "3.13", path_str = "/opt/python/cp313-cp313t" },
{ identifier = "cp36-musllinux_s390x", version = "3.6", path_str = "/opt/python/cp36-cp36m" },
{ identifier = "cp37-musllinux_s390x", version = "3.7", path_str = "/opt/python/cp37-cp37m" },
{ identifier = "cp38-musllinux_s390x", version = "3.8", path_str = "/opt/python/cp38-cp38" },
Expand All @@ -92,6 +101,7 @@ python_configurations = [
{ identifier = "cp311-musllinux_s390x", version = "3.11", path_str = "/opt/python/cp311-cp311" },
{ identifier = "cp312-musllinux_s390x", version = "3.12", path_str = "/opt/python/cp312-cp312" },
{ identifier = "cp313-musllinux_s390x", version = "3.13", path_str = "/opt/python/cp313-cp313" },
{ identifier = "cp313t-musllinux_s390x", version = "3.13", path_str = "/opt/python/cp313-cp313t" },
]

[macos]
Expand Down Expand Up @@ -142,12 +152,15 @@ python_configurations = [
{ identifier = "cp312-win32", version = "3.12.3", arch = "32" },
{ identifier = "cp312-win_amd64", version = "3.12.3", arch = "64" },
{ identifier = "cp313-win32", version = "3.13.0-b1", arch = "32" },
{ identifier = "cp313t-win32", version = "3.13.0-b1", arch = "32" },
{ identifier = "cp313-win_amd64", version = "3.13.0-b1", arch = "64" },
{ identifier = "cp313t-win_amd64", version = "3.13.0-b1", arch = "64" },
{ identifier = "cp39-win_arm64", version = "3.9.10", arch = "ARM64" },
{ identifier = "cp310-win_arm64", version = "3.10.11", arch = "ARM64" },
{ identifier = "cp311-win_arm64", version = "3.11.9", arch = "ARM64" },
{ identifier = "cp312-win_arm64", version = "3.12.3", arch = "ARM64" },
{ identifier = "cp313-win_arm64", version = "3.13.0-b1", arch = "ARM64" },
{ identifier = "cp313t-win_arm64", version = "3.13.0-b1", arch = "ARM64" },
{ identifier = "pp37-win_amd64", version = "3.7", arch = "64", url = "https://downloads.python.org/pypy/pypy3.7-v7.3.9-win64.zip" },
{ identifier = "pp38-win_amd64", version = "3.8", arch = "64", url = "https://downloads.python.org/pypy/pypy3.8-v7.3.11-win64.zip" },
{ identifier = "pp39-win_amd64", version = "3.9", arch = "64", url = "https://downloads.python.org/pypy/pypy3.9-v7.3.16-win64.zip" },
Expand Down
10 changes: 7 additions & 3 deletions cibuildwheel/resources/constraints-python310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
altgraph==0.17.4
# via macholib
build==1.2.1
# via -r cibuildwheel/resources/constraints.in
delocate==0.11.0
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8
# via virtualenv
filelock==3.14.0
Expand All @@ -17,14 +19,16 @@ packaging==24.0
# build
# delocate
pip==24.0
platformdirs==4.2.1
# via -r cibuildwheel/resources/constraints.in
platformdirs==4.2.2
# via virtualenv
pyproject-hooks==1.1.0
# via build
tomli==2.0.1
# via build
typing-extensions==4.11.0
# via delocate
virtualenv==20.26.1
zipp==3.18.1
virtualenv==20.26.2
# via -r cibuildwheel/resources/constraints.in
zipp==3.18.2
# via importlib-metadata
8 changes: 6 additions & 2 deletions cibuildwheel/resources/constraints-python311.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
altgraph==0.17.4
# via macholib
build==1.2.1
# via -r cibuildwheel/resources/constraints.in
delocate==0.11.0
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8
# via virtualenv
filelock==3.14.0
Expand All @@ -15,10 +17,12 @@ packaging==24.0
# build
# delocate
pip==24.0
platformdirs==4.2.1
# via -r cibuildwheel/resources/constraints.in
platformdirs==4.2.2
# via virtualenv
pyproject-hooks==1.1.0
# via build
typing-extensions==4.11.0
# via delocate
virtualenv==20.26.1
virtualenv==20.26.2
# via -r cibuildwheel/resources/constraints.in
8 changes: 6 additions & 2 deletions cibuildwheel/resources/constraints-python312.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
altgraph==0.17.4
# via macholib
build==1.2.1
# via -r cibuildwheel/resources/constraints.in
delocate==0.11.0
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8
# via virtualenv
filelock==3.14.0
Expand All @@ -15,10 +17,12 @@ packaging==24.0
# build
# delocate
pip==24.0
platformdirs==4.2.1
# via -r cibuildwheel/resources/constraints.in
platformdirs==4.2.2
# via virtualenv
pyproject-hooks==1.1.0
# via build
typing-extensions==4.11.0
# via delocate
virtualenv==20.26.1
virtualenv==20.26.2
# via -r cibuildwheel/resources/constraints.in
10 changes: 7 additions & 3 deletions cibuildwheel/resources/constraints-python313.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
altgraph==0.17.4
# via macholib
build==1.2.1
# via -r cibuildwheel/resources/constraints.in
delocate==0.11.0
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8
# via virtualenv
filelock==3.14.0
Expand All @@ -14,11 +16,13 @@ packaging==24.0
# via
# build
# delocate
pip==24.0
platformdirs==4.2.1
pip==24.1b1
# via -r cibuildwheel/resources/constraints.in
platformdirs==4.2.2
# via virtualenv
pyproject-hooks==1.1.0
# via build
typing-extensions==4.11.0
# via delocate
virtualenv==20.26.1
virtualenv==20.26.2
# via -r cibuildwheel/resources/constraints.in
6 changes: 5 additions & 1 deletion cibuildwheel/resources/constraints-python37.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
altgraph==0.17.4
# via macholib
build==1.1.1
# via -r cibuildwheel/resources/constraints.in
delocate==0.11.0
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8
# via virtualenv
filelock==3.12.2
Expand All @@ -19,6 +21,7 @@ packaging==24.0
# build
# delocate
pip==24.0
# via -r cibuildwheel/resources/constraints.in
platformdirs==4.0.0
# via virtualenv
pyproject-hooks==1.1.0
Expand All @@ -30,6 +33,7 @@ typing-extensions==4.7.1
# delocate
# importlib-metadata
# platformdirs
virtualenv==20.26.1
virtualenv==20.26.2
# via -r cibuildwheel/resources/constraints.in
zipp==3.15.0
# via importlib-metadata
10 changes: 7 additions & 3 deletions cibuildwheel/resources/constraints-python38.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
altgraph==0.17.4
# via macholib
build==1.2.1
# via -r cibuildwheel/resources/constraints.in
delocate==0.11.0
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8
# via virtualenv
filelock==3.14.0
Expand All @@ -17,14 +19,16 @@ packaging==24.0
# build
# delocate
pip==24.0
platformdirs==4.2.1
# via -r cibuildwheel/resources/constraints.in
platformdirs==4.2.2
# via virtualenv
pyproject-hooks==1.1.0
# via build
tomli==2.0.1
# via build
typing-extensions==4.11.0
# via delocate
virtualenv==20.26.1
zipp==3.18.1
virtualenv==20.26.2
# via -r cibuildwheel/resources/constraints.in
zipp==3.18.2
# via importlib-metadata
10 changes: 7 additions & 3 deletions cibuildwheel/resources/constraints-python39.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
altgraph==0.17.4
# via macholib
build==1.2.1
# via -r cibuildwheel/resources/constraints.in
delocate==0.11.0
# via -r cibuildwheel/resources/constraints.in
distlib==0.3.8
# via virtualenv
filelock==3.14.0
Expand All @@ -17,14 +19,16 @@ packaging==24.0
# build
# delocate
pip==24.0
platformdirs==4.2.1
# via -r cibuildwheel/resources/constraints.in
platformdirs==4.2.2
# via virtualenv
pyproject-hooks==1.1.0
# via build
tomli==2.0.1
# via build
typing-extensions==4.11.0
# via delocate
virtualenv==20.26.1
zipp==3.18.1
virtualenv==20.26.2
# via -r cibuildwheel/resources/constraints.in
zipp==3.18.2
# via importlib-metadata
3 changes: 2 additions & 1 deletion cibuildwheel/resources/constraints.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pip
pip>=24.1b1 ; python_version >= '3.13'
pip ; python_version < '3.13'
build
delocate
virtualenv
Loading

0 comments on commit eebc852

Please sign in to comment.