Last active
October 5, 2022 04:12
-
-
Save mrsipan/a0483e896cdb9640283769eac5bdb306 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.4.2\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 | |
cd Python-${python_version} | |
LD_RUN_PATH="$(brew --prefix openssl)/lib" \ | |
CFLAGS="-I$(brew --prefix openssl)/include" \ | |
CPPFLAGS="-I$(brew --prefix openssl)/include" \ | |
LDFLAGS="-L$(brew --prefix openssl)/lib" \ | |
./configure --prefix=${directory} --with-ensurepip --enable-shared --enable-ipv6 \ | |
--with-dtrace --with-openssl="$(brew --prefix openssl)" | |
make | |
make install | |
cd $cwd | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment