Created
June 3, 2011 18:16
-
-
Save un33k/1006847 to your computer and use it in GitHub Desktop.
Remote a directory from the python path (site packages directory)
This file contains 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
#!/bin/bash | |
# pyunlink.sh - Remove a pylinked module from your site packages directory. | |
# See http://gist.github.com/21650 for updates. | |
# You may also want to see pylink at http://gist.github.com/21649. | |
# Save this gist as pyulink and put it somewhere on your path | |
# Check that an argument has been given. If not, print usage string. | |
if [ -z $1 ] | |
then | |
echo "Usage: `basename $0` <link_name>" | |
exit | |
fi | |
# If there is not already a SITE_PACKAGES environment variable, then get it | |
# from Python. | |
if [[ -z $SITE_PACKAGES || ! -d $SITE_PACKAGES ]] | |
then | |
SITE_PACKAGES=`python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"` | |
fi | |
# If given name is a symbolic link in $SITE_PACKAGES | |
if [ -h $SITE_PACKAGES/`basename $1` ]; then | |
# Remove it | |
rm -Rf $SITE_PACKAGES/`basename $1` | |
else | |
# Signal an error. | |
echo "Error: link `basename $1` not found." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment