diff --git a/hacking/env-setup.fish b/hacking/env-setup.fish index a5fe291fe9..b7b2db63b7 100644 --- a/hacking/env-setup.fish +++ b/hacking/env-setup.fish @@ -5,7 +5,7 @@ set HACKING_DIR (dirname (status -f)) set FULL_PATH (python -c "import os; print(os.path.realpath('$HACKING_DIR'))") set ANSIBLE_HOME (dirname $FULL_PATH) set PREFIX_PYTHONPATH $ANSIBLE_HOME/lib -set PREFIX_PATH $ANSIBLE_HOME/bin +set PREFIX_PATH $ANSIBLE_HOME/bin $ANSIBLE_HOME/test/runner set PREFIX_MANPATH $ANSIBLE_HOME/docs/man # set quiet flag @@ -45,21 +45,51 @@ if not contains $PREFIX_MANPATH $MANPATH end end +# Set PYTHON_BIN +if not set -q PYTHON_BIN + if test (which python) + set -gx PYTHON_BIN (which python) + else if test (which python3) + set -gx PYTHON_BIN (which python3) + else + echo "No valid Python found" + exit 1 + end +end + set -gx ANSIBLE_LIBRARY $ANSIBLE_HOME/library +# # Generate egg_info so that pkg_resources works -pushd $ANSIBLE_HOME -if test -e $PREFIX_PYTHONPATH/ansible*.egg-info - rm -r $PREFIX_PYTHONPATH/ansible*.egg-info -end -if [ $QUIET ] - python setup.py -q egg_info -else - python setup.py egg_info -end -find . -type f -name "*.pyc" -delete -popd +# +# Do the work in a fuction +function gen_egg_info + + if test -e $PREFIX_PYTHONPATH/ansible*.egg-info + rm -rf "$PREFIX_PYTHONPATH/ansible*.egg-info" + end + + if [ $QUIET ] + set options '-q' + end + + eval $PYTHON_BIN setup.py $options egg_info + +end + + +pushd $ANSIBLE_HOME + +if [ $QUIET ] + gen_egg_info ^ /dev/null + find . -type f -name "*.pyc" -exec rm -f '{}' ';' ^ /dev/null +else + gen_egg_info + find . -type f -name "*.pyc" -exec rm -f '{}' ';' +end + +popd if not [ $QUIET ] echo "" @@ -67,6 +97,7 @@ if not [ $QUIET ] echo "" echo "PATH=$PATH" echo "PYTHONPATH=$PYTHONPATH" + echo "PYTHON_BIN=$PYTHON_BIN" echo "ANSIBLE_LIBRARY=$ANSIBLE_LIBRARY" echo "MANPATH=$MANPATH" echo ""