Skip to content

Commit 60d25bf

Browse files
authored
Merge pull request #14573 from velconia/add_py36_py37_ubuntu_dockerfile
Add python3.6 python3.7 support in ubuntu dockerfile
2 parents 9dad45c + 05e6a71 commit 60d25bf

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,27 @@ ENV HOME /root
2222
# Add bash enhancements
2323
COPY ./paddle/scripts/docker/root/ /root/
2424

25+
# Prepare packages for Python
26+
RUN apt-get update && \
27+
apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
28+
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
29+
xz-utils tk-dev libffi-dev liblzma-dev
30+
31+
# Install Python3.6
32+
RUN mkdir -p /root/python_build/ && wget -q https://www.sqlite.org/2018/sqlite-autoconf-3250300.tar.gz && \
33+
tar -zxf sqlite-autoconf-3250300.tar.gz && cd sqlite-autoconf-3250300 && \
34+
./configure -prefix=/usr/local && make -j8 && make install && cd ../ && rm sqlite-autoconf-3250300.tar.gz && \
35+
wget -q https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz && \
36+
tar -xzf Python-3.6.0.tgz && cd Python-3.6.0 && \
37+
CFLAGS="-Wformat" ./configure --prefix=/usr/local/ --enable-shared > /dev/null && \
38+
make -j8 > /dev/null && make altinstall > /dev/null
39+
40+
# Install Python3.7
41+
RUN wget -q https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz && \
42+
tar -xzf Python-3.7.0.tgz && cd Python-3.7.0 && \
43+
CFLAGS="-Wformat" ./configure --prefix=/usr/local/ --enable-shared > /dev/null && \
44+
make -j8 > /dev/null && make altinstall > /dev/null
45+
2546
RUN apt-get update && \
2647
apt-get install -y --allow-downgrades patchelf \
2748
python3 python3-dev python3-pip \
@@ -74,6 +95,12 @@ RUN localedef -i en_US -f UTF-8 en_US.UTF-8
7495
RUN pip3 install -U wheel && \
7596
pip3 install -U docopt PyYAML sphinx==1.5.6 && \
7697
pip3 install sphinx-rtd-theme==0.1.9 recommonmark && \
98+
pip3.6 install -U wheel && \
99+
pip3.6 install -U docopt PyYAML sphinx==1.5.6 && \
100+
pip3.6 install sphinx-rtd-theme==0.1.9 recommonmark && \
101+
pip3.7 install -U wheel && \
102+
pip3.7 install -U docopt PyYAML sphinx==1.5.6 && \
103+
pip3.7 install sphinx-rtd-theme==0.1.9 recommonmark && \
77104
easy_install -U pip && \
78105
pip install -U pip setuptools wheel && \
79106
pip install -U docopt PyYAML sphinx==1.5.6 && \
@@ -82,22 +109,34 @@ RUN pip3 install -U wheel && \
82109
RUN pip3 install 'pre-commit==1.10.4' 'ipython==5.3.0' && \
83110
pip3 install 'ipykernel==4.6.0' 'jupyter==1.0.0' && \
84111
pip3 install opencv-python && \
112+
pip3.6 install 'pre-commit==1.10.4' 'ipython==5.3.0' && \
113+
pip3.6 install 'ipykernel==4.6.0' 'jupyter==1.0.0' && \
114+
pip3.6 install opencv-python && \
115+
pip3.7 install 'pre-commit==1.10.4' 'ipython==5.3.0' && \
116+
pip3.7 install 'ipykernel==4.6.0' 'jupyter==1.0.0' && \
117+
pip3.7 install opencv-python && \
85118
pip install 'pre-commit==1.10.4' 'ipython==5.3.0' && \
86119
pip install 'ipykernel==4.6.0' 'jupyter==1.0.0' && \
87120
pip install opencv-python
88121

89122
#For docstring checker
90123
RUN pip3 install pylint pytest astroid isort
124+
RUN pip3.6 install pylint pytest astroid isort
125+
RUN pip3.7 install pylint pytest astroid isort
91126
RUN pip install pylint pytest astroid isort LinkChecker
92127

93128
COPY ./python/requirements.txt /root/
94129
RUN pip3 install -r /root/requirements.txt
130+
RUN pip3.6 install -r /root/requirements.txt
131+
RUN pip3.7 install -r /root/requirements.txt
95132
RUN pip install -r /root/requirements.txt
96133

97134
# To fix https://github.com/PaddlePaddle/Paddle/issues/1954, we use
98135
# the solution in https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl-py2
99136
RUN apt-get install -y libssl-dev libffi-dev
100137
RUN pip3 install certifi urllib3[secure]
138+
RUN pip3.6 install certifi urllib3[secure]
139+
RUN pip3.7 install certifi urllib3[secure]
101140
RUN pip install certifi urllib3[secure]
102141

103142

0 commit comments

Comments
 (0)