@@ -30,36 +30,59 @@ fetch_source Python-${CPYTHON_VERSION}.tgz.asc ${CPYTHON_DOWNLOAD_URL}/${CPYTHON
3030gpg --import ${MY_DIR} /cpython-pubkeys.txt
3131gpg --verify Python-${CPYTHON_VERSION} .tgz.asc
3232tar -xzf Python-${CPYTHON_VERSION} .tgz
33- pushd Python-${CPYTHON_VERSION}
34- PREFIX=" /opt/_internal/cpython-${CPYTHON_VERSION} "
35- mkdir -p ${PREFIX} /lib
36- if [ " ${AUDITWHEEL_POLICY} " == " manylinux2010" ]; then
37- # The _ctypes stdlib module build started to fail with 3.10.0rc1
38- # No clue what changed exactly yet
39- # This workaround fixes the build
40- LIBFFI_INCLUDEDIR=$( pkg-config --cflags-only-I libffi | tr -d ' [:space:]' )
41- LIBFFI_INCLUDEDIR=${LIBFFI_INCLUDEDIR: 2}
42- cp ${LIBFFI_INCLUDEDIR} /ffi.h ${LIBFFI_INCLUDEDIR} /ffitarget.h /usr/include/
43- fi
44- # configure with hardening options only for the interpreter & stdlib C extensions
45- # do not change the default for user built extension (yet?)
46- ./configure \
47- CFLAGS_NODIST=" ${MANYLINUX_CFLAGS} ${MANYLINUX_CPPFLAGS} " \
48- LDFLAGS_NODIST=" ${MANYLINUX_LDFLAGS} " \
49- --prefix=${PREFIX} --disable-shared --with-ensurepip=no > /dev/null
50- make > /dev/null
51- make install > /dev/null
52- if [ " ${AUDITWHEEL_POLICY} " == " manylinux2010" ]; then
53- rm -f /usr/include/ffi.h /usr/include/ffitarget.h
54- fi
55- popd
56- rm -rf Python-${CPYTHON_VERSION} Python-${CPYTHON_VERSION} .tgz Python-${CPYTHON_VERSION} .tgz.asc
5733
58- # we don't need libpython*.a, and they're many megabytes
59- find ${PREFIX} -name ' *.a' -print0 | xargs -0 rm -f
34+ function build {
35+ IS_SHARED=$1
36+ pushd Python-${CPYTHON_VERSION}
37+ PREFIX=" /opt/_internal/cpython-${CPYTHON_VERSION} "
38+ if [ ${IS_SHARED} -eq 1 ]; then
39+ PREFIX=" ${PREFIX} -shared"
40+ fi
41+ mkdir -p ${PREFIX} /lib
42+ if [ " ${AUDITWHEEL_POLICY} " == " manylinux2010" ]; then
43+ # The _ctypes stdlib module build started to fail with 3.10.0rc1
44+ # No clue what changed exactly yet
45+ # This workaround fixes the build
46+ LIBFFI_INCLUDEDIR=$( pkg-config --cflags-only-I libffi | tr -d ' [:space:]' )
47+ LIBFFI_INCLUDEDIR=${LIBFFI_INCLUDEDIR: 2}
48+ cp ${LIBFFI_INCLUDEDIR} /ffi.h ${LIBFFI_INCLUDEDIR} /ffitarget.h /usr/include/
49+ fi
50+ # configure with hardening options only for the interpreter & stdlib C extensions
51+ # do not change the default for user built extension (yet?)
52+ if [ ${IS_SHARED} -eq 1 ]; then
53+ FLAVOR=" --enable-shared"
54+ FLAVOR_LDFLAGS=" -Wl,-rpath=${PREFIX} /lib"
55+ else
56+ FLAVOR=" --disable-shared"
57+ FLAVOR_LDFLAGS=
58+ fi
59+
60+ ./configure \
61+ CFLAGS_NODIST=" ${MANYLINUX_CFLAGS} ${MANYLINUX_CPPFLAGS} " \
62+ LDFLAGS_NODIST=" ${MANYLINUX_LDFLAGS} ${FLAVOR_LDFLAGS} " \
63+ --prefix=${PREFIX} ${FLAVOR} --with-ensurepip=no > /dev/null
64+ make > /dev/null
65+ make install > /dev/null
66+ if [ " ${AUDITWHEEL_POLICY} " == " manylinux2010" ]; then
67+ rm -f /usr/include/ffi.h /usr/include/ffitarget.h
68+ fi
69+ popd
70+
71+ if [ ${IS_SHARED} -eq 0 ]; then
72+ # we don't need libpython*.a, and they're many megabytes
73+ find ${PREFIX} -name ' *.a' -print0 | xargs -0 rm -f
74+ fi
6075
61- # We do not need precompiled .pyc and .pyo files.
62- clean_pyc ${PREFIX}
76+ # We do not need precompiled .pyc and .pyo files.
77+ clean_pyc ${PREFIX}
6378
64- # Strip ELF files found in ${PREFIX}
65- strip_ ${PREFIX}
79+ # Strip ELF files found in ${PREFIX}
80+ strip_ ${PREFIX}
81+ }
82+
83+ build 0
84+ if [ ${PY_SHARED-0} -eq 1 ]; then
85+ build 1
86+ fi
87+
88+ rm -rf Python-${CPYTHON_VERSION} Python-${CPYTHON_VERSION} .tgz Python-${CPYTHON_VERSION} .tgz.asc
0 commit comments