Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 3f16dfc

Browse files
committed
Limit deployment target
1 parent 2e7dbef commit 3f16dfc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

setup.py

+23
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
11
import os
2+
import platform
23
import sys
34
import subprocess
5+
from sysconfig import get_config_vars
6+
7+
from pkg_resources import parse_version
48
from setuptools import setup, find_packages, Extension
59

10+
# From https://github.com/pandas-dev/pandas/pull/24274:
11+
# For mac, ensure extensions are built for macos 10.9 when compiling on a
12+
# 10.9 system or above, overriding distuitls behaviour which is to target
13+
# the version that python was built for. This may be overridden by setting
14+
# MACOSX_DEPLOYMENT_TARGET before calling setup.py
15+
if sys.platform == "darwin":
16+
if "MACOSX_DEPLOYMENT_TARGET" not in os.environ:
17+
current_system = platform.mac_ver()[0]
18+
python_target = get_config_vars().get(
19+
"MACOSX_DEPLOYMENT_TARGET", current_system
20+
)
21+
target_macos_version = "10.9"
22+
23+
parsed_python_target = parse_version(python_target)
24+
parsed_current_system = parse_version(current_system)
25+
parsed_macos_version = parse_version(target_macos_version)
26+
if parsed_python_target <= parsed_macos_version <= parsed_current_system:
27+
os.environ["MACOSX_DEPLOYMENT_TARGET"] = target_macos_version
28+
629
if sys.version_info[:2] == (3, 6):
730
clinic_file = "tools/py36_clinic.py"
831
elif sys.version_info[:2] == (3, 7):

0 commit comments

Comments
 (0)