Skip to content

Instantly share code, notes, and snippets.

@hdonnay
Last active December 18, 2015 00:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save hdonnay/5700506 to your computer and use it in GitHub Desktop.
Save hdonnay/5700506 to your computer and use it in GitHub Desktop.
Helper script to use esky with salt
#!/bin/sh
trap '[ -f patch.$$ ] && patch -R < patch.$$' 0
PATH="$PATH:`pwd`/patchelf/src"
set -e
#exec >/dev/null
[ -f setup.py ] || { printf "You seem to be in the wrong directory.\n"} >&2; exit 1; }
if ! which patchelf >/dev/null 2>&1; then
printf "Couldn't find 'patchelf', going to download and compile.\n" >&2
git clone https://github.com/NixOS/patchelf
(
cd patchelf
git checkout 0.6
./bootstrap.sh
./configure
make
)
fi
which virtualenv >/dev/null 2>&1 || { printf "'virtualenv' not found.\n" >&2; exit 1; }
which swig >/dev/null 2>&1 || { printf "'swig' not found.\n" >&2; exit 1; }
if [ -f freeze.cfg ]; then
exec < freeze.cfg
read deps
read includes
read ppath
else
printf "Enter a space separated list of packages to add as requirements:\n"
read deps
printf "Enter a space separated list of modules to attempt to include in the freeze:\n"
read includes
printf "Enter a colon separated list of paths to include in PYTHONPATH:\n"
read ppath
fi
export deps includes ppath
(
virtualenv --system-site-packages .env
. .env/bin/activate
pip install --upgrade pip
pip install --egg bbfreeze esky
cp setup.py setup.py.$$
cp requirements.txt requirements.txt.$$
for i in ${includes}; do
sed -i "/elif sys\\.platform\\.startswith('linux'):/a\\
freezer_includes.append('$i')" setup.py.$$
done
for i in ${deps}; do
echo $i >> requirements.txt.$$
done
diff -u setup.py setup.py.$$ > setup.py.patch.$$ || true
diff -u requirements.txt requirements.txt.$$ > requirements.txt.patch.$$ || true
rm setup.py.$$ requirements.txt.$$
patch < setup.py.patch.$$
patch < requirements.txt.patch.$$
python setup.py develop
python setup.py bdist
PYTHONPATH="$PYTHONPATH:$ppath" python setup.py bdist_esky
)
@hdonnay
Copy link
Author

hdonnay commented Jun 3, 2013

If one would, for example, like to include the redis module so the redis returner can be used and ldap for a custom grain, the freeze.cfg would look like this:

redis python-ldap
redis ldap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment