Making Windows executables from Django applications - python

I am trying to make a Django website be a simple Windows executable. I've been told that py2exe does not work correctly, both due to Django using __import__, and to its attempting to dispatch manage.py in some obscure way. Is that the case? If so, is there an alternative tool that works better, or is there a way to work around the py2exe issues?

You can try Pyinstaller.

PyInstaller trunk has been succesfully used to build Django applications. It has builtin support for many Django magic, but requires a careful setup (have a look at the dedicated wiki page).

Related

Is there a simple way to include entire applications in pyinstaller?

As the title implies, I am looking for a way (if any) to include entire applications in my pyinstaller executable. I have seen the --include-binaries option for single-file binaries, as well as some vague hints as to where to get started for what I need, but never anything specific.
Since my application uses Selenium, and I'd not like the user to install google-chrome to use my application, I'd like to include a portable version of Chrome bundled within the exe, as well as a copy of wireshark (https://wireshark.org).
So far, I've worked on custom cross-platform setup files for Linux and MacOS using shell scripts, but I imagine there to be a cleaner way than messy wget requests to url.
Thanks for the help!

python and package installment while application is installed

I have done some image processing works using python 3.5, opencv, scikit modules etc for an unreal engine game application.
I have manually installed python and other modules using pip in my windows system.
Now when a user installs the application, i want python and those modules to be installed auto with the application's installment.
I saw pyinstaller which turns py file to application file but unfortunately could not understand how to work it of what i want.
Thank you for any piece of advice.
First, let me say Python packaging has improved a lot over the years, but is still considered very hard compared to other languages like e.g. golang.
Generally, I see two ways how to bring your applications to your user.
Either make a Python package or create an installable package for an operation system.
A Python package means, you could upload it somewhere (e.g. PyPi) and your users could pip install your_package. This involves a lot of work. A good starting point would be:
https://packaging.python.org/tutorials/packaging-projects/
The second option is to create an installer or e.g. Windows.
There are several tools out there, like the mentioned pyinstaller, more on this page: https://docs.python-guide.org/shipping/freezing/
Also, there is a new option called PyOxidizer ( https://pyoxidizer.readthedocs.io/en/stable/overview.html ).
At work we used cx_Freeze - which worked ok.
Unfortunately, there is no easy way. Have a look at several options, and then decide for one.

Create executable with Python, which use QT and different versions of python

I am planning to make a self contained app on OSX, which use a QT/PYQT UI with Python3, and also code using Python2 (because the libraries I use are not available on Python3 yet).
I am using Pyinstaller; which create apps that works fine on my machine, but when I try the same app on a different machine I get crashes or errors.
I was under the impression that Pyinstaller does generate a self contained app, but it seems that I still need to install QT on the computers that will run this app? Is there a better way to generate self contained apps, that would work in my scenario?
Deploying pure python apps with Pyinstaller is straight forward but it comes tricky especially with a framework like pyqt. The best results i got so far was using cx_freeze which makes sure that all the dependencies are packaged correctly.
Here is an extensive walkthrough:
https://www.smallsurething.com/a-really-simple-guide-to-packaging-your-pyqt-application-with-cx_freeze/

Distribute a Python without additional libraries and interpreter

I have a simple application. When I compile it in .NET I can just distribute the .dll or .exe without having an installer.
But how do I do this with Python? For example we have machine without the Python interpreter or with the Python interpreter but without 3rd party libraries.
You have a couple of options:
Provide an installer for Python. Once they've installed Python, they're good. They've already had the .NET runtime installed - this is really no different (except Microsoft didn't embed Python into their OS)
Use Portable Python. You can actually build your own version (though I've never done it so I have no clue how hard it would be).
Use cxFreeze or py2exe. This packages the python interpreter up along with your source so it looks like just one .exe but actually contains more
Use IronPython this way or distribute it in some other fashion.
If you don't require access to the local machine, use Flask or some other Python framework/microframework and host the app on the web using something like Heroku's free tier.
There might be some other options as well, but those are probably the most common.
Use Py2Exe. It makes a .exe file out of your script, including the interpreter and required libraries. It's going to be bigger than your script though because of the interpreter.

Is there a skeleton project for a graphical cross-platform Python application?

I found that making a Python application work across all three platforms with, say, PySide is hard enough work as it is. Surely there's a project that provides an example codebase where this all works (even packaging the application and deploying it as well)
You could use PyInstaller. The development version works with OSX and the older versions work with all linux distributions i have tried (ubuntu/debian, opensuse,...)
Just have a look at it, works fine for me www.pyinstaller.org

Categories