@@ -68,26 +68,44 @@ function cmake_gen() {
68
68
# Support build for all python versions, currently
69
69
# including cp27-cp27m and cp27-cp27mu.
70
70
PYTHON_FLAGS=" "
71
- if [ " $1 " != " " ]; then
72
- echo " using python abi: $1 "
73
- if [ " $1 " == " cp27-cp27m" ]; then
74
- export LD_LIBRARY_PATH=/opt/_internal/cpython-2.7.11-ucs2/lib:${LD_LIBRARY_PATH#/ opt/ _internal/ cpython-2.7.11-ucs4/ lib: }
75
- export PATH=/opt/python/cp27-cp27m/bin/:${PATH}
76
- PYTHON_FLAGS=" -DPYTHON_EXECUTABLE:FILEPATH=/opt/python/cp27-cp27m/bin/python
77
- -DPYTHON_INCLUDE_DIR:PATH=/opt/python/cp27-cp27m/include/python2.7
78
- -DPYTHON_LIBRARIES:FILEPATH=/opt/_internal/cpython-2.7.11-ucs2/lib/libpython2.7.so"
79
- elif [ " $1 " == " cp27-cp27mu" ]; then
80
- export LD_LIBRARY_PATH=/opt/_internal/cpython-2.7.11-ucs4/lib:${LD_LIBRARY_PATH#/ opt/ _internal/ cpython-2.7.11-ucs2/ lib: }
81
- export PATH=/opt/python/cp27-cp27mu/bin/:${PATH}
82
- PYTHON_FLAGS=" -DPYTHON_EXECUTABLE:FILEPATH=/opt/python/cp27-cp27mu/bin/python
83
- -DPYTHON_INCLUDE_DIR:PATH=/opt/python/cp27-cp27mu/include/python2.7
84
- -DPYTHON_LIBRARIES:FILEPATH=/opt/_internal/cpython-2.7.11-ucs4/lib/libpython2.7.so"
85
- elif [ " $1 " == " cp35-cp35m" ]; then
86
- export LD_LIBRARY_PATH=/opt/_internal/cpython-3.5.1/lib/:${LD_LIBRARY_PATH}
87
- export PATH=/opt/_internal/cpython-3.5.1/bin/:${PATH}
88
- export PYTHON_FLAGS=" -DPYTHON_EXECUTABLE:FILEPATH=/opt/_internal/cpython-3.5.1/bin/python3
71
+ SYSTEM=` uname -s`
72
+ if [ " $SYSTEM " == " Darwin" ]; then
73
+ if [[ " $1 " == " cp27-cp27m" ]] || [[ " $1 " == " " ]]; then
74
+ echo " using python abi: $1 "
75
+ if [ -d " /Library/Frameworks/Python.framework/Versions/2.7" ]; then
76
+ export LD_LIBRARY_PATH=/Library/Frameworks/Python.framework/Versions/2.7
77
+ export DYLD_LIBRARY_PATH=/Library/Frameworks/Python.framework/Versions/2.7
78
+ export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin/:${PATH}
79
+ PYTHON_FLAGS=" -DPYTHON_EXECUTABLE:FILEPATH=/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
80
+ -DPYTHON_INCLUDE_DIR:PATH=/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
81
+ -DPYTHON_LIBRARY:FILEPATH=/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib"
82
+ else
83
+ exit 1
84
+ fi
85
+ # TODO: qiyang add python3 part here
86
+ fi
87
+ else
88
+ if [ " $1 " != " " ]; then
89
+ echo " using python abi: $1 "
90
+ if [ " $1 " == " cp27-cp27m" ]; then
91
+ export LD_LIBRARY_PATH=/opt/_internal/cpython-2.7.11-ucs2/lib:${LD_LIBRARY_PATH#/ opt/ _internal/ cpython-2.7.11-ucs4/ lib: }
92
+ export PATH=/opt/python/cp27-cp27m/bin/:${PATH}
93
+ PYTHON_FLAGS=" -DPYTHON_EXECUTABLE:FILEPATH=/opt/python/cp27-cp27m/bin/python
94
+ -DPYTHON_INCLUDE_DIR:PATH=/opt/python/cp27-cp27m/include/python2.7
95
+ -DPYTHON_LIBRARIES:FILEPATH=/opt/_internal/cpython-2.7.11-ucs2/lib/libpython2.7.so"
96
+ elif [ " $1 " == " cp27-cp27mu" ]; then
97
+ export LD_LIBRARY_PATH=/opt/_internal/cpython-2.7.11-ucs4/lib:${LD_LIBRARY_PATH#/ opt/ _internal/ cpython-2.7.11-ucs2/ lib: }
98
+ export PATH=/opt/python/cp27-cp27mu/bin/:${PATH}
99
+ PYTHON_FLAGS=" -DPYTHON_EXECUTABLE:FILEPATH=/opt/python/cp27-cp27mu/bin/python
100
+ -DPYTHON_INCLUDE_DIR:PATH=/opt/python/cp27-cp27mu/include/python2.7
101
+ -DPYTHON_LIBRARIES:FILEPATH=/opt/_internal/cpython-2.7.11-ucs4/lib/libpython2.7.so"
102
+ elif [ " $1 " == " cp35-cp35m" ]; then
103
+ export LD_LIBRARY_PATH=/opt/_internal/cpython-3.5.1/lib/:${LD_LIBRARY_PATH}
104
+ export PATH=/opt/_internal/cpython-3.5.1/bin/:${PATH}
105
+ export PYTHON_FLAGS=" -DPYTHON_EXECUTABLE:FILEPATH=/opt/_internal/cpython-3.5.1/bin/python3
89
106
-DPYTHON_INCLUDE_DIR:PATH=/opt/_internal/cpython-3.5.1/include/python3.5m
90
107
-DPYTHON_LIBRARIES:FILEPATH=/opt/_internal/cpython-3.5.1/lib/libpython3.so"
108
+ fi
91
109
fi
92
110
fi
93
111
201
219
make install -j ` nproc`
202
220
}
203
221
222
+ function build_mac() {
223
+ mkdir -p ${PADDLE_ROOT} /build
224
+ cd ${PADDLE_ROOT} /build
225
+ cat << EOF
226
+ ============================================
227
+ Building in /paddle/build ...
228
+ ============================================
229
+ EOF
230
+ make clean
231
+ sudo make -j 8
232
+ sudo make install -j 8
233
+ }
234
+
204
235
function build_android() {
205
236
if [ $ANDROID_ABI == " arm64-v8a" ]; then
206
237
ANDROID_ARCH=arm64
324
355
fi
325
356
}
326
357
358
+ function run_mac_test() {
359
+ mkdir -p ${PADDLE_ROOT} /build
360
+ cd ${PADDLE_ROOT} /build
361
+ if [ ${WITH_TESTING:- ON} == " ON" ] ; then
362
+ cat << EOF
363
+ ========================================
364
+ Running unit tests ...
365
+ ========================================
366
+ EOF
367
+
368
+ # TODO: jiabin need to refine this part when these tests fixed on mac
369
+ ctest --output-on-failure -j8
370
+ # make install should also be test when unittest
371
+ make install -j 8
372
+ pip install /usr/local/opt/paddle/share/wheels/* .whl
373
+ if [[ ${WITH_FLUID_ONLY:- OFF} == " OFF" ]] ; then
374
+ paddle version
375
+ fi
376
+ fi
377
+ }
378
+
327
379
function assert_api_not_changed() {
328
380
mkdir -p ${PADDLE_ROOT} /build/.check_api_workspace
329
381
cd ${PADDLE_ROOT} /build/.check_api_workspace
@@ -677,6 +729,11 @@ function main() {
677
729
test_fluid_inference_lib
678
730
assert_api_spec_approvals
679
731
;;
732
+ maccheck)
733
+ cmake_gen ${PYTHON_ABI:- " " }
734
+ build_mac
735
+ run_mac_test
736
+ ;;
680
737
* )
681
738
print_usage
682
739
exit 0
0 commit comments