Skip to content

Instantly share code, notes, and snippets.

@bugkiwi
Last active February 6, 2017 02:58
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 bugkiwi/a560682f2f2324aa14fc to your computer and use it in GitHub Desktop.
Save bugkiwi/a560682f2f2324aa14fc to your computer and use it in GitHub Desktop.
wow py
#!/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