Skip to content

Instantly share code, notes, and snippets.

@ryansb
Last active February 18, 2016 15:55
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 ryansb/a794fb84c804775de2a5 to your computer and use it in GitHub Desktop.
Save ryansb/a794fb84c804775de2a5 to your computer and use it in GitHub Desktop.
Strip down a Python virtualenv by removing symbols from compiled files, thanks to @ogrisel for the tip!
#!/bin/bash
set -e
set -o pipefail
echo "venv original size $(du -sh $VIRTUAL_ENV)"
find $VIRTUAL_ENV/lib/python2.7/site-packages/ -name "*.so" | xargs strip
echo "venv after stripping $(du -sh $VIRTUAL_ENV)"
pushd $VIRTUAL_ENV/lib/python2.7/site-packages/ && zip -r -9 -q ~/venv.zip * ; popd
echo "final zip size $(du -sh venv.zip)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment