Skip to content

Commit c5ade26

Browse files
committed
Add files
1 parent e324d4b commit c5ade26

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM ubuntu:16.04
2+
3+
COPY build.sh .

README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
1-
# python-3.7-on-ubuntu-16.04
21
Scripts to build Python 3.7 on Ubuntu 16.04
2+
===========================================
3+
4+
You can run build.sh directly, or use Docker like this:
5+
6+
```bash
7+
docker build --tag python_builder .
8+
docker run --rm --interactive --tty --name python_builder python_builder
9+
10+
# run inside the docker container:
11+
./build.sh
12+
13+
# run this from a another terminal while the container is still running:
14+
docker cp python_builder:/Python-3.7.2/python3.7_3.7.2-1_amd64.deb .
15+
16+
# install the package
17+
sudo dpkg -i python3.7_3.7.2-1_amd64.deb
18+
```
19+
20+
Note:
21+
-----
22+
23+
You should check whether a newer version of Python is available and modify the
24+
`build.sh` accordingly. The commands above will also have to be modified.

build.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
set -o errexit -o nounset -o pipefail -o xtrace
4+
5+
PYTHON_VERSION=3.7.2
6+
7+
# this must not be plain python as otherwise the system Python gets overridden
8+
PACKAGE_NAME=python3.7
9+
10+
# sources need to be available for build-deb
11+
sed --in-place=~orig 's/# deb-src/deb-src/' /etc/apt/sources.list
12+
13+
apt-get update
14+
apt-get upgrade
15+
16+
# install things we need for this script
17+
apt-get install --assume-yes \
18+
checkinstall \
19+
wget \
20+
21+
# install things to compile Python
22+
apt-get build-dep --assume-yes python3.5
23+
24+
# download the latest version (from https://www.python.org/downloads/source/)
25+
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz
26+
27+
tar xvf Python-${PYTHON_VERSION}.tgz
28+
cd Python-${PYTHON_VERSION}
29+
30+
# enabling optimizations requires running tests which takes a long time but results in a faster Python
31+
./configure \
32+
--enable-optimizations \
33+
--with-ensurepip=install \
34+
35+
# compile as much as possible in parallel
36+
make --jobs 4
37+
38+
# use altinstall to not replace the system Python
39+
checkinstall --pkgname ${PACKAGE_NAME} --pkgversion ${PYTHON_VERSION} --default make altinstall

0 commit comments

Comments
 (0)