|
| 1 | +import distutils.sysconfig |
| 2 | +import distutils.version |
| 3 | +from glob import glob |
1 | 4 | import os
|
| 5 | +import platform |
2 | 6 | from setuptools import Extension, setup, find_packages
|
3 | 7 | from setuptools.command.build_ext import build_ext
|
4 |
| -import sys |
5 |
| -import setuptools |
6 |
| -from glob import glob |
7 | 8 | import subprocess
|
| 9 | +import sys |
8 | 10 |
|
9 | 11 |
|
10 | 12 | with open("README.md", "r") as fh:
|
@@ -53,11 +55,28 @@ def get_openmp_flag():
|
53 | 55 | extra_compile_args=["-O3", "-std=c++11", "-march=native"] + get_openmp_flag()
|
54 | 56 | )
|
55 | 57 |
|
| 58 | +def is_platform_mac(): |
| 59 | + return sys.platform == 'darwin' |
| 60 | + |
| 61 | + |
| 62 | +# For mac, ensure extensions are built for macos 10.9 when compiling on a |
| 63 | +# 10.9 system or above, overriding distutils behaviour which is to target |
| 64 | +# the version that python was built for. This may be overridden by setting |
| 65 | +# MACOSX_DEPLOYMENT_TARGET before calling setup.py. This behavior is |
| 66 | +# motivated by Apple dropping support for libstdc++. |
| 67 | +if is_platform_mac(): |
| 68 | + if 'MACOSX_DEPLOYMENT_TARGET' not in os.environ: |
| 69 | + current_system = distutils.version.LooseVersion(platform.mac_ver()[0]) |
| 70 | + python_target = distutils.version.LooseVersion( |
| 71 | + distutils.sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')) |
| 72 | + if python_target < '10.9' and current_system >= '10.9': |
| 73 | + os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9' |
| 74 | + |
56 | 75 | ext_modules = [_diffcp]
|
57 | 76 |
|
58 | 77 | setup(
|
59 | 78 | name='diffcp',
|
60 |
| - version="1.0.8", |
| 79 | + version="1.0.9", |
61 | 80 | author="Akshay Agrawal, Shane Barratt, Stephen Boyd, Enzo Busseti, Walaa Moursi",
|
62 | 81 | long_description=long_description,
|
63 | 82 | long_description_content_type="text/markdown",
|
|
0 commit comments