forked from GoogleCloudPlatform/python-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-python-3.4.sh
More file actions
executable file
·141 lines (129 loc) · 3.8 KB
/
build-python-3.4.sh
File metadata and controls
executable file
·141 lines (129 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
set -euo pipefail
set -x
# Get the source
mkdir -p /opt/sources
cd /opt/sources
wget --no-verbose https://www.python.org/ftp/python/3.4.8/Python-3.4.8.tgz
# SHA-256 generated via `shasum -a 256 [file]`
shasum --check <<EOF
8b1a1ce043e132082d29a5d09f2841f193c77b631282a82f98895a5dbaba1639 Python-3.4.8.tgz
EOF
tar xzf Python-3.4.8.tgz
cd Python-3.4.8
# Explanation of flags:
#
# Noteworthy Debian options we _don't_ use:
#
# --enable-shared
# This is complicated to get right, and we don't expect our
# customers to embed Python in a native code application. There is
# also a noteworthy interaction with 'make altinstall'
# (https://bugs.python.org/issue27685)
# --without-ensurepip
# Debian unbundles pip for their own reasons
# CFLAGS=-fdebug-prefix-map
# Unnecessary in our build environment
#
#
# Flags that we _do_ use:
# (Debian) means it was taken from Debian build rules.
#
# --enable-ipv6
# (Debian) Ensure support is compiled in instead of relying on autodetection
# --enable-loadable-sqlite-extensions
# (Debian)
# --prefix
# Avoid possible collisions with Debian or others
# --with-computed-gotos
# (Debian) Performance optimization
# --with-dbmliborder=bdb:gdbm
# (Debian) Python default is "ndbm:gdbm:bdb", I have no idea why one
# would prefer one over the other.
# --with-fpectl
# (Debian) Floating point exception control
# --with-system-expat
# (Debian) for compatibility with other Debian packages
# --with-system-ffi
# (Debian) for compatibility with other Debian packages
# --with-system-libmpdec
# (Debian) for compatibility with other Debian packages
# AR=
# (Debian) No-op
# CC=
# (Debian) No-op
# CFLAGS=-fstack-protector-strong
# (Debian) Security hardening
# CFLAGS=-g
# (Debian) More debug info
# CFLAGS=-Wformat -Werror=format-security
# (Debian) Security hardening
# CPPFLAGS=-D_FORTIFY_SOURCE=2
# (Debian) Security hardening
# CPPFLAGS=-Wdate-time
# (Debian) Warnings about non-reproducible builds
# CXX=
# (Debian) No-op
# LDFLAGS=-Wl,-z,relro:
# (Debian) Security hardening
# RANLIB=
# (Debian) No-op
PREFIX=/opt/python3.4
mkdir build-static
cd build-static
../configure \
--enable-ipv6 \
--enable-loadable-sqlite-extensions \
--prefix="$PREFIX" \
--with-dbmliborder=bdb:gdbm \
--with-computed-gotos \
--with-fpectl \
--with-system-expat \
--with-system-ffi \
--with-system-libmpdec \
AR="x86_64-linux-gnu-gcc-ar" \
CC="x86_64-linux-gnu-gcc" \
CFLAGS="\
-fstack-protector-strong \
-g \
-Wformat -Werror=format-security \
" \
CPPFLAGS="\
-D_FORTIFY_SOURCE=2 \
-Wdate-time \
" \
CXX="x86_64-linux-gnu-g++" \
LDFLAGS="-Wl,-z,relro" \
RANLIB="x86_64-linux-gnu-gcc-ranlib" \
make all
# Run tests
# test___all__: Depends on Debian-specific locale changes
# test_dbm: https://bugs.python.org/issue28700
# test_imap: https://bugs.python.org/issue30175
# test_shutil: https://bugs.python.org/issue29317
# test_subprocess: https://bugs.python.org/issue6135
# test_xmlrpc_net: https://bugs.python.org/issue31724
make test TESTOPTS="-uall,-network,-urlfetch --exclude test___all__ test_dbm test_imaplib test_shutil test_subprocess test_xmlrpc_net"
# Install
make altinstall
# Remove redundant copy of libpython
rm "$PREFIX"/lib/libpython3.4m.a
# Remove opt-mode bytecode
find "$PREFIX"/lib/python3.4/ \
-name \*.opt-\?.pyc \
-exec rm {} \;
# Remove all but a few files in the 'test' subdirectory
find "$PREFIX"/lib/python3.4/test \
-mindepth 1 -maxdepth 1 \
\! -name support \
-a \! -name __init__.py \
-a \! -name pystone.\* \
-a \! -name regrtest.\* \
-a \! -name test_support.py \
-exec rm -rf {} \;
# Clean-up sources
cd /opt
rm /opt/sources/Python-3.4.8.tgz
rm -r /opt/sources/Python-3.4.8
# Archive and copy to persistent external volume
tar czf /workspace/runtime-image/interpreter-3.4.tar.gz /opt/python3.4