Last active
December 18, 2015 00:59
-
-
Save hdonnay/5700506 to your computer and use it in GitHub Desktop.
Helper script to use esky with salt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If one would, for example, like to include the
redis
module so the redis returner can be used andldap
for a custom grain, thefreeze.cfg
would look like this: