diff options
author | Sam Doran <sdoran@ansible.com> | 2017-08-01 09:41:21 -0400 |
---|---|---|
committer | Brian Coca <bcoca@users.noreply.github.com> | 2017-08-01 09:41:21 -0400 |
commit | aa19563388ff03d1093a10f770f9cc76b8a78f85 (patch) | |
tree | a9cdabaad408ac5e0a1aca9ad9c223e19a09cabc /hacking/env-setup.fish | |
parent | 00ef894f6cd71e06eefd566eb54794178bab2fcc (diff) | |
download | ansible-aa19563388ff03d1093a10f770f9cc76b8a78f85.tar.gz |
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
Diffstat (limited to 'hacking/env-setup.fish')
-rw-r--r-- | hacking/env-setup.fish | 47 |
1 files changed, 39 insertions, 8 deletions
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 +# + +# 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 ] - python setup.py -q egg_info + gen_egg_info ^ /dev/null + find . -type f -name "*.pyc" -exec rm -f '{}' ';' ^ /dev/null else - python setup.py egg_info + gen_egg_info + find . -type f -name "*.pyc" -exec rm -f '{}' ';' end -find . -type f -name "*.pyc" -delete -popd +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 "" |