Skip to content

Commit 8fcf1d9

Browse files
author
Doug Greiman
committed
Remove unused files to slim down the image
Add tests that the 'test' standard library module is functional.
1 parent 37d384d commit 8fcf1d9

5 files changed

Lines changed: 56 additions & 6 deletions

File tree

python-interpreter-builder/scripts/build-python-3.5.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,16 @@ QUILT_PATCHES=/patches/3.5 quilt push -a
8787
# Specifically EXTRA_CFLAGS="-g -flto -fuse-linker-plugin
8888
# -ffat-lto-objects"
8989

90+
PREFIX=/opt/python3.5
91+
9092
mkdir build-static
9193
cd build-static
9294

9395
../configure \
9496
--enable-ipv6 \
9597
--enable-loadable-sqlite-extensions \
9698
--enable-optimizations \
97-
--prefix=/opt/python3.5 \
99+
--prefix="$PREFIX" \
98100
--with-dbmliborder=bdb:gdbm \
99101
--with-computed-gotos \
100102
--with-fpectl \
@@ -117,13 +119,32 @@ cd build-static
117119
RANLIB="x86_64-linux-gnu-gcc-ranlib" \
118120

119121
make profile-opt
120-
make altinstall
121122

122123
# Run tests
123124
# test___all__: Depends on Debian-specific locale changes
125+
# test_dbm: https://bugs.python.org/issue28700
124126
# test_imap: https://bugs.python.org/issue30175
125127
# test_shutil: https://bugs.python.org/issue29317
126-
make test TESTOPTS="--exclude test___all__ test_imaplib test_shutil"
128+
make test TESTOPTS="--exclude test___all__ test_dbm test_imaplib test_shutil"
129+
130+
# Install
131+
make altinstall
132+
# We don't expect users to statically link Python into a C/C++ program
133+
rm "$PREFIX"/lib/libpython3.5m.a \
134+
"$PREFIX"/lib/python3.5/config-*/libpython3.5m.a
135+
# Remove opt-mode bytecode
136+
find "$PREFIX"/lib/python3.5/ \
137+
-name \*.opt-\?.pyc \
138+
-exec rm {} \;
139+
# Remove all but a few files in the 'test' subdirectory
140+
find "$PREFIX"/lib/python3.5/test \
141+
-mindepth 1 -maxdepth 1 \
142+
\! -name support \
143+
-a \! -name __init__.py \
144+
-a \! -name pystone.\* \
145+
-a \! -name regrtest.\* \
146+
-a \! -name test_support.py \
147+
-exec rm -rf {} \;
127148

128149
# Clean-up sources
129150
cd /opt

python-interpreter-builder/scripts/build-python-3.6.sh

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,16 @@ QUILT_PATCHES=/patches/3.6 quilt push -a
8787
# Specifically EXTRA_CFLAGS="-g -flto -fuse-linker-plugin
8888
# -ffat-lto-objects"
8989

90+
PREFIX=/opt/python3.6
91+
9092
mkdir build-static
9193
cd build-static
9294

9395
../configure \
9496
--enable-ipv6 \
9597
--enable-loadable-sqlite-extensions \
9698
--enable-optimizations \
97-
--prefix=/opt/python3.6 \
99+
--prefix="$PREFIX" \
98100
--with-dbmliborder=bdb:gdbm \
99101
--with-computed-gotos \
100102
--with-fpectl \
@@ -117,7 +119,6 @@ cd build-static
117119
RANLIB="x86_64-linux-gnu-gcc-ranlib" \
118120

119121
make profile-opt
120-
make altinstall
121122

122123
# Run tests
123124
# test___all__: Depends on Debian-specific locale changes
@@ -126,6 +127,25 @@ make altinstall
126127
# test_shutil: https://bugs.python.org/issue29317
127128
make test TESTOPTS="--exclude test___all__ test_dbm test_imaplib test_shutil"
128129

130+
# Install
131+
make altinstall
132+
# We don't expect users to statically link Python into a C/C++ program
133+
rm "$PREFIX"/lib/libpython3.6m.a \
134+
"$PREFIX"/lib/python3.6/config-*/libpython3.6m.a
135+
# Remove opt-mode bytecode
136+
find "$PREFIX"/lib/python3.6/ \
137+
-name \*.opt-\?.pyc \
138+
-exec rm {} \;
139+
# Remove all but a few files in the 'test' subdirectory
140+
find "$PREFIX"/lib/python3.6/test \
141+
-mindepth 1 -maxdepth 1 \
142+
\! -name support \
143+
-a \! -name __init__.py \
144+
-a \! -name pystone.\* \
145+
-a \! -name regrtest.\* \
146+
-a \! -name test_support.py \
147+
-exec rm -rf {} \;
148+
129149
# Clean-up sources
130150
cd /opt
131151
rm /opt/sources/Python-3.6.1.tgz

tests/virtualenv/virtualenv_python34.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ commandTests:
4242

4343
- name: "flask integration"
4444
command: ["python", "-c", "\"import sys; import flask; sys.exit(0 if flask.__file__.startswith('/env') else 1)\""]
45+
46+
- name: "test.support"
47+
command: ["python", "-c", "\"from test import pystone, regrtest, support\""]

tests/virtualenv/virtualenv_python35.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ commandTests:
4646

4747
- name: "flask integration"
4848
command: ["python", "-c", "\"import sys; import flask; sys.exit(0 if flask.__file__.startswith('/env') else 1)\""]
49+
50+
- name: "test.support"
51+
command: ["python", "-c", "\"from test import pystone, regrtest, support\""]

tests/virtualenv/virtualenv_python36.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ commandTests:
2929

3030
- name: "python version"
3131
command: ["python", "--version"]
32-
expectedOutput: ["Python 3.6.3\n"]
32+
expectedOutput: ["Python 3.6.1\n"]
3333

3434
- name: "pip installation"
3535
command: ["which", "pip"]
@@ -46,3 +46,6 @@ commandTests:
4646

4747
- name: "flask integration"
4848
command: ["python", "-c", "\"import sys; import flask; sys.exit(0 if flask.__file__.startswith('/env') else 1)\""]
49+
50+
- name: "test.support"
51+
command: ["python", "-c", "\"from test import pystone, regrtest, support\""]

0 commit comments

Comments
 (0)