From 6a6060ac5591a34386cdd03d1148d7063db77372 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Tue, 6 May 2014 11:19:41 -0700 Subject: [PATCH 1/2] Teach env-setup how to create egg-info for ansible so that pkg_resources works --- hacking/env-setup | 26 +++++++++++++++++++++++++- hacking/env-setup.fish | 10 ++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/hacking/env-setup b/hacking/env-setup index 6e4de1af72b..032611b2ae5 100755 --- a/hacking/env-setup +++ b/hacking/env-setup @@ -25,6 +25,30 @@ unset ANSIBLE_LIBRARY export ANSIBLE_LIBRARY="$ANSIBLE_HOME/library:`python $HACKING_DIR/get_library.py`" [[ $MANPATH != ${PREFIX_MANPATH}* ]] && export MANPATH=$PREFIX_MANPATH:$MANPATH +# +# Generate egg_info so that pkg_resources works +# + +# Do the work in a function so we don't repeat ourselves later +gen_egg_info() +{ + python setup.py egg_info + if [ -e $PREFIX_PYTHONPATH/ansible*.egg-info ] ; then + rm -r $PREFIX_PYTHONPATH/ansible*.egg-info + fi + mv ansible*.egg-info $PREFIX_PYTHONPATH +} + +# In some shells if pushd is a no-op then popd sends you to a previous +# directory in history +if [ "$ANSIBLE_HOME" != "$PWD" ] ; then + pushd "$ANSIBLE_HOME" + gen_egg_info + popd +else + gen_egg_info +fi + # Print out values unless -q is set if [ $# -eq 0 -o "$1" != "-q" ] ; then @@ -36,7 +60,7 @@ if [ $# -eq 0 -o "$1" != "-q" ] ; then echo "ANSIBLE_LIBRARY=$ANSIBLE_LIBRARY" echo "MANPATH=$MANPATH" echo "" - + echo "Remember, you may wish to specify your host file with -i" echo "" echo "Done!" diff --git a/hacking/env-setup.fish b/hacking/env-setup.fish index 1613baeb146..0caa055efa5 100644 --- a/hacking/env-setup.fish +++ b/hacking/env-setup.fish @@ -36,6 +36,16 @@ end set -gx ANSIBLE_LIBRARY $ANSIBLE_HOME/library +# Generate egg_info so that pkg_resources works +pushd $ANSIBLE_HOME +python setup.py egg_info +if test -e $PREFIX_PYTHONPATH/ansible*.egg-info + rm -r $PREFIX_PYTHONPATH/ansible*.egg-info +end +mv ansible*egg-info $PREFIX_PYTHONPATH +popd + + if set -q argv switch $argv case '-q' '--quiet' From f7b76e0394ad2eb59f4aef6497fd89ce664e8718 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Tue, 6 May 2014 11:21:31 -0700 Subject: [PATCH 2/2] Restore the pkg_resources calls so that we pull in the correct pycrypto on RHEL6 --- bin/ansible-playbook | 4 ++-- bin/ansible-vault | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ansible-playbook b/bin/ansible-playbook index 21635ea5735..6c023fc8cd7 100755 --- a/bin/ansible-playbook +++ b/bin/ansible-playbook @@ -18,8 +18,8 @@ ####################################################### -#__requires__ = ['ansible'] -#import pkg_resources +__requires__ = ['ansible'] +import pkg_resources import sys import os diff --git a/bin/ansible-vault b/bin/ansible-vault index 4929e1c2a19..07092376c40 100755 --- a/bin/ansible-vault +++ b/bin/ansible-vault @@ -20,8 +20,8 @@ # example playbook to bootstrap this script in the examples/ dir which # installs ansible and sets it up to run on cron. -#__requires__ = ['ansible'] -#import pkg_resources +__requires__ = ['ansible'] +import pkg_resources import os import sys