Skip to content

Instantly share code, notes, and snippets.

@pmdevita
Last active April 12, 2018 15:31
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 pmdevita/066ab25aa7885efb8f6a69b40d844412 to your computer and use it in GitHub Desktop.
Save pmdevita/066ab25aa7885efb8f6a69b40d844412 to your computer and use it in GitHub Desktop.
Compile portable(ish) Python with custom OpenSSL on Mac OSX
#!/bin/bash
# where to do the building
build_dir="/Users/pmdevita/Downloads"
# links to python and openssl to use
python_link="https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz"
openssl_link="https://www.openssl.org/source/openssl-1.1.0g.tar.gz"
# needs to be same file type as download
python_name="Python.tar.xz"
openssl_name="openssl.tar.gz"
python_src="python_src"
openssl_src="openssl_src"
python_dir="python"
openssl_dir="openssl"
cd $build_dir
curl -o $python_name $python_link
curl -o $openssl_name $openssl_link
mkdir $python_src
mkdir $openssl_src
mkdir $openssl_dir
mkdir $python_dir
tar xf $python_name -C $python_src --strip-components 1
tar xf $openssl_name -C $openssl_src --strip-components 1
cd $openssl_src
./Configure darwin64-x86_64-cc --prefix="$build_dir/$openssl_dir" --openssldir="$build_dir/$openssl_dir"
make clean
make
make install
cd ..
cd $python_src
./configure CPPFLAGS="-I$build_dir/$openssl_dir/include" LDFLAGS="-L$build_dir/$openssl_dir/lib" --prefix="$build_dir/$python_dir"
make clean
make
make install
@pmdevita
Copy link
Author

pmdevita commented Feb 19, 2018

Thanks to https://stackoverflow.com/a/20740964

Haven't tested moving the files to another Mac and running it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment