Skip to content

Instantly share code, notes, and snippets.

@mrsipan
Last active October 5, 2022 04:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrsipan/a0483e896cdb9640283769eac5bdb306 to your computer and use it in GitHub Desktop.
Save mrsipan/a0483e896cdb9640283769eac5bdb306 to your computer and use it in GitHub Desktop.
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