Created
October 28, 2011 11:27
-
-
Save jbking/1322091 to your computer and use it in GitHub Desktop.
Setup a virtalenv for Google Appengine.
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
| #!/bin/sh # -x | |
| function usage { | |
| echo "Usage: $0 python_path virtualenv_path" | |
| echo "Setup a virtalenv for Google Appengine." | |
| echo "" | |
| echo "python_path Path to the Python interpreter used to the virtualenv." | |
| echo "virtualenv_path Path to the target virtualenv." | |
| exit | |
| } | |
| if [ ! $# -eq 2 ]; then | |
| usage | |
| fi | |
| python_path=$1 | |
| virtualenv_path=$2 | |
| if [ ! \( -f $python_path -a -d $virtualenv_path \) ]; then | |
| usage | |
| fi | |
| echo "python_path: $python_path" | |
| echo "virtualenv_path: $virtualenv_path" | |
| # link original module into virtualenv. | |
| original_lib_path=$($python_path -c "import os; print os.path.dirname(os.__file__)") | |
| virtualenv_lib_path=$virtualenv_path/lib/$(basename $original_lib_path) | |
| for original_module_path in $(find $original_lib_path -maxdepth 1 -and -name \*.py -or -type d) | |
| do | |
| module_name=$(basename $original_module_path) | |
| virtualenv_module_path=$virtualenv_lib_path/$module_name | |
| if [ ! -f $virtualenv_module_path ]; then | |
| echo linking $original_module_path to $virtualenv_module_path | |
| ln -s $original_module_path $virtualenv_module_path | |
| fi | |
| done | |
| # make distutils_path hard coded. | |
| quoted_original_lib_path=$(echo $original_lib_path | sed 's;/;\\/;g') | |
| perl -i.bak -ple "s/^(distutils_path = ).*/\$1\"$quoted_original_lib_path\/distutils\"/" $virtualenv_lib_path/distutils/__init__.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment