Created
November 9, 2011 23:05
-
-
Save jordanorelli/1353465 to your computer and use it in GitHub Desktop.
install python package conditionally in bash
This file contains hidden or 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
#!/usr/bin/env bash | |
ARCHIVE_URL="https://github.com/recurly/recurly-client-python/tarball/master" | |
ARCHIVE_NAME="recurly.tar.gz" | |
if ! python -c 'import recurly' &> /dev/null; then | |
TMP_DIR=$(mktemp -d XXXXX) | |
pushd "$TMP_DIR" | |
wget "$ARCHIVE_URL" -O "$ARCHIVE_NAME" | |
tar --strip-components 1 -xf "$ARCHIVE_NAME" | |
find . -type f -name 'setup.py' -exec python {} install \; | |
rm "$ARCHIVE_NAME" | |
popd | |
rm -rf "$TMP_DIR" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this kinda works. it doesn't fully work because their setup.py doesn't install the package's dependencies automatically, but if you have the prereqs it works. kinda a shitty solution, but it's a good example of shell exit codes and the -c flag for the python interpreter.