Wednesday 31 October 2012 20:00
Every so often, you have an idea for a little project that's both useful and fun to implement (but mainly fun), and you get pleasantly surprised when you manage to knock it out in a day. stickytape is one of those little projects. You can use it to take a Python script that depends on a load of pure-Python modules, and convert it into a single-file Python script. Admittedly, it's all one big hack -- the single-file script writes out all of its dependencies to temporary files before running the original script. It does the job for my purposes though, and it's much quicker and smaller than setting up or copying virtualenvs.
All you need to do it point it at the script you want to transform, and where stickytape should be searching for packages and modules:
stickytape scripts/blah --add-python-path . --output-file /tmp/blah-standalone
You can also point stickytape at a specific Python binary to use the values
to search for packages and modules:
stickytape scripts/blah --python-binary _virtualenv/bin/python \ --output-file /tmp/blah-standalone
pip install stickytape