I know that all you really need to execute a python program is the python interpriter, what what if your program uses config files that might be in /etc, ~/.program, or C:\users\Name\Appdata ? How would you go about creating an installer for you python program and all of it's files and assets? Secondly, if you want your program to work with Linux and Windows would you use a one smart insaller or a different installers for each version? Thanks.

For the path problem:
1. Use relative paths when you can.
2. Detect the platform an decide on where you should look for the config files.
3. Use os.path.expanduser to find the users home directory and write the config there.
4. Use the installer to your advantage, and let the installer tell your program how all of the paths work.

For the installer problem:

First off, obviously a program written in python requires python. To get around this:
1. Tell the users that python is required.
2. Download python if it is not already installed.
3. Package python with the installer.
4. Use pyinstaller to make an executable out of the code.

The most standard way would be to use a different installer for each platform. For example, I would use Innosetup (NSIS and WIX also work here) for Windows, dgm for Mac and deb&rpm for linux. I would also create installers for different architectures as well as OS's.

Though, since this is python you can use some of python systems for installing packages. See https://python-packaging-user-guide.readthedocs.org/en/latest/current.html for more details.

pyinstaller to make an executable, wouldn't that eliminate the need for the python to be installed on the system?

pyinstaller to make an executable, wouldn't that eliminate the need for the python to be installed on the system?

Yes and there are more tool,a GUI tool for many freezing tool.

Nukita and also Cython can make "exe",a new approach pynsist
See video from pycon 2014, The Day of the EXE Is Upon Us conclusion at end of video.

If you search for cx_Freeze(work Linux and Windows) and py2exe(now also work Python 3) on Daniweb you find working code.
Innosetup as mention by Hiroshe is my favorite tool for make installer,fine to use after freezing tool to get a nice installer.

For my project wx_nrk(Downloading norwegian Tv)
Has some user ca2000,for Windows i used Py2exe and for Linux no packing tool just a readme with install instruction(easier for Linux user because Python is pre-installed).

Edited 2 Years Ago by snippsat

This article has been dead for over six months. Start a new discussion instead.