-
-
Save pydemo/35141213f3ead448bd62840afb02fcaf to your computer and use it in GitHub Desktop.
A simple script that builds static versions of Python and LibPython using musl-libc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We were unable to process your request. | |
We're required by law to inform you of the exact fees you will incur for international wires, including fees from other banks. For this request, we do not have the exact fees from other banks and therefore are not able to process it. If your request was in US dollars, you may try again in foreign currency -- this may help us determine the exact fees incurred for this transaction and enable us to send the wire request successfully. If you have received this message for both US dollars and foreign currency, it means we cannot process this request. We are sorry for any inconvenience. | |
#!/bin/bash | |
# set -eux | |
# This a simple script that builds static versions of Python and LibPython using musl-libc | |
# Find the associated article at: http://general-purpose.io/2015/12/06/compiling-python-and-libpython-statically-using-musl-libc/ | |
WORKING_DIR="/code/static-python" | |
MUSL_PREFIX="/code/static-python/musl" | |
PY_PREFIX="/code/static-python/python" | |
# COMPILER="gcc" | |
# COMPILER_VERSION="4.8" | |
COMPILER="clang" | |
COMPILER_VERSION="3.7" | |
# make the compiler's actual command name | |
export CC="${COMPILER}-${COMPILER_VERSION}" | |
# prepare the working directory | |
mkdir --parents "${WORKING_DIR}" | |
# download/extract/build static musl libc | |
cd "${WORKING_DIR}" | |
wget "http://www.musl-libc.org/releases/musl-1.1.12.tar.gz" | |
tar -xzf musl-1.1.12.tar.gz | |
cd musl-1.1.12 | |
./configure --prefix="${MUSL_PREFIX}" --disable-shared | |
make | |
make install | |
# enable the "musl compiler" | |
export CC="${MUSL_PREFIX}/bin/musl-${COMPILER}" | |
# download/extract/build static python/libpython | |
cd "${WORKING_DIR}" | |
wget "https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tar.xz" | |
tar -xJf Python-3.5.0.tar.xz | |
cd Python-3.5.0 | |
./configure --prefix="${PY_PREFIX}" --disable-shared \ | |
LDFLAGS="-static" CFLAGS="-static" CPPFLAGS="-static" | |
make | |
make install | |
# done ! (ignore any error that might happen during "make install") | |
# we now have: | |
# ${MUSL_PREFIX}/bin/musl-gcc : "static gcc" that uses musl | |
# ${PY_PREFIX}/bin/python3.5 : static python interpreter | |
# ${PY_PREFIX}/lib/libpython3.5m.a : static libpython | |
# ${PY_PREFIX}/include/python3.5m : include directory for libpython |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment