2013-08-13 21:14:01 +00:00
|
|
|
#!/usr/bin/env fish
|
2013-08-14 21:52:37 +00:00
|
|
|
# usage: . ./hacking/env-setup [-q]
|
2013-08-13 21:14:01 +00:00
|
|
|
# modifies environment for running Ansible from checkout
|
|
|
|
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)
|
2016-10-24 17:35:00 +00:00
|
|
|
set PREFIX_PYTHONPATH $ANSIBLE_HOME/lib
|
|
|
|
set PREFIX_PATH $ANSIBLE_HOME/bin
|
2013-08-13 21:14:01 +00:00
|
|
|
set PREFIX_MANPATH $ANSIBLE_HOME/docs/man
|
|
|
|
|
2016-04-27 18:34:51 +00:00
|
|
|
# set quiet flag
|
2016-10-24 17:35:00 +00:00
|
|
|
if test (count $argv) -ge 1
|
2016-04-27 18:34:51 +00:00
|
|
|
switch $argv
|
2016-10-24 17:35:00 +00:00
|
|
|
case '-q' '--quiet'
|
|
|
|
set QUIET "true"
|
|
|
|
case '*'
|
2016-04-27 18:34:51 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-13 21:14:01 +00:00
|
|
|
# Set PYTHONPATH
|
|
|
|
if not set -q PYTHONPATH
|
|
|
|
set -gx PYTHONPATH $PREFIX_PYTHONPATH
|
|
|
|
else
|
|
|
|
switch PYTHONPATH
|
|
|
|
case "$PREFIX_PYTHONPATH*"
|
2013-08-14 16:46:58 +00:00
|
|
|
case "*"
|
2016-04-27 18:34:51 +00:00
|
|
|
if not [ $QUIET ]
|
|
|
|
echo "Appending PYTHONPATH"
|
|
|
|
end
|
2014-08-12 19:09:20 +00:00
|
|
|
set -gx PYTHONPATH "$PREFIX_PYTHONPATH:$PYTHONPATH"
|
2013-08-13 21:14:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Set PATH
|
|
|
|
if not contains $PREFIX_PATH $PATH
|
|
|
|
set -gx PATH $PREFIX_PATH $PATH
|
|
|
|
end
|
|
|
|
|
|
|
|
# Set MANPATH
|
|
|
|
if not contains $PREFIX_MANPATH $MANPATH
|
|
|
|
if not set -q MANPATH
|
2016-06-15 15:41:14 +00:00
|
|
|
set -gx MANPATH $PREFIX_MANPATH:
|
2013-08-13 21:14:01 +00:00
|
|
|
else
|
|
|
|
set -gx MANPATH $PREFIX_MANPATH $MANPATH
|
|
|
|
end
|
|
|
|
end
|
2013-08-14 16:46:58 +00:00
|
|
|
|
2013-08-13 21:14:01 +00:00
|
|
|
set -gx ANSIBLE_LIBRARY $ANSIBLE_HOME/library
|
2013-08-14 16:46:58 +00:00
|
|
|
|
2014-05-06 18:19:41 +00:00
|
|
|
# Generate egg_info so that pkg_resources works
|
|
|
|
pushd $ANSIBLE_HOME
|
2016-10-24 17:35:00 +00:00
|
|
|
if test -e $PREFIX_PYTHONPATH/ansible*.egg-info
|
|
|
|
rm -r $PREFIX_PYTHONPATH/ansible*.egg-info
|
|
|
|
end
|
2016-04-27 18:34:51 +00:00
|
|
|
if [ $QUIET ]
|
|
|
|
python setup.py -q egg_info
|
|
|
|
else
|
|
|
|
python setup.py egg_info
|
|
|
|
end
|
2015-09-02 21:05:16 +00:00
|
|
|
find . -type f -name "*.pyc" -delete
|
2014-05-06 18:19:41 +00:00
|
|
|
popd
|
|
|
|
|
|
|
|
|
2016-04-27 18:34:51 +00:00
|
|
|
if not [ $QUIET ]
|
|
|
|
echo ""
|
|
|
|
echo "Setting up Ansible to run out of checkout..."
|
|
|
|
echo ""
|
|
|
|
echo "PATH=$PATH"
|
|
|
|
echo "PYTHONPATH=$PYTHONPATH"
|
|
|
|
echo "ANSIBLE_LIBRARY=$ANSIBLE_LIBRARY"
|
|
|
|
echo "MANPATH=$MANPATH"
|
|
|
|
echo ""
|
|
|
|
echo "Remember, you may wish to specify your host file with -i"
|
|
|
|
echo ""
|
|
|
|
echo "Done!"
|
|
|
|
echo ""
|
2013-08-13 21:14:01 +00:00
|
|
|
end
|
2016-04-27 18:34:51 +00:00
|
|
|
|
|
|
|
set -e QUIET
|