Here’s how to use Eggsac with Flask’s demo app, Flaskr:
# Create and activate a new virtualenv, "flaskr"
virtualenv ~/envs/flaskr
source ~/envs/flaskr/bin/activate
pip install eggsac
git clone https://github.com/mitsuhiko/flask.git
Flaskr isn’t a true standalone installable Python application, as it doesn’t have a setup.py. So let’s make one, for the purposes of this tutorial, in flask/examples/setup.py:
#!/usr/bin/env python
from setuptools import setup
setup(
name='Flaskr',
packages=['flaskr'],
install_requires=[
'Flask',
],
zip_safe=False,
include_package_data=True,
package_data={
'': ['*.sql'],
'flaskr': ['static/*', 'templates/*'],
},
)
Now, invoke Eggsac:
eggsac --python-package flaskr --keep
This will install Flaskr into a relocatable virtualenv at (somewhere like) /tmp/flaskr_None-20131201t1516-master-afd3c45/.
Let’s run this copy of Flaskr:
cd /tmp/flaskr_*/flaskr/
source bin/activate
python lib/python2.7/site-packages/Flaskr-*.egg/flaskr/flaskr.py
Flaskr should run.
Now, let’s package Flaskr into a gzipped tarball in the current directory:
eggsac --python-package flaskr --tar-gzip --output-dir .
Let’s unpack that tarball elsewhere to demonstrate that the virtualenv is relocatable:
mkdir ~/flaskr_demo
tar -zxf flaskr.tar.gz --directory ~/flaskr_demo/
pushd ~/flaskr_demo/flaskr
source bin/activate
python lib/python2.7/site-packages/Flaskr-*.egg/flaskr/flaskr.py