Skip to content

Commit ed05dff

Browse files
authored
MacOS wheels py3.10-3.12 -> macosx_11_0 . For py3.13-3.14 -> macosx_12_0 whls (#7848) (#7851)
This constraints MacOS builds as follows: Py 3.10-3.12 builds should support macosx_11 as minos Py 3.13, 3.13t, 3.14 and 3.14t builds should support macosx_11 as minos Reason: We can build 3.13, 3.13t, 3.14, 3.14t due to conda python version not supporting MacOS 11: https://anaconda.org/channels/main/packages/python/overview
1 parent 15c5884 commit ed05dff

3 files changed

Lines changed: 40 additions & 22 deletions

File tree

tools/pkg-helpers/pytorch_pkg_helpers/macos.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
def get_macos_variables(arch_name: str, python_version: str = "3.8") -> list:
2+
# Python 3.13+ requires macOS 12.0
3+
# Handle full point versions like "3.11.14" and freethreaded like "3.13t"
4+
parts = python_version.rstrip("t").split(".")
5+
base_version = float(f"{parts[0]}.{parts[1]}")
6+
deployment_target = "12.0" if base_version >= 3.13 else "11.0"
27
variables = [
3-
"export MACOSX_DEPLOYMENT_TARGET=10.15",
8+
f"export MACOSX_DEPLOYMENT_TARGET={deployment_target}",
9+
f"export _PYTHON_HOST_PLATFORM=macosx-{deployment_target}-arm64",
410
"export CC=clang",
511
"export CXX=clang++",
612
]

tools/pkg-helpers/tests/test_macos.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,22 @@
33

44

55
@pytest.mark.parametrize(
6-
"arch_name,expected",
6+
"python_version,expected_target",
77
[
8-
(
9-
("arm64"),
10-
[
11-
"export MACOSX_DEPLOYMENT_TARGET=10.9",
12-
"export CC=clang",
13-
"export CXX=clang++",
14-
],
15-
),
16-
(
17-
("x86_64"),
18-
[
19-
"export MACOSX_DEPLOYMENT_TARGET=10.9",
20-
"export CC=clang",
21-
"export CXX=clang++",
22-
"export CONDA_EXTRA_BUILD_CONSTRAINT='- mkl<=2021.2.0'",
23-
],
24-
),
8+
("3.10", "11.0"),
9+
("3.11", "11.0"),
10+
("3.12", "11.0"),
11+
("3.13", "12.0"),
12+
("3.13t", "12.0"),
13+
("3.14", "12.0"),
14+
("3.14t", "12.0"),
2515
],
2616
)
27-
def test_get_macos_variables(arch_name, expected):
28-
assert get_macos_variables(arch_name) == expected
17+
def test_get_macos_variables(python_version, expected_target):
18+
result = get_macos_variables("arm64", python_version)
19+
assert result == [
20+
f"export MACOSX_DEPLOYMENT_TARGET={expected_target}",
21+
f"export _PYTHON_HOST_PLATFORM=macosx-{expected_target}-arm64",
22+
"export CC=clang",
23+
"export CXX=clang++",
24+
]

tools/scripts/generate_binary_build_matrix.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
"test": ["3.10", "3.11", "3.12", "3.13", "3.13t", "3.14", "3.14t"],
2727
"release": ["3.10", "3.11", "3.12", "3.13", "3.13t", "3.14", "3.14t"],
2828
}
29+
30+
MACOS_PYTHON_POINT_VERSIONS = {
31+
"3.10": "3.10.19",
32+
"3.11": "3.11.14",
33+
"3.12": "3.12.12",
34+
"3.13": "3.13",
35+
"3.14": "3.14.3",
36+
}
2937
CUDA_ARCHES_DICT = {
3038
"nightly": ["12.6", "12.8", "13.0"],
3139
"test": ["12.6", "12.8", "13.0"],
@@ -483,8 +491,16 @@ def generate_wheels_matrix(
483491
continue
484492

485493
desired_cuda = translate_desired_cuda(gpu_arch_type, gpu_arch_version)
494+
495+
# For macOS, use pinned .0 point versions for consistent builds
496+
effective_python_version = python_version
497+
if os == MACOS_ARM64:
498+
effective_python_version = MACOS_PYTHON_POINT_VERSIONS.get(
499+
python_version, python_version
500+
)
501+
486502
entry = {
487-
"python_version": python_version,
503+
"python_version": effective_python_version,
488504
"gpu_arch_type": gpu_arch_type,
489505
"gpu_arch_version": gpu_arch_version,
490506
"desired_cuda": desired_cuda,

0 commit comments

Comments
 (0)