Skip to content

Instantly share code, notes, and snippets.

@dbl0null
Forked from raelmax/pex_standalone.sh
Created November 30, 2017 10:06
Show Gist options
  • Save dbl0null/67671e3ebee4ad0215209700f93fe829 to your computer and use it in GitHub Desktop.
Save dbl0null/67671e3ebee4ad0215209700f93fe829 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Checking if python is installed
if ! [ -x "$(command -v python)" ]; then
echo 'Error: python is not installed. :(' >&2
exit 1
fi
# Build directory
export OLDDIR=$PWD
export TMPDIR=`mktemp -d /tmp/pex-build.XXXXXX`
# Download and unzip pex
curl -L https://github.com/pantsbuild/pex/archive/master.zip -o "$TMPDIR/master.zip"
cd $TMPDIR
unzip master.zip
cd pex-master
# Installing pex in a local folder
mkdir ../lib/
PYTHONPATH=../lib/ python setup.py install --install-lib="../lib" --install-scripts="../scripts"
# Generating a pex from pex
cd ..
PYTHONPATH="$PWD/lib" "$TMPDIR/scripts/pex" pex requests -c pex -o "$OLDDIR/pex"
# Cleaning up
rm -rf $TMPDIR
###############
printf "\n\n\n\n\n"
printf "Congratz! Now you can use ./pex from this directory to create standalone python packages!\n"
printf "Docs: https://pex.readthedocs.io"
printf "\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment