Improve fish environment setup (#26151)

* Add test runner to PATH

* Add Python3 support

* Updating env-setup.fish to use more portable '-exec' rather than '-delete'

* Create gen_egg_info function

Move code into a function similar to env-setup.

Silence all output when run with -q
This commit is contained in:
Sam Doran 2017-08-01 09:41:21 -04:00 committed by Brian Coca
parent 00ef894f6c
commit aa19563388

View file

@ -5,7 +5,7 @@ set HACKING_DIR (dirname (status -f))
set FULL_PATH (python -c "import os; print(os.path.realpath('$HACKING_DIR'))") set FULL_PATH (python -c "import os; print(os.path.realpath('$HACKING_DIR'))")
set ANSIBLE_HOME (dirname $FULL_PATH) set ANSIBLE_HOME (dirname $FULL_PATH)
set PREFIX_PYTHONPATH $ANSIBLE_HOME/lib 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 PREFIX_MANPATH $ANSIBLE_HOME/docs/man
# set quiet flag # set quiet flag
@ -45,21 +45,51 @@ if not contains $PREFIX_MANPATH $MANPATH
end end
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 set -gx ANSIBLE_LIBRARY $ANSIBLE_HOME/library
#
# Generate egg_info so that pkg_resources works # 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 ] if not [ $QUIET ]
echo "" echo ""
@ -67,6 +97,7 @@ if not [ $QUIET ]
echo "" echo ""
echo "PATH=$PATH" echo "PATH=$PATH"
echo "PYTHONPATH=$PYTHONPATH" echo "PYTHONPATH=$PYTHONPATH"
echo "PYTHON_BIN=$PYTHON_BIN"
echo "ANSIBLE_LIBRARY=$ANSIBLE_LIBRARY" echo "ANSIBLE_LIBRARY=$ANSIBLE_LIBRARY"
echo "MANPATH=$MANPATH" echo "MANPATH=$MANPATH"
echo "" echo ""