Skip to content

Commit 58a6df5

Browse files
committed
Fix build issue (stdlib headers not found) on mac
ref: pandas-dev/pandas#23424
1 parent 10ba595 commit 58a6df5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

setup.py

+22
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import sys
55
import shlex
66
import pkg_resources
7+
import platform
8+
from distutils.sysconfig import get_config_var
9+
from distutils.version import LooseVersion
710
from glob import glob
811
from setuptools import setup, Extension
912
from setuptools.command.test import test as TestCommand
@@ -25,6 +28,25 @@ def is_installed(requirement):
2528
else:
2629
return True
2730

31+
32+
def is_platform_mac():
33+
return sys.platform == 'darwin'
34+
35+
36+
# For mac, ensure extensions are built for macos 10.9 when compiling on a
37+
# 10.9 system or above, overriding distuitls behaviour which is to target
38+
# the version that python was built for. This may be overridden by setting
39+
# MACOSX_DEPLOYMENT_TARGET before calling setup.py
40+
# https://github.com/pandas-dev/pandas/issues/23424#issuecomment-446393981
41+
if is_platform_mac():
42+
if 'MACOSX_DEPLOYMENT_TARGET' not in os.environ:
43+
current_system = LooseVersion(platform.mac_ver()[0])
44+
python_target = LooseVersion(
45+
get_config_var('MACOSX_DEPLOYMENT_TARGET'))
46+
if python_target < '10.9' and current_system >= '10.9':
47+
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
48+
49+
2850
# Resolving Cython dependency via 'setup_requires' requires setuptools >= 18.0:
2951
# https://github.com/pypa/setuptools/commit/a811c089a4362c0dc6c4a84b708953dde9ebdbf8
3052
setuptools_req = "setuptools >= 18.0"

0 commit comments

Comments
 (0)