What's the difference between StaticPython and PyRun?

This blog post explains the difference between StaticPython and PyRun.

Both StaticPython and PyRun are free, portable binary distributions of Python 2.x and 3.x, for Linux, Mac OS X (and PyRun also works on FreeBSD without Linux emulation). That is, a user without root access can quickly download, extract and run either StaticPython or PyRun, and it won't conflict with the (possibly old) Python versions installed to the system (by root). Windows users should use Portable Python instead.

An important difference is that StaticPython doesn't need any external files to run on Linux, while PyRun needs lots of system libraries (libssl.so.1.0.0, libcrypto.so.1.0.0, libz.so.1, libsqlite3.so.0, libz2.so.1, libpthread.so.0, libdl.so.2, libutil.so.1, libm.so.6, libc.so.6), and will not work on systems which don't have all of the required libraries installed (with the required version), so PyRun is much less portable.

Another important difference is that with PyRun you can compile and install C extensions, and with StaticPython you can't (even ctypes doesn't work with StaticPython). However, many extensions are precompiled: Stackless + greenlet + libssl + Tokyo Cabinet + libevent2 + Concurrence + AES + Syncless + MessagePack + Gevent MySQL + PyCrypto.

Another important difference is that PyRun integrates nicely with packaging (setuptools, pip etc.), and is a nice, self-contained replacement for virtualenv. StaticPython doesn't help you with packaging, you have to do Python library installation and distribution manually.

There are many small differences, e.g. PyRun is available for both 32-bit and 64-bit, ans StaticPython is 32-bit only. PyRun needs at least 14 megabytes of disk space (10 megabytes for the binary executable and about 4 megabytes for the mandatory system library dependencies), and StaticPython needs between 6 and 9 megabytes depending on which feature set you need.

My recommendation: If PyRun works on your system (because you have the right version of system libraries installed, and you have enough free disk space), then use PyRun, otherwise use StaticPython.

Caveat: I am the author of StaticPython.


marcell said...

what's the recommended way to embed your own python application into a single exectuable?

Ivanelson said...

Hello! Where can I get a port of Static Python for AIX?

pts said...

@marcell: To embed your own python application into a single exectuable, use bbfreeze, PyInstaller, py2exe, or whatever DropBox uses. Please note that most of these will create more than a single executable file: each C extension (e.g. _socket.so) would be in a separate file next to the main executable.

StaticPython doesn't directly support building a custom executable, but it wouldn't be hard do add support. (Start by adding code to site.py before building StaticPython.) The unique advantage would be that it the whole application would be packed to a single executable (of 9 megabytes + the ZIPped size of the .py files): one executable For Linux and FreeBSD, and a separate one for Mac OS X. If you need someone to develop such a product, please give me an offer.

pts said...

@Ivanelson: I don't know of an existing port of StaticPython for AIX. I think there is no principal obstacle, just nobody cared to do it so far and publish it.

If you need an AIX port, please make me an offer. I estimate that it should be 2 days of work for me + 2 days of work for agreeing on the requirements, communicating etc.

Ivanelson said...


Sometimes it's boring to do system administration tasks in bash script. So I wanted to try Python. Unfortunately, I have no arguments to convince my employer to pay for your effort. : (