Skip to content

Instantly share code, notes, and snippets.

@zvoase
Created November 2, 2008 04:12
Show Gist options
  • Select an option

  • Save zvoase/21649 to your computer and use it in GitHub Desktop.

Select an option

Save zvoase/21649 to your computer and use it in GitHub Desktop.

Revisions

  1. zvoase revised this gist Jan 3, 2009. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion pylink.sh
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ fi

    # If there is not already a SITE_PACKAGES environment variable, then get it
    # from Python.
    if [ -z $SITE_PACKAGES || ! -d $SITE_PACKAGES ]
    if [[ -z $SITE_PACKAGES || ! -d $SITE_PACKAGES ]]
    then
    SITE_PACKAGES=`python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`
    fi
    2 changes: 1 addition & 1 deletion pyunlink.sh
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ fi

    # If there is not already a SITE_PACKAGES environment variable, then get it
    # from Python.
    if [ -z $SITE_PACKAGES || ! -d $SITE_PACKAGES ]
    if [[ -z $SITE_PACKAGES || ! -d $SITE_PACKAGES ]]
    then
    SITE_PACKAGES=`python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`
    fi
  2. zvoase revised this gist Jan 3, 2009. 2 changed files with 4 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions pylink.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    #!/bin/bash
    #
    # pylink.sh - Link a Python module to your site packages directory.
    #
    # See http://gist.github.com/21649 for updates.

    # Check that an argument has been given. If not, print usage string.
    2 changes: 2 additions & 0 deletions pyunlink.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    #!/bin/bash
    #
    # pyunlink.sh - Remove a pylinked module from your site packages directory.
    #
    # See http://gist.github.com/21649 for updates.

    # Check that an argument has been given. If not, print usage string.
  3. zvoase revised this gist Jan 3, 2009. 2 changed files with 27 additions and 1 deletion.
    1 change: 0 additions & 1 deletion pylink.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,6 @@
    #!/bin/bash
    # pylink.sh - Link a Python module to your site packages directory.
    # See http://gist.github.com/21649 for updates.
    # You may also want to see pyunlink at http://gist.github.com/21650.

    # Check that an argument has been given. If not, print usage string.
    if [ -z $1 ]
    27 changes: 27 additions & 0 deletions pyunlink.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    #!/bin/bash
    # pyunlink.sh - Remove a pylinked module from your site packages directory.
    # See http://gist.github.com/21649 for updates.

    # 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
  4. zvoase revised this gist Jan 3, 2009. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions pylink.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    #!/bin/bash
    # pylink.sh - Link a Python module to your site packages directory.
    # See http://gist.github.com/21649 for updates.
    # You may also want to see pyunlink at http://gist.github.com/21650.

    # Check that an argument has been given. If not, print usage string.
    if [ -z $1 ]
  5. zvoase revised this gist Jan 3, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pylink.sh
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    # Check that an argument has been given. If not, print usage string.
    if [ -z $1 ]
    then
    echo "Usage: `basename $0` <module_name> [<link_name>]"
    echo "Usage: `basename $0` <path_to_module> [<link_name>]"
    exit
    fi

  6. zvoase revised this gist Jan 3, 2009. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions pylink.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    #!/bin/bash
    # pylink.sh - Link a Python module to your site packages directory.

    # Check that an argument has been given. If not, print usage string.
    if [ -z $1 ]
    then
    echo "Usage: `basename $0` <module_name> [<link_name>]"
  7. zvoase revised this gist Jan 3, 2009. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions pylink.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,12 @@
    #!/bin/bash
    # pylink.sh - Link a Python module to your site packages directory.

    if [ -z $1 ]
    then
    echo "Usage: `basename $0` <module_name> [<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 ]
  8. zvoase revised this gist Jan 3, 2009. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions pylink.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    #!/bin/bash
    # pylink.sh - Link a Python module to your site packages directory.

    # If there is not already a SITE_PACKAGES environment variable, then get it
    # from Python.
  9. zvoase revised this gist Nov 29, 2008. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pylink.sh
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ BASE=`basename $1`
    DIR=`dirname $1`

    # Go into the directory of the first argument
    pushd $DIR
    pushd $DIR > /dev/null

    if [ $2 ]; then
    # If an additional name for the module has been provided, use that as the
  10. zvoase revised this gist Nov 29, 2008. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pylink.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    # If there is not already a SITE_PACKAGES environment variable, then get it
    # from Python.
    if [ ! -d $SITE_PACKAGES ]
    if [ -z $SITE_PACKAGES || ! -d $SITE_PACKAGES ]
    then
    SITE_PACKAGES=`python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`
    fi
  11. zvoase created this gist Nov 2, 2008.
    28 changes: 28 additions & 0 deletions pylink.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #!/bin/bash

    # If there is not already a SITE_PACKAGES environment variable, then get it
    # from Python.
    if [ ! -d $SITE_PACKAGES ]
    then
    SITE_PACKAGES=`python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`
    fi

    # Parse the first argument
    BASE=`basename $1`
    DIR=`dirname $1`

    # Go into the directory of the first argument
    pushd $DIR

    if [ $2 ]; then
    # If an additional name for the module has been provided, use that as the
    # link's basename.
    ln -sfnv `pwd`/$BASE $SITE_PACKAGES/`basename $2`
    else
    # Otherwise, use the basename of the given location.
    ln -sfnv `pwd`/$BASE $SITE_PACKAGES/$BASE
    fi

    # Return to where we were before
    popd > /dev/null