Skip to content

Commit 9f2d5c0

Browse files
Merge pull request pandas-dev#550 from manahl/setup_py_conda_env
MacOS Fix build with conda gcc
2 parents 65fa510 + 8ccfc68 commit 9f2d5c0

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Bugfix: #534 VersionStore: overwriting a symbol with different dtype (but same data format) does not
88
raise exceptions anymore
99
* Bugfix: #531 arctic_prune_versions: clean broken snapshot references before pruning
10+
* Bugfix: setup.py develop in a conda environment on Mac
1011
* Feature: #490 add support to numpy 1.14
1112

1213
### 1.63 (2018-04-06)

docs/developing-conda-mac.md

-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ l.write('thing', object())
5757

5858
## Issues
5959

60-
### Not using the correct compiler on Mac OS X
61-
62-
FIXME: setup.py needs patching to use anaconda cc / g++ directly
63-
64-
6560
### tzlocal issue with pytz == 1.5.1
6661

6762
```

setup.py

+22-18
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,39 @@
2323
from setuptools.command.test import test as TestCommand
2424
import sys
2525
import os
26+
import subprocess
2627
import platform
2728

28-
2929
link_args = ['-fopenmp']
3030
# Avoid compiling error with prange. Similar to http://stackoverflow.com/questions/36577182/unable-to-assign-value-to-array-in-prange
3131
compile_args = ['-fopenmp', '-fpermissive']
3232

3333
if platform.system().lower() == 'darwin':
34-
# clang on macOS does not work with OpenMP
35-
ccs = ["/usr/local/bin/g++-5",
36-
"/usr/local/bin/g++-6",
37-
"/usr/local/bin/g++-7",
38-
"/usr/local/opt/llvm/bin/clang"]
39-
cc = None
40-
for compiler in ccs:
41-
if os.path.isfile(compiler):
42-
cc = compiler
43-
if cc is None:
44-
raise ValueError("You must install clang-6.0 or gcc/g++. You can install with homebrew: brew install gcc or brew install llvm")
45-
if 'clang' in cc and os.path.isdir("/usr/local/opt/libomp")==False:
46-
raise ValueError("You must also install libomp. You can install with homebrew: brew install libomp")
47-
os.environ["CC"] = cc if 'clang' in cc else cc.replace("g++", "gcc")
48-
os.environ["CXX"] = cc
34+
# if a recent compiler on PATH (e.g. from anaconda) then let's use that
35+
gcc_out = subprocess.check_output(['gcc', '-v'], stderr=subprocess.STDOUT)
36+
if b'LLVM' in gcc_out:
37+
# clang on macOS does not work with OpenMP
38+
ccs = ["/usr/local/bin/g++-5",
39+
"/usr/local/bin/g++-6",
40+
"/usr/local/bin/g++-7",
41+
"/usr/local/opt/llvm/bin/clang"]
42+
cc = None
43+
for compiler in ccs:
44+
if os.path.isfile(compiler):
45+
cc = compiler
46+
if cc is None:
47+
raise ValueError("You must install clang-6.0 or gcc/g++. You can install with homebrew: brew install gcc or brew install llvm")
48+
if 'clang' in cc and os.path.isdir("/usr/local/opt/libomp")==False:
49+
raise ValueError("You must also install libomp. You can install with homebrew: brew install libomp")
50+
os.environ["CC"] = cc if 'clang' in cc else cc.replace("g++", "gcc")
51+
os.environ["CXX"] = cc
52+
if 'clang' in cc:
53+
link_args = ['-fopenmp=libomp']
54+
4955
# not all OSX/clang compiler flags supported by GCC. For some reason
5056
# these sometimes are generated and used. Cython will still add more flags.
5157
os.environ["CFLAGS"] = "-fno-common -fno-strict-aliasing -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -g -fwrapv -Os"
5258

53-
if 'clang' in cc:
54-
link_args = ['-fopenmp=libomp']
5559
elif platform.system().lower() == 'windows':
5660
compile_args = ['/openmp']
5761
link_args = []

0 commit comments

Comments
 (0)