Is there a way to compile python application into static binary?
<p>What I'm trying to do is ship my code to a remote server, that may have different python version installed and/or may not have packages my app requires.</p>

<p>Right now to achieve such portability I have to build relocatable virtualenv with interpreter and code. That approach has some issues (for example, you have to manually copy a bunch of libraries into your virtualenv, since <code>--always-copy</code> doesn't work as expected) and generally slow.</p>

<p>There's (in theory) <a href="https://wiki.python.org/moin/BuildStatically">a way</a> to build python itself statically.</p>

<p>I wonder if I could pack interpreter with my code into one binary and run my application as module. Something like that: <code>./mypython -m myapp run</code> or <code>./mypython -m gunicorn -c ./gunicorn.conf myapp.wsgi:application</code>.</p>

<p>If you are on a Mac you can use py2app to create a .app bundle, which starts your Django app when you double-click on it.</p>

<p>I described how to bundle Django and CherryPy into such a bundle at <a href="https://moosystems.com/articles/14-distribute-django-app-as-native-desktop-app-01.html" rel="nofollow">https://moosystems.com/articles/14-distribute-django-app-as-native-desktop-app-01.html</a></p>

<p>In the article I use pywebview to display your Django site in a local application window.</p>

python build