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