26

I wrote a quick program in Python to add a gtk GUI to a cli program. How can I create an installer using distutils? Since it's just a GUI frontend for a command line app it only works in *nix anyway so I'm not worried about it being cross platform.

My goal is to create a .deb package for Debian/Ubuntu users, but I don't understand make/configure files.

1
  • Do not include solution to question please (post a separate answer instead). Commented May 20 at 0:40

3 Answers 3

14

See the distutils simple example. That's basically what it is like, except real install scripts usually contain a bit more information. I have not seen any that are fundamentally more complicated, though. In essence, you just give it a list of what needs to be installed. Sometimes you need to give it some mapping dicts since the source and installed trees might not be the same.

Here is a real-life (anonymized) example:

#!/usr/bin/python 

from distutils.core import setup 

setup (name = 'Initech Package 3', 
          description = "Services and libraries ABC, DEF", 
          author = "That Guy, Initech Ltd", 
          author_email = "[email protected]", 
          version = '1.0.5', 
          package_dir = {'Package3' : 'site-packages/Package3'}, 
          packages = ['Package3', 'Package3.Queries'], 
          data_files = [ 
                       ('/etc/Package3', ['etc/Package3/ExternalResources.conf']) 
          ])
Sign up to request clarification or add additional context in comments.

2 Comments

can the data_files path be absolute ? I've got ValueError: path '/etc/Package3' cannot be absolute
Plus 1 for "Initech" - the only thing that would have been better is "Plas-trol-tech"
6

apt-get install python-stdeb

Python to Debian source package conversion utility

This package provides some tools to produce Debian packages from Python packages via a new distutils command, sdist_dsc. Automatic defaults are provided for the Debian package, but many aspects of the resulting package can be customized via a configuration file.

  • pypi-install will query the Python Package Index (PyPI) for a package, download it, create a .deb from it, and then install the .deb.
  • py2dsc will convert a distutils-built source tarball into a Debian source package.

Comments

1

distutils really isn't all that difficult once you get the hang of it. It's really just a matter of putting in some meta-information (program name, author, version, etc) and then selecting what files you want to include. For example, here's a sample distutils setup.py module from a decently complex python library:

Kamaelia setup.py

Note that this doesn't deal with any data files or or whatnot, so YMMV.

On another note, I agree that the distutils documentation is probably some of python's worst documentation. It is extremely inclusive in some areas, but neglects some really important information in others.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.