From 001dd6df44582e3baae595a9ba87e1b3050dc6e4 Mon Sep 17 00:00:00 2001 From: risemeup1 <515586620@qq.com> Date: Thu, 8 Dec 2022 08:06:36 +0000 Subject: [PATCH 1/4] support py3 in setup.py --- paddle/scripts/paddle_build.sh | 37 +++++++++++----------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index 4e563496d3529..75cab3f23b152 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -3463,25 +3463,18 @@ function check_coverage_build() { } function run_setup(){ rm -rf ${PADDLE_ROOT}/build + # Build script will not fail if *.deb does not exist + rm *.deb 2>/dev/null || true + # Delete previous built egg packages + rm -rf ${PADDLE_ROOT}/dist 2>/dev/null || true + # Delete previous built paddle cache + rm -rf ${PADDLE_ROOT}/build/python/paddle 2>/dev/null || true startTime_s=`date +%s` SYSTEM=`uname -s` if [ "$SYSTEM" == "Darwin" ]; then echo "Using python abi: $1" - if [ "$1" == "cp36-cp36m" ] || [ "$1" == "" ]; then - if [ -d "/Library/Frameworks/Python.framework/Versions/3.6" ]; then - export LD_LIBRARY_PATH=/Library/Frameworks/Python.framework/Versions/3.6/lib/ - export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/Library/Frameworks/Python.framework/Versions/3.6/lib/ - export PATH=/Library/Frameworks/Python.framework/Versions/3.6/bin/:${PATH} - #after changing "PYTHON_LIBRARY:FILEPATH" to "PYTHON_LIBRARY" ,we can use export - export PYTHON_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/3.6/bin/python3 - export PYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m/ - export PYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6m.dylib - pip3.6 install --user -r ${PADDLE_ROOT}/python/requirements.txt - else - exit 1 - fi - elif [ "$1" == "cp37-cp37m" ]; then + if [ "$1" == "cp37-cp37m" ]; then if [ -d "/Library/Frameworks/Python.framework/Versions/3.7" ]; then export LD_LIBRARY_PATH=/Library/Frameworks/Python.framework/Versions/3.7/lib/ export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/Library/Frameworks/Python.framework/Versions/3.7/lib/ @@ -3490,7 +3483,6 @@ function run_setup(){ export PYTHON_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 export PYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m/ export PYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib - pip3.7 install --user -r ${PADDLE_ROOT}/python/requirements.txt else exit 1 @@ -3538,21 +3530,14 @@ function run_setup(){ else if [ "$1" != "" ]; then echo "using python abi: $1" - if [ "$1" == "cp36-cp36m" ]; then - export LD_LIBRARY_PATH=/opt/_internal/cpython-3.6.0/lib/:${LD_LIBRARY_PATH} - export PATH=/opt/_internal/cpython-3.6.0/bin/:${PATH} - #after changing "PYTHON_LIBRARY:FILEPATH" to "PYTHON_LIBRARY" ,we can use export - export PYTHON_EXECUTABLE=/opt/_internal/cpython-3.6.0/bin/python3 - export PYTHON_INCLUDE_DIR=/opt/_internal/cpython-3.6.0/include/python3.6m - export PYTHON_LIBRARIES=/opt/_internal/cpython-3.6.0/lib/libpython3.so - pip3.6 install -r ${PADDLE_ROOT}/python/requirements.txt - elif [ "$1" == "cp37-cp37m" ]; then + if [ "$1" == "cp37-cp37m" ]; then export LD_LIBRARY_PATH=/opt/_internal/cpython-3.7.0/lib/:${LD_LIBRARY_PATH} export PATH=/opt/_internal/cpython-3.7.0/bin/:${PATH} #after changing "PYTHON_LIBRARY:FILEPATH" to "PYTHON_LIBRARY" ,we can use export export PYTHON_EXECUTABLE=/opt/_internal/cpython-3.7.0/bin/python3.7 export PYTHON_INCLUDE_DIR=/opt/_internal/cpython-3.7.0/include/python3.7m export PYTHON_LIBRARIES=/opt/_internal/cpython-3.7.0/lib/libpython3.so + export PADDLE_CUSTOM_PATH=/opt/_internal/cpython-3.7.0/lib/python3.7/site-packages/paddlepaddle-0.0.0-py3.7-linux-x86_64.egg/paddle pip3.7 install -r ${PADDLE_ROOT}/python/requirements.txt elif [ "$1" == "cp38-cp38" ]; then export LD_LIBRARY_PATH=/opt/_internal/cpython-3.8.0/lib/:${LD_LIBRARY_PATH} @@ -3884,7 +3869,9 @@ function main() { build_mac ;; cicheck_py37) - cmake_gen_and_build ${PYTHON_ABI:-""} ${parallel_number} + # cmake_gen_and_build ${PYTHON_ABI:-""} ${parallel_number} + # run_linux_cpu_test ${PYTHON_ABI:-""} ${PROC_RUN:-1} + run_setup ${PYTHON_ABI:-""} run_linux_cpu_test ${PYTHON_ABI:-""} ${PROC_RUN:-1} ;; test_cicheck_py37) From 62a28ba477612bfd6cd1dfa28299a8037d035290 Mon Sep 17 00:00:00 2001 From: risemeup1 <515586620@qq.com> Date: Thu, 8 Dec 2022 14:50:42 +0000 Subject: [PATCH 2/4] support setup.py bdist_wheel in py3 --- paddle/scripts/paddle_build.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index 75cab3f23b152..b833af522f886 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -768,7 +768,7 @@ function run_linux_cpu_test() { mkdir -p ${PADDLE_ROOT}/build cd ${PADDLE_ROOT}/build pip install hypothesis - if [ -d "${PADDLE_ROOT}/build/python/dist/" ]; then + if [ -d "${PADDLE_ROOT}/dist/" ]; then pip install ${PADDLE_ROOT}/build/python/dist/*whl fi cp ${PADDLE_ROOT}/build/python/paddle/fluid/tests/unittests/op_test.py ${PADDLE_ROOT}/build/python @@ -3537,7 +3537,6 @@ function run_setup(){ export PYTHON_EXECUTABLE=/opt/_internal/cpython-3.7.0/bin/python3.7 export PYTHON_INCLUDE_DIR=/opt/_internal/cpython-3.7.0/include/python3.7m export PYTHON_LIBRARIES=/opt/_internal/cpython-3.7.0/lib/libpython3.so - export PADDLE_CUSTOM_PATH=/opt/_internal/cpython-3.7.0/lib/python3.7/site-packages/paddlepaddle-0.0.0-py3.7-linux-x86_64.egg/paddle pip3.7 install -r ${PADDLE_ROOT}/python/requirements.txt elif [ "$1" == "cp38-cp38" ]; then export LD_LIBRARY_PATH=/opt/_internal/cpython-3.8.0/lib/:${LD_LIBRARY_PATH} @@ -3649,7 +3648,7 @@ function run_setup(){ # reset ccache zero stats for collect PR's actual hit rate ccache -z - python setup.py install;build_error=$? + python setup.py bdist_wheel;build_error=$? # ci will collect ccache hit rate collect_ccache_hits From 5a64863ed8ec0240e268b74b7f68f4b5d7ac8878 Mon Sep 17 00:00:00 2001 From: risemeup1 <515586620@qq.com> Date: Thu, 8 Dec 2022 16:04:21 +0000 Subject: [PATCH 3/4] support py3 in setup.py --- paddle/scripts/paddle_build.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index b833af522f886..7ecd531bb1df7 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -769,7 +769,7 @@ function run_linux_cpu_test() { cd ${PADDLE_ROOT}/build pip install hypothesis if [ -d "${PADDLE_ROOT}/dist/" ]; then - pip install ${PADDLE_ROOT}/build/python/dist/*whl + pip install ${PADDLE_ROOT}/dist/*whl fi cp ${PADDLE_ROOT}/build/python/paddle/fluid/tests/unittests/op_test.py ${PADDLE_ROOT}/build/python cp ${PADDLE_ROOT}/build/python/paddle/fluid/tests/unittests/testsuite.py ${PADDLE_ROOT}/build/python @@ -3648,7 +3648,7 @@ function run_setup(){ # reset ccache zero stats for collect PR's actual hit rate ccache -z - python setup.py bdist_wheel;build_error=$? + python setup.py $2;build_error=$? # ci will collect ccache hit rate collect_ccache_hits @@ -3868,9 +3868,7 @@ function main() { build_mac ;; cicheck_py37) - # cmake_gen_and_build ${PYTHON_ABI:-""} ${parallel_number} - # run_linux_cpu_test ${PYTHON_ABI:-""} ${PROC_RUN:-1} - run_setup ${PYTHON_ABI:-""} + run_setup ${PYTHON_ABI:-""} bdist_wheel run_linux_cpu_test ${PYTHON_ABI:-""} ${PROC_RUN:-1} ;; test_cicheck_py37) From c74ec563d262d8073c7ebdfbb453e6b3ea276c0e Mon Sep 17 00:00:00 2001 From: risemeup1 <515586620@qq.com> Date: Thu, 8 Dec 2022 16:30:40 +0000 Subject: [PATCH 4/4] modify run_setup --- paddle/scripts/paddle_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index 7ecd531bb1df7..de75594642817 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -3881,7 +3881,7 @@ function main() { parallel_test ;; build_gpubox) - run_setup ${PYTHON_ABI:-""} + run_setup ${PYTHON_ABI:-""} install ;; check_xpu) cmake_gen_and_build ${PYTHON_ABI:-""} ${parallel_number}