@@ -6,119 +6,40 @@ set -ex
6
6
7
7
# Set build environment variables
8
8
MY_DIR=$( dirname " ${BASH_SOURCE[0]} " )
9
- . $MY_DIR /build_env.sh
10
-
11
- # Dependencies for compiling Python that we want to remove from
12
- # the final image after compiling Python
13
- PYTHON_COMPILE_DEPS=" zlib-devel bzip2-devel expat-devel ncurses-devel readline-devel tk-devel gdbm-devel libdb-devel libpcap-devel xz-devel openssl-devel keyutils-libs-devel krb5-devel libcom_err-devel libidn-devel curl-devel perl-devel"
14
-
15
- # Libraries that are allowed as part of the manylinux2014 profile
16
- # Extract from PEP: https://www.python.org/dev/peps/pep-0599/#the-manylinux2014-policy
17
- # On RPM-based systems, they are provided by these packages:
18
- # Package: Libraries
19
- # glib2: libglib-2.0.so.0, libgthread-2.0.so.0, libgobject-2.0.so.0
20
- # glibc: libresolv.so.2, libutil.so.1, libnsl.so.1, librt.so.1, libpthread.so.0, libdl.so.2, libm.so.6, libc.so.6
21
- # libICE: libICE.so.6
22
- # libX11: libX11.so.6
23
- # libXext: libXext.so.6
24
- # libXrender: libXrender.so.1
25
- # libgcc: libgcc_s.so.1
26
- # libstdc++: libstdc++.so.6
27
- # mesa: libGL.so.1
28
- #
29
- # PEP is missing the package for libSM.so.6 for RPM based system
30
- # Install development packages (except for libgcc which is provided by gcc install)
31
- MANYLINUX_DEPS=" glibc-devel libstdc++-devel glib2-devel libX11-devel libXext-devel libXrender-devel mesa-libGL-devel libICE-devel libSM-devel"
32
-
33
- CMAKE_DEPS=" openssl-devel zlib-devel libcurl-devel"
9
+ source $MY_DIR /build_env.sh
34
10
35
11
# Get build utilities
36
12
source $MY_DIR /build_utils.sh
37
13
38
- # See https://unix.stackexchange.com/questions/41784/can-yum-express-a-preference-for-x86-64-over-i386-packages
39
- echo " multilib_policy=best" >> /etc/yum.conf
40
- # Error out if requested packages do not exist
41
- echo " skip_missing_names_on_install=False" >> /etc/yum.conf
42
- # Make sure that locale will not be removed
43
- sed -i ' /^override_install_langs=/d' /etc/yum.conf
44
-
45
- # https://hub.docker.com/_/centos/
46
- # "Additionally, images with minor version tags that correspond to install
47
- # media are also offered. These images DO NOT recieve updates as they are
48
- # intended to match installation iso contents. If you choose to use these
49
- # images it is highly recommended that you include RUN yum -y update && yum
50
- # clean all in your Dockerfile, or otherwise address any potential security
51
- # concerns."
52
- # Decided not to clean at this point: https://github.com/pypa/manylinux/pull/129
53
- yum -y update
54
- yum -y install yum-utils curl
55
- yum-config-manager --enable extras
56
-
57
- if ! which localedef & > /dev/null; then
58
- # somebody messed up glibc-common package to squeeze image size, reinstall the package
59
- yum -y reinstall glibc-common
60
- fi
61
-
62
- # upgrading glibc-common can end with removal on en_US.UTF-8 locale
63
- localedef -i en_US -f UTF-8 en_US.UTF-8
64
-
65
- TOOLCHAIN_DEPS=" devtoolset-9-binutils devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-gcc-gfortran"
66
- if [ " ${AUDITWHEEL_ARCH} " == " x86_64" ]; then
67
- # Software collection (for devtoolset-9)
68
- yum -y install centos-release-scl-rh
69
- # EPEL support (for yasm)
70
- yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
71
- YASM=yasm
72
- elif [ " ${AUDITWHEEL_ARCH} " == " aarch64" ] || [ " ${AUDITWHEEL_ARCH} " == " ppc64le" ] || [ " ${AUDITWHEEL_ARCH} " == " s390x" ]; then
73
- # Software collection (for devtoolset-9)
74
- yum -y install centos-release-scl-rh
75
- elif [ " ${AUDITWHEEL_ARCH} " == " i686" ]; then
76
- # No yasm on i686
77
- # Install mayeut/devtoolset-9 repo to get devtoolset-9
78
- curl -fsSLo /etc/yum.repos.d/mayeut-devtoolset-9.repo https://copr.fedorainfracloud.org/coprs/mayeut/devtoolset-9/repo/custom-1/mayeut-devtoolset-9-custom-1.repo
79
- fi
14
+ # Dependencies for compiling Python that we want to remove from
15
+ # the final image after compiling Python
16
+ PYTHON_COMPILE_DEPS=" zlib-devel bzip2-devel expat-devel ncurses-devel readline-devel tk-devel gdbm-devel libdb-devel libpcap-devel xz-devel openssl-devel keyutils-libs-devel krb5-devel libcom_err-devel libidn-devel curl-devel perl-devel libffi-devel kernel-devel"
17
+ CMAKE_DEPS=" openssl-devel zlib-devel libcurl-devel"
80
18
81
19
# Development tools and libraries
82
- yum -y install \
83
- autoconf \
84
- automake \
85
- bison \
86
- bzip2 \
87
- ${TOOLCHAIN_DEPS} \
88
- diffutils \
89
- gettext \
90
- file \
91
- kernel-devel \
92
- libffi-devel \
93
- make \
94
- patch \
95
- unzip \
96
- which \
97
- ${YASM} \
98
- ${PYTHON_COMPILE_DEPS} \
99
- ${CMAKE_DEPS}
20
+ yum -y install ${PYTHON_COMPILE_DEPS} ${CMAKE_DEPS}
100
21
101
22
# Install git
102
23
build_git $GIT_ROOT $GIT_HASH
103
- git version
104
-
105
- # Install newest automake
106
- build_automake $AUTOMAKE_ROOT $AUTOMAKE_HASH
107
- automake --version
108
-
109
- # Install newest libtool
110
- build_libtool $LIBTOOL_ROOT $LIBTOOL_HASH
111
- libtool --version
24
+ /manylinux-rootfs/usr/local/bin/git version
112
25
113
26
# Install a more recent SQLite3
114
27
curl -fsSLO $SQLITE_AUTOCONF_DOWNLOAD_URL /$SQLITE_AUTOCONF_ROOT .tar.gz
115
28
check_sha256sum $SQLITE_AUTOCONF_ROOT .tar.gz $SQLITE_AUTOCONF_HASH
116
29
tar xfz $SQLITE_AUTOCONF_ROOT .tar.gz
117
30
cd $SQLITE_AUTOCONF_ROOT
118
- do_standard_install
31
+ DESTDIR=/sqlite3 do_standard_install
119
32
cd ..
120
33
rm -rf $SQLITE_AUTOCONF_ROOT *
121
- rm /usr/local/lib/libsqlite3.a
34
+ rm /sqlite3/usr/local/lib/libsqlite3.a
35
+ # Install for build
36
+ cp -rf /sqlite3/* /
37
+ # Clean-up for runtime
38
+ rm -rf /sqlite3/usr/local/bin /sqlite3/usr/local/include /sqlite3/usr/local/lib/pkg-config /sqlite3/usr/local/share
39
+ # Install for runtime
40
+ cp -rf /sqlite3/* /manylinux-rootfs/
41
+ # clean-up
42
+ rm -rf /sqlite3
122
43
123
44
# Install a recent version of cmake3
124
45
curl -L -O $CMAKE_DOWNLOAD_URL /v${CMAKE_VERSION} /cmake-${CMAKE_VERSION} .tar.gz
@@ -127,101 +48,29 @@ tar -xzf cmake-${CMAKE_VERSION}.tar.gz
127
48
cd cmake-${CMAKE_VERSION}
128
49
./bootstrap --system-curl --parallel=$( nproc)
129
50
make -j$( nproc)
130
- make install
51
+ make install DESTDIR=/manylinux-rootfs
131
52
cd ..
132
- rm -rf cmake-${CMAKE_VERSION}
133
-
134
- # Install libcrypt.so.1 and libcrypt.so.2
135
- build_libxcrypt " $LIBXCRYPT_DOWNLOAD_URL " " $LIBXCRYPT_VERSION " " $LIBXCRYPT_HASH "
53
+ rm -rf cmake-${CMAKE_VERSION} *
136
54
137
55
# Compile the latest Python releases.
138
56
# (In order to have a proper SSL module, Python is compiled
139
57
# against a recent openssl [see env vars above], which is linked
140
58
# statically.
141
- mkdir -p /opt/python
142
59
build_cpythons $CPYTHON_VERSIONS
143
60
144
- # Create venv for auditwheel & certifi
145
- TOOLS_PATH=/opt/_internal/tools
146
- /opt/python/cp37-cp37m/bin/python -m venv $TOOLS_PATH
147
- source $TOOLS_PATH /bin/activate
148
-
149
- # Install default packages
150
- pip install -U --require-hashes -r $MY_DIR /requirements.txt
151
- # Install certifi and auditwheel
152
- pip install -U --require-hashes -r $MY_DIR /requirements-tools.txt
153
-
154
- # Make auditwheel available in PATH
155
- ln -s $TOOLS_PATH /bin/auditwheel /usr/local/bin/auditwheel
156
-
157
- # Our openssl doesn't know how to find the system CA trust store
158
- # (https://github.com/pypa/manylinux/issues/53)
159
- # And it's not clear how up-to-date that is anyway
160
- # So let's just use the same one pip and everyone uses
161
- ln -s $( python -c ' import certifi; print(certifi.where())' ) /opt/_internal/certs.pem
162
- # If you modify this line you also have to modify the versions in the Dockerfiles:
163
- export SSL_CERT_FILE=/opt/_internal/certs.pem
164
-
165
- # Deactivate the tools virtual environment
166
- deactivate
167
-
168
- # Install patchelf (latest with unreleased bug fixes) and apply our patches
169
- build_patchelf $PATCHELF_VERSION $PATCHELF_HASH
170
-
171
- # Clean up development headers and other unnecessary stuff for
172
- # final image
173
- yum -y erase \
174
- avahi \
175
- bitstream-vera-fonts \
176
- freetype \
177
- gettext \
178
- gtk2 \
179
- hicolor-icon-theme \
180
- libX11 \
181
- wireless-tools \
182
- ${PYTHON_COMPILE_DEPS} > /dev/null 2>&1
183
- yum -y install ${MANYLINUX_DEPS}
184
- yum -y clean all > /dev/null 2>&1
185
- yum list installed
186
-
187
61
# we don't need libpython*.a, and they're many megabytes
188
62
find /opt/_internal -name ' *.a' -print0 | xargs -0 rm -f
189
63
190
64
# Strip what we can -- and ignore errors, because this just attempts to strip
191
65
# *everything*, including non-ELF files:
192
66
find /opt/_internal -type f -print0 \
193
67
| xargs -0 -n1 strip --strip-unneeded 2> /dev/null || true
194
- find /usr/local -type f -print0 \
68
+ find /manylinux-rootfs -type f -print0 \
195
69
| xargs -0 -n1 strip --strip-unneeded 2> /dev/null || true
196
70
197
- for PYTHON in /opt/python/* /bin/python; do
198
- # Smoke test to make sure that our Pythons work, and do indeed detect as
199
- # being manylinux compatible:
200
- $PYTHON $MY_DIR /manylinux-check.py
201
- # Make sure that SSL cert checking works
202
- $PYTHON $MY_DIR /ssl-check.py
203
- done
204
-
205
71
# We do not need the Python test suites, or indeed the precompiled .pyc and
206
72
# .pyo files. Partially cribbed from:
207
73
# https://github.com/docker-library/python/blob/master/3.4/slim/Dockerfile
208
74
find /opt/_internal -depth \
209
75
\( -type d -a -name test -o -name tests \) \
210
76
-o \( -type f -a -name ' *.pyc' -o -name ' *.pyo' \) | xargs rm -rf
211
-
212
- # Fix libc headers to remain compatible with C99 compilers.
213
- find /usr/include/ -type f -exec sed -i ' s/\bextern _*inline_*\b/extern __inline __attribute__ ((__gnu_inline__))/g' {} +
214
-
215
- if [ " ${DEVTOOLSET_ROOTPATH:- } " != " " ]; then
216
- # remove useless things that have been installed by devtoolset
217
- rm -rf $DEVTOOLSET_ROOTPATH /usr/share/man
218
- find $DEVTOOLSET_ROOTPATH /usr/share/locale -mindepth 1 -maxdepth 1 -not \( -name ' en*' -or -name ' locale.alias' \) | xargs rm -rf
219
- fi
220
- rm -rf /usr/share/backgrounds
221
- # if we updated glibc, we need to strip locales again...
222
- localedef --list-archive | grep -v -i ^en_US.utf8 | xargs localedef --delete-from-archive
223
- mv -f /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl
224
- build-locale-archive
225
- find /usr/share/locale -mindepth 1 -maxdepth 1 -not \( -name ' en*' -or -name ' locale.alias' \) | xargs rm -rf
226
- find /usr/local/share/locale -mindepth 1 -maxdepth 1 -not \( -name ' en*' -or -name ' locale.alias' \) | xargs rm -rf
227
- rm -rf /usr/local/share/man
0 commit comments