未验证 提交 05ec0757 编写于 作者: R Roc 提交者: GitHub

Limit Python version GE 3.7 (#46477)

上级 f4a6c539
......@@ -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})
......
......@@ -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})
......@@ -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()
......@@ -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!
......
......@@ -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
......
......@@ -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} \
......
......@@ -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
......@@ -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:
......
......@@ -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
......
......@@ -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] && \
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册