Skip to content

Commit 03fa780

Browse files
Add uuid-dev, libffi-dev and update installer for Python 3.7 build
- uuid-dev is needed for uuid module - libffi-dev is needef for cytpes - update installer to be able to handle Python 3.6.8 or Python 3.7 as --with-threads is removed in Python 3.7 - Update Makefile to build Python 3.7.2 by default while still supporting Python 3.6.8 builds
1 parent d3d1c92 commit 03fa780

File tree

4 files changed

+44
-23
lines changed

4 files changed

+44
-23
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ WORKDIR /root
77

88
SHELL [ "/bin/bash", "-c" ]
99

10-
ARG PYTHON_VERSION_TAG=3.6.8
10+
ARG PYTHON_VERSION_TAG=3.7.2
1111
ARG LINK_PYTHON_TO_PYTHON3=1
1212

1313
# Existing lsb_release causes issues with modern installations of Python3
@@ -27,6 +27,8 @@ RUN apt-get -qq -y update && \
2727
libgdbm-compat-dev \
2828
liblzma-dev \
2929
libreadline-dev \
30+
uuid-dev \
31+
libffi-dev \
3032
wget \
3133
curl \
3234
git \

Makefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
default: all
1+
default: image
22

3-
all: image
3+
all: image py_3.6.8
44

55
image:
66
docker build -f Dockerfile \
77
--cache-from matthewfeickert/docker-python3-ubuntu:latest \
8-
--build-arg PYTHON_VERSION_TAG=3.6.8 \
8+
--build-arg PYTHON_VERSION_TAG=3.7.2 \
99
--build-arg LINK_PYTHON_TO_PYTHON3=1 \
1010
-t matthewfeickert/docker-python3-ubuntu:latest \
11+
-t matthewfeickert/docker-python3-ubuntu:3.7.2 \
12+
--compress .
13+
14+
py_3.6.8:
15+
docker build -f Dockerfile \
16+
--cache-from matthewfeickert/docker-python3-ubuntu:3.6.8 \
17+
--build-arg PYTHON_VERSION_TAG=3.6.8 \
18+
--build-arg LINK_PYTHON_TO_PYTHON3=1 \
19+
-t matthewfeickert/docker-python3-ubuntu:3.6.8 \
1120
--compress .

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Python3 on Ubuntu Docker
22

3-
Dockerfile for image built off [Ubuntu 18.04](https://wiki.ubuntu.com/BionicBeaver/ReleaseNotes/18.04) containing [Python 3.6](https://www.python.org/downloads/release/python-368/) built from source
3+
Dockerfile for image built off [Ubuntu 18.04](https://wiki.ubuntu.com/BionicBeaver/ReleaseNotes/18.04) containing [Python 3.7](https://www.python.org/downloads/release/python-372/) ([Python 3.6](https://www.python.org/downloads/release/python-368/)) built from source
44

55
[![Docker Automated build](https://img.shields.io/docker/automated/matthewfeickert/docker-python3-ubuntu.svg)](https://hub.docker.com/r/matthewfeickert/docker-python3-ubuntu/)
66
[![Docker Build Status](https://img.shields.io/docker/build/matthewfeickert/docker-python3-ubuntu.svg)](https://hub.docker.com/r/matthewfeickert/docker-python3-ubuntu/builds/)
@@ -23,6 +23,8 @@ Dockerfile for image built off [Ubuntu 18.04](https://wiki.ubuntu.com/BionicBeav
2323
- libgdbm-compat-dev
2424
- liblzma-dev
2525
- libreadline-dev
26+
- uuid-dev
27+
- libffi-dev
2628
- wget
2729
- curl
2830
- make
@@ -34,4 +36,4 @@ Dockerfile for image built off [Ubuntu 18.04](https://wiki.ubuntu.com/BionicBeav
3436

3537
### From source
3638

37-
- Python 3.6
39+
- Python 3.7 (3.6)

install_python.sh

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,37 @@ function build_cpython () {
2929
# 1: the prefix to be passed to configure
3030
# c.f. https://docs.python.org/3/using/unix.html#python-related-paths-and-files
3131
# 2: the path to the version of gcc to be used
32+
# 3: the Python version being built
3233

3334
# https://docs.python.org/3/using/unix.html#building-python
35+
# https://github.com/python/cpython/blob/3.7/README.rst
3436
# https://github.com/python/cpython/blob/3.6/README.rst
3537
printf "\n### ./configure\n"
36-
./configure --prefix="${1}" \
37-
--exec_prefix="${1}" \
38-
--with-cxx-main="${2}" \
39-
--enable-optimizations \
40-
--with-lto \
41-
--enable-loadable-sqlite-extensions \
42-
--enable-ipv6 \
43-
--with-threads \
44-
CXX="${2}"
38+
if [[ "${3}" > "3.7.0" ]]; then
39+
# --with-threads is removed in Python 3.7 (threading already on)
40+
./configure --prefix="${1}" \
41+
--exec_prefix="${1}" \
42+
--with-cxx-main="${2}" \
43+
--enable-optimizations \
44+
--with-lto \
45+
--enable-loadable-sqlite-extensions \
46+
--enable-ipv6 \
47+
CXX="${2}"
48+
else
49+
./configure --prefix="${1}" \
50+
--exec_prefix="${1}" \
51+
--with-cxx-main="${2}" \
52+
--enable-optimizations \
53+
--with-lto \
54+
--enable-loadable-sqlite-extensions \
55+
--enable-ipv6 \
56+
--with-threads \
57+
CXX="${2}"
58+
fi
4559
printf "\n### make -j${NPROC}\n"
4660
make -j${NPROC}
47-
# make install will create symlinks for python3, pip3, and pip
4861
printf "\n### make install\n"
4962
make install
50-
51-
# Link `python` against python3 if no python2 exists
52-
if ! command -v python2 >/dev/null 2>&1; then
53-
ln -s "${1}"/bin/"python${PYTHON_VERSION_TAG:0:3}" "${1}"/bin/python
54-
fi
5563
}
5664

5765
function update_pip {
@@ -90,7 +98,7 @@ function main() {
9098
# 1: the Python version tag
9199
# 2: bool of if should symlink python and pip to python3 versions
92100

93-
PYTHON_VERSION_TAG=3.6.8 # Switch to 3.7 once Tensorflow is out for it
101+
PYTHON_VERSION_TAG=3.7.2
94102
LINK_PYTHON_TO_PYTHON3=0 # By default don't link so as to reserve python for Python 2
95103
if [[ $# -gt 0 ]]; then
96104
PYTHON_VERSION_TAG="${1}"
@@ -103,7 +111,7 @@ function main() {
103111
NPROC="$(set_num_processors)"
104112
download_cpython "${PYTHON_VERSION_TAG}"
105113
cd Python-"${PYTHON_VERSION_TAG}"
106-
build_cpython /usr "${CXX_VERSION}"
114+
build_cpython /usr "${CXX_VERSION}" "${PYTHON_VERSION_TAG}"
107115
update_pip
108116

109117
if [[ "${LINK_PYTHON_TO_PYTHON3}" -eq 1 ]]; then

0 commit comments

Comments
 (0)