Skip to content

Commit d96ef9b

Browse files
committed
- updated Makefile.config for building SNAP for many python versions on macOS and Windows
- made a few minor updates in Makefile - removed -py3 argument for SWIG
1 parent c76e8bd commit d96ef9b

File tree

2 files changed

+108
-57
lines changed

2 files changed

+108
-57
lines changed

Makefile.config

Lines changed: 102 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -52,72 +52,123 @@ ifeq ($(UNAME), Linux)
5252
endif
5353
else ifeq ($(UNAME), Darwin)
5454
# OS X flags
55-
PY_CONDA3 := $(shell which python3 | grep conda3)
56-
PY_BREW := $(shell which python3 | grep local)
57-
5855
CC = g++
5956
SWIGFLAGS += -D_CMPWARN -D__stdcall -DSW_SNAPPY -DNONUMPY
57+
CXXFLAGS = -std=c++98 -fwrapv -Wall -Wno-unknown-pragmas -O3 -DNDEBUG -DNOMP -DSW_SNAPPY
6058
CXXFLAGS += -DSW_SNAPPY
61-
IFLAGS := $(shell python-config --includes)
62-
IFLAGS3 := $(shell python3-config --includes)
63-
LDFLAGS := $(shell python-config --ldflags) -dynamiclib -headerpad_max_install_names
64-
LDFLAGS3 := $(shell python3-config --ldflags) -dynamiclib -headerpad_max_install_names
65-
CLANG := $(shell g++ -v 2>&1 | grep clang | cut -d " " -f 2)
66-
ifeq ($(CLANG), LLVM)
67-
CXXFLAGS += -DNOMP
68-
CXXOPENMP =
69-
else ifeq ($(CLANG), clang)
70-
CXXFLAGS += -DNOMP
71-
CXXOPENMP =
72-
else
73-
#SWIGFLAGS += -DGCC_ATOMIC
74-
CXXFLAGS += -fopenmp
75-
LDFLAGS += -fopenmp
76-
#CXXOPENMP += -fopenmp
77-
endif
78-
ifneq ($(PY_CONDA3), )
79-
CC = x86_64-apple-darwin13.4.0-clang
80-
CXXFLAGS = -std=c++98 -Wall -Wno-unknown-pragmas -O3
81-
CXXFLAGS += -fPIC -flto -mmacosx-version-min=10.9
82-
CXXFLAGS += -DNDEBUG -DSW_SNAPPY -DNOMP
83-
CXXFLAGS += -isystem $(CONDA_PREFIX)/include
84-
IFLAGS3 = -I$(CONDA_PREFIX)/include/python3.7m
85-
LDFLAGS3 = -bundle -undefined dynamic_lookup -flto -arch x86_64 -mmacosx-version-min=10.9
86-
LDFLAGS3 += -isystem $(CONDA_PREFIX)/include
87-
LDFLAGS3 += -L$(CONDA_PREFIX)/lib
88-
LIBS =
89-
endif
90-
91-
ifneq ($(PY_BREW), )
92-
CC = clang
93-
CXXFLAGS = -std=c++98 -Wall -Wno-unknown-pragmas -O3
94-
CXXFLAGS += -dynamic
95-
CXXFLAGS += -DNDEBUG -DSW_SNAPPY -DNOMP
96-
CXXFLAGS += -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
97-
IFLAGS3 = -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include
98-
IFLAGS3 += -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers
99-
IFLAGS3 += -I/usr/local/include
100-
IFLAGS3 += -I/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/include/python3.7m
101-
LDFLAGS3 = -bundle -undefined dynamic_lookup -flto
102-
LDFLAGS3 += -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
103-
LDFLAGS3 += -L/usr/local/lib
104-
LIBS =
105-
endif
10659

10760
MANIFEST = MANIFEST.mac
10861
MANIFEST_IN = MANIFEST.in.nx
10962
PYTHON = python
11063
PYTHON3 = python3
64+
IFLAGS = -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include
65+
IFLAGS3 = $(IFLAGS)
66+
LDFLAGS = -bundle -undefined dynamic_lookup
67+
LDFLAGS += -L/usr/local/opt/readline/lib -L/usr/local/opt/[email protected]/lib
68+
LDFLAGS3 = $(LDFLAGS)
69+
# SNAP_PY is set externally for the python build environment
70+
ifeq ($(SNAP_PY), 2.7)
71+
PYPATH = /Users/rok/.pyenv/versions/2.7.18
72+
CXXFLAGS += -fno-strict-aliasing
73+
IFLAGS += -I$(PYPATH)/include/python2.7
74+
LDFLAGS += -L$(PYPATH)/lib
75+
else ifeq ($(SNAP_PY), 3.5)
76+
PYPATH = /Users/rok/.pyenv/versions/3.5.10
77+
IFLAGS3 += -I$(PYPATH)/include/python3.5m
78+
LDFLAGS3 += -L$(PYPATH)/lib
79+
else ifeq ($(SNAP_PY), 3.6)
80+
PYPATH = /Users/rok/.pyenv/versions/3.6.12
81+
IFLAGS3 += -I$(PYPATH)/include/python3.6m
82+
LDFLAGS3 += -L$(PYPATH)/lib
83+
else ifeq ($(SNAP_PY), 3.7)
84+
PYPATH = /Users/rok/.pyenv/versions/3.7.9
85+
IFLAGS3 += -I$(PYPATH)/include/python3.7m
86+
LDFLAGS3 += -L$(PYPATH)/lib
87+
else ifeq ($(SNAP_PY), 3.8)
88+
PYPATH = /Users/rok/.pyenv/versions/3.8.6
89+
IFLAGS3 += -I$(PYPATH)/include/python3.8
90+
LDFLAGS3 += -L$(PYPATH)/lib
91+
else ifeq ($(SNAP_PY), 3.9)
92+
PYPATH = /Users/rok/.pyenv/versions/3.9.0
93+
IFLAGS3 += -I$(PYPATH)/include/python3.9
94+
LDFLAGS3 += -L$(PYPATH)/lib
95+
else
96+
97+
# the build environment is not specified, try to figure out the parameters
98+
PY_CONDA3 := $(shell which python3 | grep conda3)
99+
PY_BREW := $(shell which python3 | grep local)
100+
101+
IFLAGS := $(shell python-config --includes)
102+
IFLAGS3 := $(shell python3-config --includes)
103+
LDFLAGS := $(shell python-config --ldflags) -dynamiclib -headerpad_max_install_names
104+
LDFLAGS3 := $(shell python3-config --ldflags) -dynamiclib -headerpad_max_install_names
105+
CLANG := $(shell g++ -v 2>&1 | grep clang | cut -d " " -f 2)
106+
ifeq ($(CLANG), LLVM)
107+
CXXFLAGS += -DNOMP
108+
CXXOPENMP =
109+
else ifeq ($(CLANG), clang)
110+
CXXFLAGS += -DNOMP
111+
CXXOPENMP =
112+
else
113+
#SWIGFLAGS += -DGCC_ATOMIC
114+
CXXFLAGS += -fopenmp
115+
LDFLAGS += -fopenmp
116+
#CXXOPENMP += -fopenmp
117+
endif
118+
ifneq ($(PY_CONDA3), )
119+
CC = x86_64-apple-darwin13.4.0-clang
120+
CXXFLAGS = -std=c++98 -Wall -Wno-unknown-pragmas -O3
121+
CXXFLAGS += -fPIC -flto -mmacosx-version-min=10.9
122+
CXXFLAGS += -DNDEBUG -DSW_SNAPPY -DNOMP
123+
CXXFLAGS += -isystem $(CONDA_PREFIX)/include
124+
IFLAGS3 = -I$(CONDA_PREFIX)/include/python3.7m
125+
LDFLAGS3 = -bundle -undefined dynamic_lookup -flto -arch x86_64 -mmacosx-version-min=10.9
126+
LDFLAGS3 += -isystem $(CONDA_PREFIX)/include
127+
LDFLAGS3 += -L$(CONDA_PREFIX)/lib
128+
LIBS =
129+
endif
130+
131+
ifneq ($(PY_BREW), )
132+
CC = clang
133+
CXXFLAGS = -std=c++98 -Wall -Wno-unknown-pragmas -O3
134+
CXXFLAGS += -dynamic
135+
CXXFLAGS += -DNDEBUG -DSW_SNAPPY -DNOMP
136+
CXXFLAGS += -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
137+
IFLAGS3 = -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include
138+
IFLAGS3 += -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers
139+
IFLAGS3 += -I/usr/local/include
140+
IFLAGS3 += -I/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/include/python3.7m
141+
LDFLAGS3 = -bundle -undefined dynamic_lookup -flto
142+
LDFLAGS3 += -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
143+
LDFLAGS3 += -L/usr/local/lib
144+
LIBS =
145+
endif
146+
endif
147+
111148
else ifeq ($(shell uname -o), Cygwin)
112149
# Cygwin flags
113150
SWIGFLAGS += -D_CMPWARN -D__stdcall -DSW_SNAPPY -DNONUMPY
114151
CXXFLAGS += -shared -D__STDC_LIMIT_MACROS -DSW_SNAPPY
115152
LIBS += -lpython2.6
116153
MANIFEST = MANIFEST.win
117154
MANIFEST_IN = MANIFEST.in.win
118-
PYTHON = /cygdrive/c/Python27/python
119-
PYTHON3 = "/cygdrive/c/Program\ Files/Python37/python"
155+
156+
ifeq ($(SNAP_PY), 2.7)
157+
PYTHON = /cygdrive/c/Python27/python
158+
else ifeq ($(SNAP_PY), 3.5)
159+
PYTHON = /cygdrive/c/Program\ Files/Python35/python
160+
else ifeq ($(SNAP_PY), 3.6)
161+
PYTHON = /cygdrive/c/Program\ Files/Python36/python
162+
else ifeq ($(SNAP_PY), 3.7)
163+
PYTHON = /cygdrive/c/Program\ Files/Python37/python
164+
else ifeq ($(SNAP_PY), 3.8)
165+
PYTHON = /cygdrive/c/Program\ Files/Python38/python
166+
else ifeq ($(SNAP_PY), 3.9)
167+
PYTHON = /cygdrive/c/Program\ Files/Python39/python
168+
endif
169+
else
170+
PYTHON = "/cygdrive/c/Program\ Files/Python37/python"
120171
endif
121172

122-
SWIGFLAGS3 += -py3 $(SWIGFLAGS)
173+
SWIGFLAGS3 += $(SWIGFLAGS)
123174

swig/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,17 @@ srcdist-win: setup.py snap.py _snap.pyd
177177
$(PYTHON) setup.py sdist --formats=zip
178178
chmod 0644 dist/*.zip
179179

180-
srcdist3-win: setup.py snap.py _snap.pyd
181-
"$(PYTHON3)" setup.py sdist --formats=zip
182-
chmod 0644 dist/*.zip
183-
184180
whldist-win: setup.py snap.py _snap.pyd
181+
$(PYTHON) setup.py bdist_wheel
182+
183+
srcdist3-win: setup.py snap.py _snap.pyd
185184
cp $(MANIFEST) MANIFEST
186185
cp $(MANIFEST_IN) MANIFEST.in
187-
$(PYTHON) setup.py bdist_wheel
186+
$(PYTHON3) setup.py sdist --formats=zip
187+
chmod 0644 dist/*.zip
188188

189189
whldist3-win: setup.py snap.py _snap.pyd
190-
"$(PYTHON3)" setup.py bdist_wheel
190+
$(PYTHON3) setup.py bdist_wheel
191191

192192
clean:
193193
rm -f *.o *_wrap*.cxx _*.so *.pyc snap*.py _snap*.*

0 commit comments

Comments
 (0)