How do I deliver ready-to-run software? - python

Recently I've been developing Python code as a freelancer. I've mostly worked on social media bots, my usual way of delivering the code is as a Python script for people to run on their compilers. However, I've started to run into people that lack the technical knowledge of installing modules and running the code that way. How do I create a package like software and deliver it in a way that can be ready-to-run and users don't have to download anything extra? Thank you in advance for your feedback.

Check out py2exe. It is a wrapper that converts your script into an executable, so the user can run it without needing to install any python libraries.
Alternatives to py2exe are:
PyInstaller - the advantage of using this is that it lets you build executables in formats other than exe, if you want to make your program run on non-Windows platforms, for example.
cx_Freeze - this is also another cross-platform alternative.

One method would be (as stated in the previous answer) is to use exe converters, but that wouldn't be as effective if you target Mac and Linux users as well.
My solution is going to take you a little more time, but it will be worth it. Here goes:
Please learn Angular JS, or some other framework (I prefer Angular). Once you know that, you can easily develop a web app for your project, and add your Python to that.
The good news is, there are lots of tutorials for this, such as https://codehandbook.org/creating-a-web-app-using-angularjs-python-mongodb/ (also teaches you mongodb) Anyways, you can find other tutorials on your own.
You could of course, I guess, build it into a mobile app, but I think web app would be easier.

Related

How do you turn a Flask app into a Perl plugin?

I have a Flask app using some Python libraries for NLP and audio processing that I want to turn into a Plugin for Audacity. Audacity accepts plugins in Nyquist, Perl, and C/C++. I'm guessing, because of the similarity between Perl and Python, that I should go that route. Audacity's docs are pretty sparse, and I haven't found any very useful tutorials, so I have a lot of questions. Forgive me if they're silly questions - this is really new territory for me. Any and all advice is welcome.
What are the steps necessary to turn that web app into a plugin?
Does creating a Perl plugin mean translating all the Python code into Perl, or just creating a Perl script that calls the Python code?
What does it mean that "scripting is not suitable for providing a service on a web server"?
Our Flask app relies on a large custom-trained model file for Mozilla's DeepSpeech - is it possible to handle very large files in a Plugin?
How do you test a plugin for a desktop app? Where do you see error logs?
Again, be gentle with me! I know these are probably silly questions, but I feel like my PM just dropped me in a foreign country with no map!
Number 1: for perl you need to build a Makefile.PL or use another module packager
Number 2: yes you will have to rewrite your code to perl. You probably could package it but you would have to assume that people installing your package have Python installed
Number 3: Hard to say, maybe they are worried about injecting code or possibly poor memory management from long running scripts
Number 4: You can ship large files, if you're duplicating and releasing other peoples code, it's maybe better to use their installer for it and decouple your code from it
Number 5: there are many ways to test it. You can (and should) decouple the UI from the business logic. The business logic cn be tested with standard unit testing. The UI with something like Selenium. You may also need integration tests to test end-to-end

Python front-end GUI for Linux

I'm planning to take a non-GUI Linux distro (no Gnome, KDE, etc) and build my own front-end GUI for it. While I have a few years of Python programming experience, I have never attempted to do something quite like this.
To be more specific about my project, I'm building a CarPC and I have everything pretty much worked out so far, except the front-end. Most pre-existing front-ends for CarPCs run on Windows and the ones that run on Linux are hard to find (they either quit development or only run on specific hardware). My front-end will always be full-screen and I do not want to run a desktop environment unless I absolutely have to; it would just slow down the boot time and provide unnecessary features.
My question is basically where I should start. What Python graphics libraries are out there that would allow me to build a front-end GUI without a desktop environment?
You'll probably want to look at other answers and questions on this topic such as this one
Another good link is this one on the Python websitewhich lists different GUI toolkits.
While I haven't used it, Kivy looks like a good place to start. It's apparently got touch screen capabilities which I assume you would use and it doesn't look constrained to a GUI desktop env.
Hopefully you can find a way to do this without a desktop env. If not perhaps consider using X11 as your layer and go from there.
You should probably consider DirectFB. You can even use a DE on it if you like (although not required).
WxPython is awesome. I use it with Python and plain WxWidgets in C++ too. I've had great luck with making native GUIs from it and internationalization is supported too. Good luck!
Edit: I missed the "without a desktop environment bit". I'm not sure my answer is relevant. You should edit the Title of the question. Just disregard.

Distributing Python apps

Quick question... Once I build a .py app, with wx gui, etc... I can compile it with pyinstaller or cx_freeze, and send the binaries to my servers, correct?
Is this a good way to distribute a script? I am fairly new to app development cycle... I have a few python script which I would like to make public, because they make my life easier...
If you were to share some code with the rest of community, provide people the .py code, and wanted to distribute binaries as well, would you compile .py with pyinstaller and cx_freeze, or would you use some other method?
Dev environment currently is Mac OSX, and a debian domU....
Thanks!
The best solution depends on who you're releasing it to, and what license you're releasing it under.
If you're not concerned about revealing the code of the apps you're distributing, then a service like github or bitbucket is the way to go. The best way to contribute your code to a community (if you're releasing it open source) is through version control because it allows people to contribute and learn from it.
But, depending on your audience, you might need something more "user-friendly". In which case, cx_freeze and pyinstaller are perfectly acceptable solutions.
If you're distributing a package, you may want to look into setuptools
See also http://wiki.python.org/moin/DistributionUtilities and How can I distribute Python programs?
To share open source projects online, GitHub is the popular choice.

How can I run Python code on a windows system?

I am used to using PHP and it is easy to set up, I can just run an exe package like Xampp and have apache and PHP running in 5 minutes on my windows system. Is there something similar to Python?
Unlike PHP, Python's primary purpose is a general-purpose tool for running on the desktop/server, not necessarily as a web application. It has bindings to many powerful GUI toolkits (Qt and wx are two examples of free and popular toolkits that work great on Windows), and so on. Therefore you just download it (either from python.org or from activestate), install it, and run it. That's it.
That said, Python is actually great for web apps too. See the Django tutorial for running a simple web-app on your PC in just a few minutes. Python actually comes with a simple web-server built-in, and it supports SQLite out of the box as well, so you can have a fully functional DB-backed web-application running without actually installing anything else. Naturally, if you need to use tools like MySQL and Apache, these are easy to connect to Python on the desktop too. Just start with that Django tutorial and everything will be clear.
Yes, you can find python from http://python.org
and If you like to make executable files from .py source file you may use py2exe
You don't say in your question what you are going to use Python for, so most answers above are completely correct in pointing out that you install Python by downloading it from Python.org. But you seem to expect more. Is it correct to assume you are going to use it to do web development?
In that case, prepare for a shock, because Python doesn't do things like PHP does at all. You want to use a web framework. There are loads of them for Python. Which on to use depends both on what you are going to do, and your personal taste.
The only "Download as one file and install to run" web system I know of that's based on Python is Plone. And Plone is great, but it's not a webframework, it's a content management system. But hey, maybe that's what you want? :-)
The other frameworks are usually easy to install as well.
(In the long run: If you are going to do web development, you'll be happier with something Unix based. Just saying.)
Download python installer and run python.
Nope no easy way out for you yet, Python is obviously not popular enough in Web dev. You should install mod_python and django. There are some nice step here.
Here's my opinionated answer:
Download and install ActivePython
Open Command Prompt and type pypm install django
Follow the Django tutorial
Note that Django does not necessarily require a webserver like Apache, as it already includes one for development purposes. Nor do you necessarily have to install MySQL as Python already includes SQLite which is supported by Django.

How do I develop and create a self-contained PyGTK application bundle for MacOS, with native-looking widgets?

I have read that it is possible to build GTK+ on MacOS X. I know that it's possible to create a bundle of a GTK+ application on MacOS. I also know that it's possible to create widgets that look sort of native. However, searching around I am not really clear on how to create a bundle that includes the native theme stuff, and uses Python rather than its own C main-point. There are also rumors that it's possible to build PyGTK, but it sounds like there might still be some wrinkles in that process.
However, there is no step-by-step guide that explains how one can set up an environment where an application might be run from Python source, then built and deployed in an app bundle. How can I go about doing that?
Native looking widgets is quite complicated.
There's a beginning of quartz engine (for theming) found here http://git.gnome.org/browse/gtk+/tree/gdk/quartz
For self-contained applications check out the newly released bundle on http://live.gnome.org/GTK%2B/OSX
I'm not sure if I'm grokking all the details of your question, but looking at your problem in general (how do I deploy a python app on mac), I'm inclined to say that the answer is py2app. Basically this will bundle a python interpreter and all relevant python files for you, and give you a scriptable system that you can use to add in whatever other resources/dependencies you need.
While it's not a guide solely targetted at python/GTK+/OS X, this post is a good, detailed description of someone else's attempt to do most of what you describe. Obviously, the app-specific stuff is going to vary.

Categories

Resources