What windows tooling to create Python bdist_msi package? - python

Can someone point me at a good introduction to creating a Windows MSI installer for a Python package? The function that I need is:
Raise the Windows auth level
Install as normal using pip...
Now run additional script to move some files where a standard user cannot put them
Reverse this on uninstall.
It looks like a bdist_msi is the simplest way to achieve this but the internet seems somewhat lacking on a good example showing what Windows tooling I need to add to enable python setup.py bdist_msi to do its stuff.
Thanks!

Related

any known way to create a device-to-device portable self-contained python runtime?

I want to distribute a python program on, say, Windows and/or Mac, but I don't want to give the user the headache of ensuring there is an appropriate python runtime installed on their machine. And i don't want to interfere with their machine's configuration by, let's say, requesting root privileges and installing a system-wide python runtime on their system that suits my program specifically because it's too invasive and might cause compatibility collisions with other installed versions of the runtime.
I would much rather have a self-contained executable that could be, for example, stored on a USB flash-drive, inserted into the system, and then maybe with a stepping-stone binary executable that just invokes the device-portable runtime on a python script that I provide, I could then run the program as if it were a self-contained binary executable (with only standard-library dependencies).
A link to this binary executable could be published into main-menu program lists, docks, or desktops. And it could be invoked by shell scripts or other executed-by-proxy mechanisms. Such a no-install/self-contained python program could potentially be a first-class user-invokable application. This is what I want to achieve.
I googled around for projects that provided a device-portable/mobile python installation and so far I've only found portablepython.com. Unfortunately it says the project is discontinued and no download link for the project is provided. it listed some similar projects but they all seemed defunkt or with a very different focus.
Does anyone know of an active project that is or includes such an independent/portable/mobile/no-install distribution for python?
or is there some way i could configure python's build system to build a noinstall-friendly product?
any ideas welcome. thanks for your input!
After more searching I found that Python.org publishes its own standalone-python distribution called the embeddable zip file.
This is exactly what I was searching for. It's a basic python standalone runtime that requires relatively few megabytes of storage.
I started with this embeddable distro and then cajoled a standalone copy of pip to work with it. Problem solved.
Improving upon #oreus2020's answer, you can download the embeddable zip file from here. Then, unzip the compressed file to a folder of your choice. Go to the root of your install and find python._pth file and open it in a text editor. Remove the "#" before import site(This file is the one which manages the environment of the portable install. If you want anything to be recognized by the portable python interpreter, just throw the path in here and that's it!). If you want pip, go to this page and save it in the root of your portable install and run it using the portable python interpreter like ./python get-pip.py from a commandline opened at the root of your install. Pip installed! To use the pip, do ./python -m pip <commands> from the commandline opened at the root of your install and then open the python._pth file and insert the following below the "." ./Lib/site-packages ./Scripts. Voila, you got yourself a python portable install!
My python._pth file looks like:
python39.zip
.
# Uncomment to run site.main() automatically
./Repo
./Repo/Code
./Repo/Code/cogs
./Lib/site-packages
./Scripts
import site
If you are still wondering, here is the link to the one I made for myself.
P.S. Pardon my bad English

How to ditribute my Unix application?

I created a command-line python tool for Unix systems.
I want my script to be executed from anywhere just like any Unix command. One solution is to make my script executable and move it to /usr/bin.
But the script works with external files, and I guess moving all these files with my script in /usr/bin is a bad habit, as it will be hard to delete them one by one in the future.
Where should I put the directory of my application ? How to add the main script to the PATH, to execute it from anywhere ?
I would like then to create a package that could move my files in the right place, and delete them in the case the user wants to uninstall my application.
I don't know how to do this.
Thank you.
There are many way of distributing a Linux application.
It will depend on the distribution you are using, since they do not all use the same package manager. For example, you would create a .deb package for Debian, Ubuntu and there derivatives, an Arch package for Archlinux, etc...
You could then share the package with anyone to let them install your tool.
However, since your tool is in written in Python, you can also make a python package. You could then upload it to the Python Package Index to let anyone install it using python's pip package manager.
To create a python package, you will need to create a file called setup.py, and, from it, to call the setup method from the setuptool packages.
You will probably want to read the python documentation about writing such a script: https://setuptools.readthedocs.io/en/latest/setuptools.html
You may especially be interested by this sections:
Including Data Files
Automatic Script Creation
If you do things correctly, setuptools will take care of installing your script and its files somewhere in the PATH so it can be executed from the command line.
You should use setuptools to distribute your application, creating a setup.py file to configure its setup and installation.
Binaries can be delivered using the console_scripts option, while data files can be delivered using either package_data.

How to package a python script for Windows OS(.exe)?

I want to distribute my open source python tool.
I created an install shell script for linux systems. What is the easiest way to create a graphical easy to use installer for Windows OS?
PS: I would consider the ability to add shortcut on desktop as a plus point.
Py2Exe is still the best way I'm aware of. You can do tricky things if you're someone like Dropbox.
EDIT If you're looking for advice on creating an installer, start here

setup.py, makefile... What I need?

I've been reading a lot these days, and I'm not sure about the specific use of it. I need ask it, because cannot find someone who explain it to me. Now I'm lost..
The main problem is I need install my app (python + glade) in "/usr/share/name_app" and a ".desktop" file in "/usr/share/applications" in Ubuntu.
The solution that I've find is creating a ".deb" file because the installation is perfect. In ubuntu I can launch it with Unity clicking on the launcher, the ".desktop".
(Probably I'll upload it to "Ubuntu Software Center").
For windows I could use "py2exe" or a similar, and another one for Mac.
But, like the code is in GitHub, it should have a "setup" or a "makefile" to install it.
After reading and reading (and reading), I think that "setup.py" is only for install a module and then import it with python.
However if I have to install and app, how can I distribute it making a "setup.py" or a "makefile"? Which is better for install an app? Which is the diference? What I have to use?
Thanks:)
setup.py is used to deploy Python applications and modules with virtualenv http://www.virtualenv.org/en/latest/index.html setup.py is mostly useful for the application developers - you can run
python setup.py develop
within virtualenv to set-up your development workspace with Python dependencies.
For each platform distribution (Windows, OSX, Linux) use the distribution tools as you are currently using.
You can also use setuptools tools to roll out packages from setup.py for the platform architecture. Eg. creating .deb from setup.py
http://pypi.python.org/pypi/stdeb/
More info about setup.py
http://packages.python.org/distribute/setuptools.html
To grasp general concepts you could read stdlib docs: An Introduction to Distutils.
The first several links for keywords: "python packaging" are to: Python Packaging User Guide that should show what setup.py is and how to use it.

Python: Handling modules

I wrote a program which uses a number of built in modules. The program is meant to be used by different persons on their systems. They dont have enough knowledge in python to install it when their system doesnt have the module needed to run the program. Is there any way of handling that.
Also I want to package the program as an executable in linux. It contains 3 py files and one text file only.
I think what you need is to create a debian package that handles the dependencies and the installation process.
I'm an Ubuntu user but this Complete Ubuntu Packaging Guide should help you get started. Good luck!
You can create an executable that contains your python modules and the python interpreter. You can use PyInstaller for creating such an executable.
I think the easiest way to achieve this on a debian distribution is to package your python application in a debian package. You can use this module to make life easier.

Categories

Resources