Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ad8178

Browse files
committed
Add support for Python 3.7.
1 parent 7eb071f commit 4ad8178

File tree

5 files changed

+164
-2
lines changed

5 files changed

+164
-2
lines changed

cloudbuild_interpreters.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ steps:
1818
args: ['/scripts/build-python-3.6.sh']
1919
id: build-3.6
2020
waitFor: ['interpreter-builder']
21+
- name: interpreter-builder
22+
args: ['/scripts/build-python-3.7.sh']
23+
id: build-3.7
24+
waitFor: ['interpreter-builder']
2125

2226
# Upload them to tbe build-id location
2327
- name: gcr.io/cloud-builders/gsutil:latest
2428
args: ['cp', '/workspace/runtime-image/*.tar.gz', 'gs://python-interpreters/$BUILD_ID/']
25-
waitFor: ['build-3.4', 'build-3.5', 'build-3.6']
29+
waitFor: ['build-3.4', 'build-3.5', 'build-3.6', 'build-3.7']
2630

2731
# "Tag" this as latest
2832
- name: gcr.io/cloud-builders/gsutil:latest

nox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def lint(session):
5757

5858

5959
@nox.session
60-
@nox.parametrize('version', ['3.4', '3.5', '3.6'])
60+
@nox.parametrize('version', ['3.4', '3.5', '3.6', '3.7'])
6161
def tests(session, version):
6262
session.interpreter = 'python' + version
6363
session.install('-r', 'scripts/requirements-test.txt')
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
set -x
5+
6+
# Get the source
7+
mkdir -p /opt/sources
8+
cd /opt/sources
9+
wget --no-verbose https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
10+
# SHA-256 generated via `shasum -a 256 [file]`
11+
shasum --check <<EOF
12+
36c1b81ac29d0f8341f727ef40864d99d8206897be96be73dc34d4739c9c9f06 Python-3.7.1.tgz
13+
EOF
14+
tar xzf Python-3.7.1.tgz
15+
16+
cd Python-3.7.1
17+
18+
# Explanation of flags:
19+
#
20+
# Noteworthy Debian options we _don't_ use:
21+
#
22+
# This is complicated to get right, and we don't expect our
23+
# --enable-shared
24+
# customers to embed Python in a native code application. There is
25+
# also a noteworthy interaction with 'make altinstall'
26+
# (https://bugs.python.org/issue27685)
27+
# --without-ensurepip
28+
# Debian unbundles pip for their own reasons
29+
# CFLAGS=-fdebug-prefix-map
30+
# Unnecessary in our build environment
31+
#
32+
#
33+
# Flags that we _do_ use:
34+
# (Debian) means it was taken from Debian build rules.
35+
#
36+
# --enable-ipv6
37+
# (Debian) Ensure support is compiled in instead of relying on autodetection
38+
# --enable-loadable-sqlite-extensions
39+
# (Debian)
40+
# --enable-optimizations
41+
# Performance optimization (Enables PGO and may or may not enable
42+
# LTO based on complex logic and bugs)
43+
# --prefix
44+
# Avoid possible collisions with Debian or others
45+
# --with-computed-gotos
46+
# (Debian) Performance optimization
47+
# --with-dbmliborder=bdb:gdbm
48+
# (Debian) Python default is "ndbm:gdbm:bdb", I have no idea why one
49+
# would prefer one over the other.
50+
# --with-fpectl
51+
# (Debian) Floating point exception control
52+
# --with-system-expat
53+
# (Debian) for compatibility with other Debian packages
54+
# --with-system-ffi
55+
# (Debian) for compatibility with other Debian packages
56+
# --with-system-libmpdec
57+
# (Debian) for compatibility with other Debian packages
58+
# AR=
59+
# (Debian) No-op
60+
# CC=
61+
# (Debian) No-op
62+
# CFLAGS=-fstack-protector-strong
63+
# (Debian) Security hardening
64+
# CFLAGS=-g
65+
# (Debian) More debug info
66+
# CFLAGS=-Wformat -Werror=format-security
67+
# (Debian) Security hardening
68+
# CPPFLAGS=-D_FORTIFY_SOURCE=2
69+
# (Debian) Security hardening
70+
# CPPFLAGS=-Wdate-time
71+
# (Debian) Warnings about non-reproducible builds
72+
# CXX=
73+
# (Debian) No-op
74+
# LDFLAGS=-Wl,-z,relro:
75+
# (Debian) Security hardening
76+
# RANLIB=
77+
# (Debian) No-op
78+
#
79+
#
80+
# LTO (Link time optimization)
81+
#
82+
# Currently disabled, due to unresolved compile problems. There is a
83+
# --with-lto flag, but Debian doesn't use it. Instead, they pass lto
84+
# related flags in EXTRA_CFLAGS (to make, rather than configure).
85+
# Specifically EXTRA_CFLAGS="-g -flto -fuse-linker-plugin
86+
# -ffat-lto-objects"
87+
88+
PREFIX=/opt/python3.7
89+
90+
mkdir build-static
91+
cd build-static
92+
93+
../configure \
94+
--enable-ipv6 \
95+
--enable-loadable-sqlite-extensions \
96+
--enable-optimizations \
97+
--prefix="$PREFIX" \
98+
--with-dbmliborder=bdb:gdbm \
99+
--with-computed-gotos \
100+
--with-fpectl \
101+
--with-system-expat \
102+
--with-system-ffi \
103+
--with-system-libmpdec \
104+
AR="x86_64-linux-gnu-gcc-ar" \
105+
CC="x86_64-linux-gnu-gcc" \
106+
CFLAGS="\
107+
-fstack-protector-strong \
108+
-g \
109+
-Wformat -Werror=format-security \
110+
" \
111+
CPPFLAGS="\
112+
-D_FORTIFY_SOURCE=2 \
113+
-Wdate-time \
114+
" \
115+
CXX="x86_64-linux-gnu-g++" \
116+
LDFLAGS="-Wl,-z,relro" \
117+
RANLIB="x86_64-linux-gnu-gcc-ranlib" \
118+
119+
make profile-opt
120+
121+
# Run tests
122+
# test___all__: Depends on Debian-specific locale changes
123+
# test_dbm: https://bugs.python.org/issue28700
124+
# test_imap: https://bugs.python.org/issue30175
125+
# test_shutil: https://bugs.python.org/issue29317
126+
# test_xmlrpc_net: https://bugs.python.org/issue31724
127+
make test TESTOPTS="--exclude test___all__ test_dbm test_imaplib test_shutil test_xmlrpc_net test_os"
128+
129+
# Install
130+
make altinstall
131+
# Remove redundant copy of libpython
132+
rm "$PREFIX"/lib/libpython3.7m.a
133+
# Remove opt-mode bytecode
134+
find "$PREFIX"/lib/python3.7/ \
135+
-name \*.opt-\?.pyc \
136+
-exec rm {} \;
137+
# Remove all but a few files in the 'test' subdirectory
138+
find "$PREFIX"/lib/python3.7/test \
139+
-mindepth 1 -maxdepth 1 \
140+
\! -name support \
141+
-a \! -name __init__.py \
142+
-a \! -name pystone.\* \
143+
-a \! -name regrtest.\* \
144+
-a \! -name test_support.py \
145+
-exec rm -rf {} \;
146+
147+
# Clean-up sources
148+
cd /opt
149+
rm /opt/sources/Python-3.7.1.tgz
150+
rm -r /opt/sources/Python-3.7.1
151+
152+
# Archive and copy to persistent external volume
153+
tar czf /workspace/runtime-image/interpreter-3.7.tar.gz /opt/python3.7

runtime-image/Dockerfile.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ ENV PYTHONUNBUFFERED 1
1919
RUN wget https://storage.googleapis.com/python-interpreters/latest/interpreter-3.4.tar.gz && \
2020
wget https://storage.googleapis.com/python-interpreters/latest/interpreter-3.5.tar.gz && \
2121
wget https://storage.googleapis.com/python-interpreters/latest/interpreter-3.6.tar.gz && \
22+
wget https://storage.googleapis.com/python-interpreters/latest/interpreter-3.7.tar.gz && \
2223
tar -xzf interpreter-3.4.tar.gz && \
2324
tar -xzf interpreter-3.5.tar.gz && \
2425
tar -xzf interpreter-3.6.tar.gz && \
26+
tar -xzf interpreter-3.7.tar.gz && \
2527
rm interpreter-*.tar.gz
2628

2729
# Add Google-built interpreters to the path
@@ -38,6 +40,8 @@ RUN /usr/bin/pip install --upgrade -r /resources/requirements.txt && \
3840
rm -f /opt/python3.5/bin/pip /opt/python3.5/bin/pip3 && \
3941
/opt/python3.6/bin/pip3.6 install --upgrade -r /resources/requirements.txt && \
4042
rm -f /opt/python3.6/bin/pip /opt/python3.6/bin/pip3 && \
43+
/opt/python3.6/bin/pip3.7 install --upgrade -r /resources/requirements.txt && \
44+
rm -f /opt/python3.7/bin/pip /opt/python3.7/bin/pip3 && \
4145
/usr/bin/pip install --upgrade -r /resources/requirements-virtualenv.txt
4246

4347
# Setup the app working directory

scripts/gen_dockerfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
'3.4': '3.4',
5555
'3.5': '3.5',
5656
'3.6': '3.6',
57+
'3.7': '3.7',
5758
}
5859

5960
# Name of environment variable potentially set by gcloud

0 commit comments

Comments
 (0)