diff --git a/CMakeLists.txt b/CMakeLists.txt index 304852f71afd1f094f810c81854585f37511cf68..20f6413dfa7d28582fb5fd0a86e7a68c32616a5a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -323,7 +323,7 @@ unset(WITH_RECORD_BUILDTIME CACHE) # PY_VERSION if(NOT PY_VERSION) - set(PY_VERSION 3.6) + set(PY_VERSION 3.7) endif() set(PYBIND11_PYTHON_VERSION ${PY_VERSION}) diff --git a/cmake/external/python.cmake b/cmake/external/python.cmake index bc58c9d7b6c35f605b28f50d00c556a45ff836af..b8ab55f60418624fc5426b9940062e77c7557066 100644 --- a/cmake/external/python.cmake +++ b/cmake/external/python.cmake @@ -14,6 +14,9 @@ include(python_module) +check_py_version(${PY_VERSION}) + +# Find Python with mnimum PY_VERSION specified or will raise error! find_package(PythonInterp ${PY_VERSION} REQUIRED) find_package(PythonLibs ${PY_VERSION} REQUIRED) @@ -79,5 +82,6 @@ if(PYTHONINTERP_FOUND) "please use pip to upgrade protobuf. pip install -U protobuf") endif() endif(PYTHONINTERP_FOUND) + include_directories(${PYTHON_INCLUDE_DIR}) include_directories(${PYTHON_NUMPY_INCLUDE_DIR}) diff --git a/cmake/python_module.cmake b/cmake/python_module.cmake index 47e449c9dadb15192f0ed269a6f292af4bbdd43c..b4b6fce8cc34fadccac5fa4133f6b9c613232eb2 100644 --- a/cmake/python_module.cmake +++ b/cmake/python_module.cmake @@ -48,3 +48,20 @@ function(find_python_module module) ${PY_${module_upper}_VERSION} PARENT_SCOPE) endfunction() + +function(check_py_version py_version) + string(REPLACE "." ";" version_list ${py_version}) + list(LENGTH version_list version_list_len) + if(version_list_len LESS 2) + message(FATAL_ERROR "Please input Python version, eg:3.7 or 3.8 and so on") + endif() + + list(GET version_list 0 version_major) + list(GET version_list 1 version_minor) + + if((version_major GREATER_EQUAL 3) AND (version_minor GREATER_EQUAL 7)) + + else() + message(FATAL_ERROR "Paddle only support Python version >=3.7 now!") + endif() +endfunction() diff --git a/paddle/fluid/inference/api/demo_ci/run_windows_demo.bat b/paddle/fluid/inference/api/demo_ci/run_windows_demo.bat index d17f516fcca5e8fd3e254e31d3f30a09a717cc5b..6eb932a1906545a925ae3b36eba82475cd1f598e 100644 --- a/paddle/fluid/inference/api/demo_ci/run_windows_demo.bat +++ b/paddle/fluid/inference/api/demo_ci/run_windows_demo.bat @@ -101,7 +101,7 @@ if NOT EXIST "%source_path%\%model_name%.tar.gz" ( if EXIST "%source_path%\%model_name%.tar.gz" ( if NOT EXIST "%source_path%\%model_name%" ( - SET /P python_path="Please input the path of python.exe, such as C:\Python35\python.exe, C:\Python35\python3.exe =======>" + SET /P python_path="Please input the path of python.exe, such as C:\Python37\python.exe =======>" set tmp_var=!python_path! call:remove_space set python_path=!tmp_var! diff --git a/paddle/scripts/fast_install.sh b/paddle/scripts/fast_install.sh index cacec55d3bc228bb8d3c08c642719b5c0fefb772..d4e30d75c824b65ac9d089e4277142fc3e81434a 100644 --- a/paddle/scripts/fast_install.sh +++ b/paddle/scripts/fast_install.sh @@ -920,7 +920,7 @@ function checkMacPip(){ if [[ "$version_list" != "" ]];then return 0 else - red "未找到可用的pip或pip3。PaddlePaddle目前支持:Python2.7/3.5/3.6/3.7及其对应的pip, 请重新输入,或使用ctrl + c退出" + red "未找到可用的pip或pip3。PaddlePaddle目前支持:Python >= 3.7及其对应的pip, 请重新输入,或使用ctrl + c退出" echo clearMacPythonEnv return 1 diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index b39a8945eb7135af1a5ee2ab0a3d1d7166db3358..8a61ab633803e0cfee53a5c6e3e84adc61650e37 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -235,7 +235,7 @@ function cmake_base() { -DWITH_INFERENCE_API_TEST=${WITH_INFERENCE_API_TEST:-ON} -DWITH_INFRT=${WITH_INFRT:-OFF} -DINFERENCE_DEMO_INSTALL_DIR=${INFERENCE_DEMO_INSTALL_DIR} - -DPY_VERSION=${PY_VERSION:-2.7} + -DPY_VERSION=${PY_VERSION:-3.7} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX:-/paddle/build} -DWITH_PSCORE=${distibuted_flag} -DWITH_PSLIB=${WITH_PSLIB:-OFF} @@ -290,7 +290,7 @@ EOF -DWITH_INFERENCE_API_TEST=${WITH_INFERENCE_API_TEST:-ON} \ -DWITH_INFRT=${WITH_INFRT:-OFF} \ -DINFERENCE_DEMO_INSTALL_DIR=${INFERENCE_DEMO_INSTALL_DIR} \ - -DPY_VERSION=${PY_VERSION:-2.7} \ + -DPY_VERSION=${PY_VERSION:-3.7} \ -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX:-/paddle/build} \ -DWITH_PSCORE=${distibuted_flag} \ -DWITH_PSLIB=${WITH_PSLIB:-OFF} \ diff --git a/paddle/scripts/windows_build/config.ini b/paddle/scripts/windows_build/config.ini index 750d7af8c29266d93bcc8d2049ec1091933285a8..d5bfa548024ceba44ab1c3d29f057a67b7eb9732 100644 --- a/paddle/scripts/windows_build/config.ini +++ b/paddle/scripts/windows_build/config.ini @@ -16,4 +16,4 @@ PYTHON3_PATH=C:\Python37 CUDA_PATH="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0" "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0" -PYTHON_PATH=C:\Python27 C:\Python37 \ No newline at end of file +PYTHON_PATH=C:\Python37 diff --git a/python/setup.py.in b/python/setup.py.in index 14ebb8749baa68522712787727cdd16393f945cf..0e25a34f801d58e790422bd3a7ff9b8895112b06 100755 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -418,22 +418,9 @@ packages=['paddle', with open('@PADDLE_SOURCE_DIR@/python/requirements.txt') as f: setup_requires = f.read().splitlines() -# Note(wangzhongpu): -# When compiling paddle under python36, the dependencies belonging to python2.7 will be imported, resulting in errors when installing paddle -if sys.version_info >= (3,6) and sys.version_info < (3,7): - setup_requires_tmp = [] - for setup_requires_i in setup_requires: - if "<\"3.6\"" in setup_requires_i or "<\"3.5\"" in setup_requires_i or "<=\"3.5\"" in setup_requires_i: - continue - setup_requires_tmp+=[setup_requires_i] - setup_requires = setup_requires_tmp -if sys.version_info >= (3,5) and sys.version_info < (3,6): - setup_requires_tmp = [] - for setup_requires_i in setup_requires: - if "<\"3.5\"" in setup_requires_i: - continue - setup_requires_tmp+=[setup_requires_i] - setup_requires = setup_requires_tmp +if sys.version_info < (3,7): + raise RuntimeError("Paddle only support Python version>=3.7 now") + if sys.version_info >= (3,7): setup_requires_tmp = [] for setup_requires_i in setup_requires: diff --git a/tools/dockerfile/Dockerfile.release16 b/tools/dockerfile/Dockerfile.release16 index 49637a3fee9a4e438626088726cec86d83e50078..8345fb4d966fa87df6cdede9d911937015513112 100644 --- a/tools/dockerfile/Dockerfile.release16 +++ b/tools/dockerfile/Dockerfile.release16 @@ -62,7 +62,7 @@ ENV CPLUS_INCLUDE_PATH=/usr/local/python3.7.0/include/python3.7:$CPLUS_INCLUDE_P RUN ln -sf /usr/local/python3.7.0/bin/python3.7 /usr/local/bin/python3 && ln -sf /usr/local/python3.7.0/bin/python3.7 /usr/bin/python3 RUN mv /usr/bin/python /usr/bin/python.bak && ln -s /usr/local/python3.7.0/bin/python3.7 /usr/local/bin/python && ln -s /usr/local/python3.7.0/bin/python3.7 /usr/bin/python -RUN rm -r /root/python_build +RUN rm -rf /root/python_build WORKDIR /home RUN python3.7 -m pip uninstall -y pip setuptools diff --git a/tools/dockerfile/Dockerfile.ubuntu b/tools/dockerfile/Dockerfile.ubuntu index 7c9636d57ddf541319efb6111ddc73bdd92e92ca..ad64deb8a22843b9327f0a647fab21ed79513989 100644 --- a/tools/dockerfile/Dockerfile.ubuntu +++ b/tools/dockerfile/Dockerfile.ubuntu @@ -45,15 +45,6 @@ WORKDIR /home RUN wget -q https://cmake.org/files/v3.16/cmake-3.16.0-Linux-x86_64.tar.gz && tar -zxvf cmake-3.16.0-Linux-x86_64.tar.gz && rm cmake-3.16.0-Linux-x86_64.tar.gz ENV PATH=/home/cmake-3.16.0-Linux-x86_64/bin:$PATH -# Install Python3.6 -RUN mkdir -p /root/python_build/ && wget -q https://paddle-ci.gz.bcebos.com/sqlite-autoconf-3250300.tar.gz && \ - tar -zxf sqlite-autoconf-3250300.tar.gz && cd sqlite-autoconf-3250300 && \ - ./configure -prefix=/usr/local && make -j8 && make install && cd ../ && rm sqlite-autoconf-3250300.tar.gz && \ - wget -q https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz && \ - tar -xzf Python-3.6.0.tgz && cd Python-3.6.0 && \ - CFLAGS="-Wformat" ./configure --prefix=/usr/local/ --enable-shared > /dev/null && \ - make -j8 > /dev/null && make altinstall > /dev/null && ldconfig - # Install Python3.7 RUN wget -q https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz && \ tar -xzf Python-3.7.0.tgz && cd Python-3.7.0 && \ @@ -78,7 +69,7 @@ ENV LD_LIBRARY_PATH=/usr/local/python3.7.0/lib:${LD_LIBRARY_PATH} ENV CPLUS_INCLUDE_PATH=/usr/local/python3.7.0/include/python3.7:$CPLUS_INCLUDE_PATH RUN ln -sf /usr/local/python3.7.0/bin/python3.7 /usr/local/bin/python3 && ln -sf /usr/local/python3.7.0/bin/python3.7 /usr/bin/python3 -RUN rm -r /root/python_build +RUN rm -rf /root/python_build # Install Python2.7.15 to replace original python WORKDIR /home @@ -101,22 +92,21 @@ RUN python setup.py build && python setup.py install WORKDIR /home RUN python3.9 -m pip uninstall -y pip setuptools && \ python3.8 -m pip uninstall -y pip setuptools && \ - python3.7 -m pip uninstall -y pip setuptools && \ - python3.6 -m pip uninstall -y pip setuptools + python3.7 -m pip uninstall -y pip setuptools + RUN wget https://files.pythonhosted.org/packages/a7/e0/30642b9c2df516506d40b563b0cbd080c49c6b3f11a70b4c7a670f13a78b/setuptools-50.3.2.zip && apt-get -y install unzip && unzip setuptools-50.3.2.zip WORKDIR /home/setuptools-50.3.2 RUN python3.9 setup.py build && python3.9 setup.py install && \ python3.8 setup.py build && python3.8 setup.py install && \ - python3.7 setup.py build && python3.7 setup.py install && \ - python3.6 setup.py build && python3.6 setup.py install + python3.7 setup.py build && python3.7 setup.py install + WORKDIR /home RUN wget https://files.pythonhosted.org/packages/28/af/2c76c8aa46ccdf7578b83d97a11a2d1858794d4be4a1610ade0d30182e8b/pip-20.0.1.tar.gz && tar -zxvf pip-20.0.1.tar.gz WORKDIR pip-20.0.1 RUN python setup.py install && \ python3.9 setup.py install && \ python3.8 setup.py install && \ - python3.7 setup.py install && \ - python3.6 setup.py install + python3.7 setup.py install WORKDIR /home RUN rm Python-$version.tgz setuptools-40.6.2.zip setuptools-50.3.2.zip pip-20.0.1.tar.gz && \ @@ -162,10 +152,7 @@ RUN localedef -i en_US -f UTF-8 en_US.UTF-8 # specify sphinx version as 1.5.6 and remove -U option for [pip install -U # sphinx-rtd-theme] since -U option will cause sphinx being updated to newest # version(1.7.1 for now), which causes building documentation failed. -RUN pip3.6 --no-cache-dir install -U wheel py-cpuinfo==5.0.0 && \ - pip3.6 --no-cache-dir install -U docopt PyYAML sphinx==1.5.6 && \ - pip3.6 --no-cache-dir install sphinx-rtd-theme==0.1.9 recommonmark && \ - pip3.7 --no-cache-dir install -U wheel py-cpuinfo==5.0.0 && \ +RUN pip3.7 --no-cache-dir install -U wheel py-cpuinfo==5.0.0 && \ pip3.7 --no-cache-dir install -U docopt PyYAML sphinx==1.5.6 && \ pip3.7 --no-cache-dir install sphinx-rtd-theme==0.1.9 recommonmark && \ pip3.8 --no-cache-dir install -U wheel py-cpuinfo==5.0.0 && \ @@ -177,9 +164,7 @@ RUN pip3.6 --no-cache-dir install -U wheel py-cpuinfo==5.0.0 && \ pip --no-cache-dir install -U docopt PyYAML sphinx==1.5.6 && \ pip --no-cache-dir install sphinx-rtd-theme==0.1.9 recommonmark -RUN pip3.6 --no-cache-dir install 'ipython==5.3.0' && \ - pip3.6 --no-cache-dir install 'ipykernel==4.6.0' 'jupyter==1.0.0' && \ - pip3.7 --no-cache-dir install 'ipython==5.3.0' && \ +RUN pip3.7 --no-cache-dir install 'ipython==5.3.0' && \ pip3.7 --no-cache-dir install 'ipykernel==4.6.0' 'jupyter==1.0.0' && \ pip3.8 --no-cache-dir install 'ipython==5.3.0' && \ pip3.8 --no-cache-dir install 'ipykernel==4.6.0' 'jupyter==1.0.0' && \ @@ -189,43 +174,36 @@ RUN pip3.6 --no-cache-dir install 'ipython==5.3.0' && \ pip --no-cache-dir install 'ipykernel==4.6.0' 'jupyter==1.0.0' #For docstring checker -RUN pip3.6 --no-cache-dir install pytest astroid isort && \ - pip3.7 --no-cache-dir install pytest astroid isort && \ +RUN pip3.7 --no-cache-dir install pytest astroid isort && \ pip3.8 --no-cache-dir install pytest astroid isort && \ pip3.9 --no-cache-dir install pytest astroid isort && \ pip --no-cache-dir install pylint pytest astroid isort #For pre-commit -RUN pip3.6 --no-cache-dir install --upgrade pip==20.3.3 && \ - pip3.7 --no-cache-dir install --upgrade pip && \ +RUN pip3.7 --no-cache-dir install --upgrade pip && \ pip3.8 --no-cache-dir install --upgrade pip && \ pip3.9 --no-cache-dir install --upgrade pip -RUN pip3.6 --no-cache-dir install pre-commit==2.1.1 pylint==2.12.0 && \ - pip3.7 --no-cache-dir install pre-commit==2.17.0 pylint==2.12.0 && \ +RUN pip3.7 --no-cache-dir install pre-commit==2.17.0 pylint==2.12.0 && \ pip3.8 --no-cache-dir install pre-commit==2.17.0 pylint==2.12.0 && \ pip3.9 --no-cache-dir install pre-commit==2.17.0 pylint==2.12.0 && \ - pip3.6 --no-cache-dir install cpplint==1.6.0 clang-format==13.0.0 && \ pip3.7 --no-cache-dir install cpplint==1.6.0 clang-format==13.0.0 && \ pip3.8 --no-cache-dir install cpplint==1.6.0 clang-format==13.0.0 && \ pip3.9 --no-cache-dir install cpplint==1.6.0 clang-format==13.0.0 -RUN pip3.6 --no-cache-dir install coverage && \ - pip3.7 --no-cache-dir install coverage && \ +RUN pip3.7 --no-cache-dir install coverage && \ pip3.8 --no-cache-dir install coverage && \ pip3.9 --no-cache-dir install coverage && \ pip --no-cache-dir install coverage COPY ./python/requirements.txt /root/ -RUN pip3.6 --no-cache-dir install -r /root/requirements.txt && \ - pip3.7 --no-cache-dir install -r /root/requirements.txt && \ +RUN pip3.7 --no-cache-dir install -r /root/requirements.txt && \ pip3.8 --no-cache-dir install -r /root/requirements.txt && \ pip3.9 --no-cache-dir install -r /root/requirements.txt # To fix https://github.com/PaddlePaddle/Paddle/issues/1954, we use # the solution in https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl-py2 RUN apt-get install -y libssl-dev libffi-dev && apt-get clean -y && \ - pip3.6 --no-cache-dir install certifi urllib3[secure] && \ pip3.7 --no-cache-dir install certifi urllib3[secure] && \ pip3.8 --no-cache-dir install certifi urllib3[secure] && \ pip3.9 --no-cache-dir install certifi urllib3[secure] && \ diff --git a/tools/dockerfile/Dockerfile.ubuntu18 b/tools/dockerfile/Dockerfile.ubuntu18 index 8ebfd9b8371c20a049669b8bdb8309b764335625..35397967f283f64c0908ea99bee05deb207db564 100644 --- a/tools/dockerfile/Dockerfile.ubuntu18 +++ b/tools/dockerfile/Dockerfile.ubuntu18 @@ -55,9 +55,7 @@ ENV PATH=/home/cmake-3.16.0-Linux-x86_64/bin:$PATH RUN apt-get update && \ - apt-get install -y python2.7 python2.7-dev \ - python3.6 python3.6-dev \ - python3.7 python3.7-dev \ + apt-get install -y python3.7 python3.7-dev \ python3.8 python3.8-dev python3.8-distutils \ python3.9 python3.9-dev python3.9-distutils && \ rm /usr/bin/python && ln -s /usr/bin/python3.7 /usr/bin/python && \ @@ -69,24 +67,19 @@ RUN wget https://files.pythonhosted.org/packages/a7/e0/30642b9c2df516506d40b563b WORKDIR /home/setuptools-50.3.2 RUN python3.9 setup.py build && python3.9 setup.py install && \ python3.8 setup.py build && python3.8 setup.py install && \ - python3.7 setup.py build && python3.7 setup.py install && \ - python3.6 setup.py build && python3.6 setup.py install -WORKDIR /home -RUN wget https://files.pythonhosted.org/packages/b0/d1/8acb42f391cba52e35b131e442e80deffbb8d0676b93261d761b1f0ef8fb/setuptools-40.6.2.zip && apt-get -y install unzip && unzip setuptools-40.6.2.zip -WORKDIR /home/setuptools-40.6.2 -RUN python2.7 setup.py build && python2.7 setup.py install + python3.7 setup.py build && python3.7 setup.py install + WORKDIR /home RUN wget https://files.pythonhosted.org/packages/28/af/2c76c8aa46ccdf7578b83d97a11a2d1858794d4be4a1610ade0d30182e8b/pip-20.0.1.tar.gz && tar -zxvf pip-20.0.1.tar.gz WORKDIR pip-20.0.1 -RUN python2.7 setup.py install && \ - python3.9 setup.py install && \ + +RUN python3.9 setup.py install && \ python3.8 setup.py install && \ - python3.7 setup.py install && \ - python3.6 setup.py install + python3.7 setup.py install WORKDIR /home -RUN rm setuptools-40.6.2.zip setuptools-50.3.2.zip pip-20.0.1.tar.gz && \ - rm -r setuptools-40.6.2 setuptools-50.3.2 pip-20.0.1 +RUN rm setuptools-50.3.2.zip pip-20.0.1.tar.gz && \ + rm -r setuptools-50.3.2 pip-20.0.1 RUN rm /usr/local/bin/pip && ln -s /usr/local/bin/pip3.7 /usr/local/bin/pip && \ rm /usr/local/bin/pip3 && ln -s /usr/local/bin/pip3.7 /usr/local/bin/pip3 @@ -116,42 +109,32 @@ RUN git config --global credential.helper store # Fix locales to en_US.UTF-8 RUN localedef -i en_US -f UTF-8 en_US.UTF-8 -RUN pip3.6 --no-cache-dir install ipython==5.3.0 && \ - pip3.6 --no-cache-dir install ipykernel==4.6.0 wheel && \ - pip3.7 --no-cache-dir install ipython==5.3.0 && \ +RUN pip3.7 --no-cache-dir install ipython==5.3.0 && \ pip3.7 --no-cache-dir install ipykernel==4.6.0 wheel && \ pip3.8 --no-cache-dir install ipython==5.3.0 && \ pip3.8 --no-cache-dir install ipykernel==4.6.0 wheel && \ pip3.9 --no-cache-dir install ipython==5.3.0 && \ - pip3.9 --no-cache-dir install ipykernel==4.6.0 wheel && \ - pip2.7 --no-cache-dir install pre-commit==1.10.4 ipython==5.3.0 && \ - pip2.7 --no-cache-dir install ipykernel==4.6.0 wheel + pip3.9 --no-cache-dir install ipykernel==4.6.0 wheel #For docstring checker -RUN pip3.6 --no-cache-dir install pytest astroid isort && \ - pip3.7 --no-cache-dir install pytest astroid isort && \ +RUN pip3.7 --no-cache-dir install pytest astroid isort && \ pip3.8 --no-cache-dir install pytest astroid isort && \ - pip3.9 --no-cache-dir install pytest astroid isort && \ - pip2.7 --no-cache-dir install pytest astroid isort + pip3.9 --no-cache-dir install pytest astroid isort #For pre-commit -RUN pip3.6 --no-cache-dir install --upgrade pip==20.3.3 && \ - pip3.7 --no-cache-dir install --upgrade pip && \ +RUN pip3.7 --no-cache-dir install --upgrade pip && \ pip3.8 --no-cache-dir install --upgrade pip && \ pip3.9 --no-cache-dir install --upgrade pip -RUN pip3.6 --no-cache-dir install pre-commit==2.1.1 pylint==2.12.0 && \ - pip3.7 --no-cache-dir install pre-commit==2.17.0 pylint==2.12.0 && \ +RUN pip3.7 --no-cache-dir install pre-commit==2.17.0 pylint==2.12.0 && \ pip3.8 --no-cache-dir install pre-commit==2.17.0 pylint==2.12.0 && \ pip3.9 --no-cache-dir install pre-commit==2.17.0 pylint==2.12.0 && \ - pip3.6 --no-cache-dir install cpplint==1.6.0 clang-format==13.0.0 && \ pip3.7 --no-cache-dir install cpplint==1.6.0 clang-format==13.0.0 && \ pip3.8 --no-cache-dir install cpplint==1.6.0 clang-format==13.0.0 && \ pip3.9 --no-cache-dir install cpplint==1.6.0 clang-format==13.0.0 COPY ./python/requirements.txt /root/ -RUN pip3.6 --no-cache-dir install -r /root/requirements.txt && \ - pip3.7 --no-cache-dir install -r /root/requirements.txt && \ +RUN pip3.7 --no-cache-dir install -r /root/requirements.txt && \ pip3.8 --no-cache-dir install -r /root/requirements.txt && \ pip3.9 --no-cache-dir install -r /root/requirements.txt