Skip to content

Instantly share code, notes, and snippets.

@UtahDave
Forked from hdonnay/mk_freeze.sh
Created June 3, 2013 19:58
Show Gist options
  • Save UtahDave/5700889 to your computer and use it in GitHub Desktop.
Save UtahDave/5700889 to your computer and use it in GitHub Desktop.
#!/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 packages
read includes
read ppath
else
printf "Enter a space separated list of packages to include in the virtualenv:\n"
read packages
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 packages includes ppath
(
virtualenv --system-site-packages .env
. .env/bin/activate
pip install $packages bbfreeze esky
cp setup.py setup.py.$$
for i in ${includes}; do
sed -i "/elif sys\\.platform\\.startswith('linux'):/a\\
freezer_includes.append('$i')" setup.py.$$
done
diff -u setup.py setup.py.$$ > patch.$$ || true
rm setup.py.$$
python setup.py develop
python setup.py bdist
patch < patch.$$
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