Last active
February 6, 2017 02:58
-
-
Save bugkiwi/a560682f2f2324aa14fc to your computer and use it in GitHub Desktop.
wow py
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
#!/usr/bin/env sh | |
if [ ! $PYTHONPATH ];then | |
PYTHONPATH="$HOME" | |
else | |
export PYTHONPATH="$PYTHONPATH:$HOME" | |
fi | |
BASE=$(pwd) | |
cd "$(dirname "$1")" | |
check(){ | |
if [ $1 == '/' ] | |
then | |
return 0 | |
elif [ -d $1/.git ] || [ -d $1/.hg ] | |
then | |
echo "$PYTHONPATH"|grep -q $1 | |
if [ $? -ne 0 ];then | |
export PYTHONPATH=$1:$PYTHONPATH | |
#echo '引入项目跟目录:'$1 | |
fi | |
return 1 | |
else | |
cd .. | |
check $(pwd) | |
fi | |
} | |
U_V1=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'` | |
U_V2=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $2}'` | |
U_V3=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $3}'` | |
export PYTHONPATH="${PYTHONPATH}:${VIRTUAL_ENV}/lib/python${U_V1}.${U_V2}/site-packages" | |
check $(pwd) | |
cd $BASE | |
python $* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment