pythonlinuxinstallationdebiandistutils

How to use Python distutils?


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.


Solution

  • 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 = "that.guy@initech.com", 
              version = '1.0.5', 
              package_dir = {'Package3' : 'site-packages/Package3'}, 
              packages = ['Package3', 'Package3.Queries'], 
              data_files = [ 
                           ('/etc/Package3', ['etc/Package3/ExternalResources.conf']) 
              ])