Deploy Python Command-Line Application - python-3.x

So I wrote a little Command-Line App and want to provide an easy way to clone and use it. Problem: My app has some dependencies like Hashlib and Pyperclip.
Is there a best practice to get missing packages installed on a different machine?
Can I do so without people needing to install global pip packages?
It is a good idea to ship it as a venv?
Can like compile them into a single python file (somewhat like a binary)?
If I cannot do so, how to I get packages installed on a different machine?
Is there a nice routine to allow the user to completely remove my app once installed?

You could use the py2exe module to make a standalone application for the Windows platform. You can use py2app to make standalone apps on the Mac platform. For Linux, you should prepare a package using the .deb format to target the Ubuntu/Debian environment (which is one of the most popular flavors of *nix). Each other *nix flavor has its own packaging system that you would have to follow to target it as a platform.

Related

Distribute wxWidgets applications on Linux platforms

I started to learn wxWidgets some days ago and I found it really good, but when I tried to "export" it to another platform, it didn't work. I expected that, but when I searched how to distribute wxWidgets apps, I didn't find that much, except to install all the wxWidgets library on that platform.
I use Debian 10, while the other platform where I need to export my app uses Lubuntu. It says that it needs a wxgtk3.0 library, but I guess that library will need even more libraries.
How do I export my wxWidgets application without asking the user to manually install and build all the library on its platform? Maybe even using .deb package (if really needed). Thanks in advance.
Please understand that every single distribution uses it own format comparing to Windows where there is an Installation Wizard or OSX where there is a Bundle.
Now, you can create a deb file where you set everything up.
So you can create an rpm (which is basically the same thing as deb, just for different distribution).
This is the best way as it ensures that all dependencies and their versions are satisfied.
Hope this helps!
Many Linux distributions have wxWidgets packages, so one possibility would be to simply ask users to install these packages when they need to use your application. This is not really different from installing GTK libraries or even X11 (or Wayland) that your application also depends on -- the only difference is that these libraries are almost surely already installed on any Linux desktop system, while wxWidgets ones might not be.
Another alternative is to link your application statically with wxWidgets libraries. This will make it much bigger and will prevent the users from upgrading the libraries on their system to improve the application behaviour, but can be simpler for the users to install. Note that if you choose the static linking route, you typically need to build your application on the oldest distribution you want to support (which is probably not Debian 10, which is relatively recent), as this is a simple way to ensure that it doesn't require newer versions of the (other, non-wx) libraries than the ones already present on the user's system.

Install frameworks in IDE or system wide?

When installing Node.JS or PyTorch for example, I can either install those in the regular system wide linux terminal or I can use the PyCharm or VS Code terminal.
With PyCharm from my understanding I can create virtual environments to manage different Python versions. Is it the same in VS Code?
If not, is there a difference between installing Node.JS through VS Code or the system terminal?
A virtual environment is much better, because you have control of the version. It is easy e.g. when you have one version in production, and one in development, and you are try to see if you can upgrade the tools.
Pycharm now is collaborating with Anaconda, to improve integration of the two tools, so with conda environment you can have not only python virtual environment, but npm and other non python programs/utilities.
The disadvantage: some more command to learn (and it is more complex), but you will make mistakes, with virtual environment you just remove such environment and you start again. On system it is more difficult to know what you installed, what was on base system etc
All the options have their pros and cons.
Installing anything by an IDE would make your development dependant on that IDE. Furthermore, you lose the options to learn the package management of the software what you use.
Learning npm or pip is really not a serious thing, the IDE shortcuts are for really beginners on this sense.
However, in many cases they may make your IDE to "know" about the packages better.
I would strongly disagree to install anything system-wide. They can have unwaited interactions with your system.
Best if you install them as user, into your home, but independently from your IDE. However, this requires the most learning.

What are some mechanisms to package cross-platform Electron apps in a single build?

I'm developing a desktop application based on Electron and I use electron-packager to create executables. The app uses some binary node modules such as bcrypt.
On my Mac, I package the app, targeting both OSX and Windows. The resulting package runs fine on OSX. But when I run the resulting Windows package (.exe and dependencies) on Windows 8.1 64 bits, the app throws an error (quite expectedly):
Is there any practice or tool that helps me be able to do the packaging once in any OS, even if the app depends on binary modules, and produce executables for Windows, OSX and Linux? For example, I'd like to run the build on OSX to produce executables for all three operating systems, instead of having to repeat the packaging for each platform
You should look into removing native binary requirements from your project if possible. For example the module you mention, bcrypt, has another implementation which is full JS and doesn't require native binaries: https://www.npmjs.com/package/bcrypt-nodejs
If you really need to include compiled binaries as a part of your dependencies you're probably going to have to design that part of the build/packaging automation yourself.

application installer

how to create installer of application( .sh and .pl files) on ubuntu? and how to install it?
We need more details to give you a proper answer. However, if you're looking for something installable on a GNU/Linux distribution, I'd recommend you package your application as an RPM or a DEB.
On the other hand, if you simply want to create a self extracting "installer", you can consider using makeself.
I don't know about any perl tool that does this.
For linux/unix platform I used InstallAnywhere and InstallShield Universal. Both allows to create projects which can be built for various platforms including win and mac and for linux platforms it creates .bin package which can be installed rather with UI or console mode.

Best approach to writing a generic installer for a Linux application?

We have a Linux server application that is comprised of a number of open-source tools as well as programs we've written ourselves. Ideally we would like to be able to install this application on any common Linux distribution.
In the past, we've written perl scripts to automate installs of this application. Unfortunately, due to idiosyncrasies of different Linux distros, the logic inside these install scripts gets horribly complex, and can change as new versions of each supported distro are released. Maintaining the installer thus becomes one of the most time-intensive parts of the project!
I'm looking for assistance, be it a framework, documentation, code samples, that can make this process less painful. Here are the types of things our installer needs to do:
Create user/group accounts
Create directory trees with specific ownership and permissions
Install open-source applications, potentially compiling them from source during install
Insert pre-compiled binaries, scripts, config files, and docs into specific directories
Register init-type startup and shutdown scripts
Generate encryption keys
Verify connectivity to a central server
Instead of the installer approach, I think a better way than having a single script that does it at install time is to have a build system which generates .deb or .rpm files suitable for installation on each system you have to support.
A poor man's way of going at that might be to use checkinstall, which creates packages from the files installed via 'make install'. So you'd build your app on each system and have the package magically created in the distro's native format.
I believe that most of the tasks which you describe are fairly standardized between Linux distros. In my experience, the following should work the Debian family (including Ubuntu) and the Red Hat family (including Fedora and CentOS):
Create user / group accounts - adduser command
Create directory trees - mkdir or install, or just expand a tarball
Install open source applications - Unless you have particularly esoteric needs, this should probably be left to the distro's package manager.
Install files - install, or just expand a tarball
Startup and shutdown scripts - install to /etc/init.d then symlink to /etc/rc*.d
VMware Server is freely available for Linux and does most of the tasks which you describe. It uses Perl and maybe shell for its installation and configuration, so you might see the approach that it takes.
However, speaking as a Linux admin, I strongly prefer applications that integrate with my package management system. In other words, create .deb and .rpm files, as Vinko Vrsalovic suggested. Building packages is extremely well documented:
Building RPMs for Fedora (or Red Hat or CentOS): draft documentation, RPM Guide
Building .debs for Debian (or Ubuntu): Debian Maintainer's Guide
I tried Autopackage a few years ago, don't know how universal it is but worked quite well (was the only truly universal way back then). Surely you have to provide some LSB-compatible ways of setting up proper directories on your own, but this piece of software should help you.
Though there's probably still too much diversity among linux distributions to do everything in a completely platform-agnostic way but I may be wrong.
You may want to try BitRock InstallBuilder. It is a cross platform installation tool that allows you to do exactly what you are looking for (adding users, installing services, install pre-compiled binaries, etc). Although some of the other posts mention a number of tools that you could use in your scripts, the problem is that every Linux distribution is a bit different and simple tasks like adding an user or installer a service are suddenly non-trivial when you need to do them across Debian, Ubuntu, Mandriva, RedHat, Gentoo, etc. A good cross platform installer should isolate you from all that. Many commercial open source companies like MySQL, SugarCRM, Zenoss, Jaspersoft, Groundwork etc. have built installers based on our technology exactly because of that (in addition to their regular source code tarballs, etc.) We also provide free licenses for open source projects.
Autopackage now merged with Listaller project. Documentation's not really thorough yet but seems to be working.

Resources