Last active
October 21, 2022 16:36
-
-
Save mrsipan/80614aed82dea77260b7fa3a1a270e20 to your computer and use it in GitHub Desktop.
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
build_python() { | |
if [ -z $1 ]; then | |
printf "use: $FUNCNAME <destination-dir> <python-version>\n | |
For example: $FUNCNAME ~/opt/py 3.10.8\n\n" | |
return 1 | |
fi | |
directory=$1 | |
python_version=$2 | |
cwd=`pwd` | |
url="https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tgz" | |
test ! -d $directory && mkdir -p $directory | |
TEMP_DIR="/tmp/build_python_${RANDOM}" | |
test ! -d $TEMP_DIR && mkdir $TEMP_DIR | |
cd $TEMP_DIR | |
tarname=Python-${python_version}.tgz | |
test -f $tarname && rm -rf $tarname | |
wget --no-check-certificate $url | |
tar -xvzf $tarname | |
export CFLAGS="$CFLAGS $(pkg-config --cflags openssl11)" | |
export LDFLAGS="$LDFLAGS $(pkg-config --libs openssl11)" | |
cd Python-${python_version} | |
./configure --prefix=${directory} --with-ensurepip --enable-shared --enable-optimizations | |
make | |
make install | |
cd $cwd | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment