How do I deploy a Python desktop application?

I have started on a personal python application that runs on the desktop. I am using wxPython as a GUI toolkit. Should there be a demand for this type of application, I would possibly like to commercialize it.

I have no knowledge of deploying "real-life" Python applications, though I have used py2exe in the past with varied success. How would I obfuscate the code? Can I somehow deploy only the bytecode?

An ideal solution would not jeopardize my intellectual property (source code), would not require a direct installation of Python (though I'm sure it will need to have some embedded interpreter), and would be cross-platform (Windows, Mac, and Linux). Does anyone know of any tools or resources in this area?

Thanks.


Asked by: Ned326 | Posted: 06-10-2021






Answer 1

You can distribute the compiled Python bytecode (.pyc files) instead of the source. You can't prevent decompilation in Python (or any other language, really). You could use an obfuscator like pyobfuscate to make it more annoying for competitors to decipher your decompiled source.

As Alex Martelli says in this thread, if you want to keep your code a secret, you shouldn't run it on other people's machines.

IIRC, the last time I used cx_Freeze it created a DLL for Windows that removed the necessity for a native Python installation. This is at least worth checking out.

Answered by: Grace545 | Posted: 07-11-2021



Answer 2

Wow, there are a lot of questions in there:

  • It is possible to run the bytecode (.pyc) file directly from the Python interpreter, but I haven't seen any bytecode obfuscation tools available.

  • I'm not aware of any "all in one" deployment solution, but:

    • For Windows you could use NSIS(http://nsis.sourceforge.net/Main_Page). The problem here is that while OSX/*nix comes with python, Windows doesn't. If you're not willing to build a binary with py2exe, I'm not sure what the licensing issues would be surrounding distribution of the Python runtime environment (not to mention the technical ones).

    • You could package up the OS X distribution using the "bundle" format, and *NIX has it's own conventions for installing software-- typically a "make install" script.

Hope that was helpful.

Answered by: Adelaide781 | Posted: 07-11-2021



Answer 3

Maybe IronPython can provide something for you? I bet those .exe/.dll-files can be pretty locked down. Not sure how such features work on mono, thus no idea how this works on Linux/OS X...

Answered by: Catherine732 | Posted: 07-11-2021



Answer 4

I have been using py2exe with good success on Windows. The code needs to be modified a bit so that the code analysis picks up all modules needed, but apart from that, it works.

As for Linux, there are several important distribution formats:

  • DEB (Debian, Ubuntu and other derivatives)
  • RPM (RedHat, Fedora, openSuSE)

DEBs aren't particularly difficult to make, especially when you're already using distutils/setuptools. Some hints are given in the policy document, examples for packaging Python applications can be found in the repository.

I don't have any experience with RPM, but I'm sure there are enough examples to be found.

Answered by: Dainton224 | Posted: 07-11-2021



Answer 5

Try to use scraZ obfuscator (http://scraZ.me). This is obfuscator for bytecode, not for source code. Free version have good, but not perfect obfuscation methods. PRO version have very very strong protection for bytecode. (after bytecode obfuscation a decompilation is impossible)

Answered by: Owen285 | Posted: 07-11-2021



Similar questions

python - Django application deployment help

I'm using Capistrano to deploy a Django application (it uses Nginx as the web server), using instructions I found at http://akashxav.com/2009/07/11/getting-django-running-on-nginx-and-fastcgi-on-prgmr/ (I had to look at a cached version earlier today) and was wondering about the last command in there...


deployment - installing Python application with Python under windows

My application uses many Python libraries (Django, Twisted, xmlrpc). I cannot expect that the end user has the Python installed with all needed libraries. I've created a fancy installer for my application using Inno Setup, but I don't think that it is a good solution to execute 5 other setup programs from my installer. It would be annoying to the user to click "Next" button 15 times. Is there any way to do that qu...


Python WSGI deployment on Windows for CPU-bound application

What options do I have for the deployment of a CPU bound Python-WSGI application on Windows? The application benefits greatly from multiple CPUs (image manipulation/encoding) but the GIL prevents it from using them. My understanding is: mod_wsgi has no support for WSGIDaemonProcess on Windows and Apache itself only runs with one process all fork based solutions (flup, spawni...


deployment - How and where to deploy my Python and BottlePy application

Ok, so I made this application in Bottle that uses the NLTK package. It works fine on my computer which has all neccesary libraries installed, however, I can't get it to work on Google's App Engine. It gives these errors: AttributeError: 'module' object has no attribute 'getuid' I searched around and think this is a limitation of GAE, so I tried to use Alwaysdata and host my app there. Ho...


deployment - How would I package and deploy Python application like Mercurial hooks?

In this case, the application consists of one or more Python files, plus a settings.ini file. Now the Python files when being installed need to be installed in ~/.hg (as default) or prompted where the user want them installed. The installation also requires text to be appended to files like hgrc. Is there already a specific Python package that does all of this, or if anyone has any ex...


deployment - Python self contained web application and server?

What is a good and easy way to distribute a web application and server bundled together, python way? So I can say to a user "Here take this tar/whatever, unpack it and run blahblah.py" and blahblah.py will run a http/wsgi server and serve my application? Im looking for a stable production-ready multi-threaded wsgi-server with which I can bundle my app, without the need for nginx or other "frontends" or havi...


deployment - deploying a Python application from a PHP developer

I'm a little confused on the deployment process for Python. Let's say you create a brand new project with virtualenv source bin/activate pip install a few libraries write a simple hello world app pip freeze the dependencies When I deploy this code into a machine, do I need first make sure the machine is sourced before installing dependencies? I don't mean to ...


python - Flask application logfile is not written under Apache deployment

I deployed a Flask app on my Apache 2.2 instance on Windows, everything running fine. Then I decided to implement logging in my app and read the Flask docs: I decided to go with a file logger, which generates a logfile containing all the logs messages that I expect...this happens when I execute the application using the builtin Flask webserver. ...


python - Django Application deployment on linux server

I am trying to deploy django application on Linux server with mod_wsgi. Below are my setting for apache in httpd.conf file - <VirtualHost 127.0.0.1:8080> AddDefaultCharset utf-8 LogLevel warn ServerName myappletrade.com #WSGIProcessGroup appletrade WSGIScriptAlias / /var/www/html/appletrade/django.wsgi DocumentRoot /var/www/html/appletrade #WSGIDaemonProc...


python - deployment of Flask application to OpenShift

I would like to deploy my application which works fine on my local unix server to OpenShift cloud. I registered there and checkout git repository. But I don't know what to do now. Application in this repository has following structure: /libs /app.py /setup.py /wsgi static/ application but I don't know where I should copy my project in which files should be modified. My project struct...


python - Why won't Django 1.0 admin application work?

I've just started playing with Django and am loosely following the tutorial with my own set of basic requirements. The models I've sketched out so far are a lot more comprehensive than the tutorial, but they compile fine. Otherwise, everything should have been the same. My problem is with the admin application. I can log into it, and view the editable models, but when I click on a model or any of the change/add but...


python - What is the best way to serve static web pages from within a Django application?

I am building a relatively simple Django application and apart from the main page where most of the dynamic parts of the application are, there are a few pages that I will need that will not be dynamic at all (About, FAQ, etc.). What is the best way to integrate these into Django, idealing still using the Djang...


networking - Embedding a remote Python shell in an application

You can embed the IPython shell inside of your application so that it launches the shell in the foreground. Is there a way to embed a telnet server in a python app so that you can telnet to a certain port and launch a remote IPython shell? Any tips for redirecting the input/output streams for IPython or how to hook it up to a telnet server library or recom...


python - Debug Pylons application through Eclipse

I have Eclipse setup with PyDev and love being able to debug my scripts/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp?


naming - Deploying a python application with shared package

I'm thinking how to arrange a deployed python application which will have a Executable script located in /usr/bin/ which will provide a CLI to functionality implemented in A library installed to wherever the current site-packages directory is. Now, currently, I have the following directory structure in my sources: foo.py foo/ __init__.py ... which...


python - How can I capture all exceptions from a wxPython application?

I'm writing a little debug app for a bit of kit we're developing and I'd like to roll it out to a few users to see if they can provoke any crashes. Does anyone know a way of effectively wrapping a wxPython app to catch any and all unhandled exceptions that would cause the app to crash? Ideally I'd want to capture all output (not just errors) and log it to a file. Any unhandled exceptions ought to log to the current...


Starting a new database driven python web application would you use a javascript widget framework? If so which framework?

I am starting a new web application project. I want to use python as I am using it at my bread-and-butter-job. However I don't want to reinvent the wheel. Some things I have thought about: AJAX would be nice if it’s not too much of a hazzle. It is best if the licensing allows commercialization but is not crucial at this point. It could also be funny to try out the G...


console application - using curses with raw_input in python

In my python linux console application I use curses to handle displaying of data. At the same time I'd like to have an input line to enter commands, pretty much in good ol' irssi-style. With default curses getch() I'd have to do a lot of coding just to get the basic funcionality of raw_input function - arrow keys to move cursor / browse through the input history. Is there a simple way to get such behavior working w...


scripting - How can I launch an instance of an application using Python?

I am creating a Python script where it does a bunch of tasks and one of those tasks is to launch and open an instance of Excel. What is the ideal way of accomplishing that in my script?


Global hotkey for Python application in Gnome

I would like to assign a global hotkey to my Python application, running in Gnome. How do I do that? All I can find are two year old posts saying, well, pretty much nothing :-)






Still can't find your answer? Check out these communities...



PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python



top