Skip to content

Instantly share code, notes, and snippets.

@bkj
Created October 18, 2016 23:41
Show Gist options
  • Save bkj/37ab135a8ad32576fa03312d70adbc2a to your computer and use it in GitHub Desktop.
Save bkj/37ab135a8ad32576fa03312d70adbc2a to your computer and use it in GitHub Desktop.
#!/bin/bash
# ./bundle-packages requirements.txt ./target-directory
# where
# requirements.txt : list of packages to include
# ./packages : path to target file
virtualenv --no-site-packages packageenv
. packageenv/bin/activate
pip install -r $1 --target $2
if [ -d $2 ]; then
cd $2
find . -name "*.pyc" -delete
find . -name "*.egg-info" | xargs rm -rf
zip -9mrv $2.zip .
mv $2.zip ..
cd ..
rm -rf $2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment