Skip to content

Commit

Permalink
Fix build issue (stdlib headers not found) on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
cadl committed Nov 6, 2019
1 parent 10ba595 commit 3f782ef
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import sys
import shlex
import pkg_resources
import platform
from distutils.sysconfig import get_config_var
from distutils.version import LooseVersion
from glob import glob
from setuptools import setup, Extension
from setuptools.command.test import test as TestCommand
Expand All @@ -25,6 +28,25 @@ def is_installed(requirement):
else:
return True


def is_platform_mac():
return sys.platform == 'darwin'


# For mac, ensure extensions are built for macos 10.9 when compiling on a
# 10.9 system or above, overriding distuitls behaviour which is to target
# the version that python was built for. This may be overridden by setting
# MACOSX_DEPLOYMENT_TARGET before calling setup.py
# https://github.com/pandas-dev/pandas/issues/23424#issuecomment-446393981
if is_platform_mac():
if 'MACOSX_DEPLOYMENT_TARGET' not in os.environ:
current_system = LooseVersion(platform.mac_ver()[0])
python_target = LooseVersion(
get_config_var('MACOSX_DEPLOYMENT_TARGET'))
if python_target < '10.9' and current_system >= '10.9':
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'


# Resolving Cython dependency via 'setup_requires' requires setuptools >= 18.0:
# https://github.com/pypa/setuptools/commit/a811c089a4362c0dc6c4a84b708953dde9ebdbf8
setuptools_req = "setuptools >= 18.0"
Expand Down

0 comments on commit 3f782ef

Please sign in to comment.