[Distutils] Best practices to package a desktop application

Jonathan Ballet jon at multani.info
Thu Dec 29 16:04:37 CET 2011


Hi,

I hav a desktop application which currently runs only on Linux using
pyGtk, and is packaged using setuptools/distribute.

It ships with a number of non-Python files:

* documentation (README, Changelog, Authors, etc.)
* .desktop file
* application specific's icons
* one man file
* translation files
* and one executable script

The setup.py file looks like this so far:

    setup(
        name='myapp',
        ...
        packages=["myapp"],
        package_dir={"myapp": "myapp/"},
        data_files=[
            ('share/myapp', ['README', 'Changelog', 'Authors']),
            ('share/applications', ['myapp.desktop']),
            ('share/pixmaps', glob.glob('myapp/pixmaps/*')),
            ('share/man/man1', ['myapp.1']),
            ('share/locale/fr/LC_MESSAGES', ['mo/fr/myapp.mo']),
            ... numerous other translation files ...

        ],
        entry_points={'console_scripts': ['myapp=myapp:run']},
    )

but I somehow have a bad feeling about this, except for the entry point
(which does a great job).

When I run ``python setup.py install --prefix="local"``, everything gets
installed into ``site-packages/myapp/``, Python files and data files,
which seems to be a feature of setuptools/distribute over plain
Distutils, whereas it seems to be "cleaner" to split things as described
by the ``data_files`` setting (and AFAIK, Distutils does just that).

To be clear, I end up with

    install/lib/python2.7/site-packages/myapp.egg/myapp.py
    ...
    install/lib/python2.7/site-packages/myapp.egg/share/myapp/README
    ...
    install/lib/python2.7/site-packages/myapp.egg/share/pixmaps/myapp.png
    ...
    install/lib/python2.7/site-packages/myapp.egg/share/locale/fr/LC_MESSAGES/myapp.mo
    ...

Whereas I "think" I would like to have this instead, which looks more
organized to me:

    install/lib/python2.7/site-packages/myapp.egg/myapp.py
    ...
    install/share/myapp/README
    ...
    install/share/pixmaps/myapp.png
    ...
    install/share/locale/fr/LC_MESSAGES/myapp.mo
    ...

Actually, someone reported this "bug" to me, as he was expecting the
latter whereas he got the former.


Also, the application currently uses a custom method to find the
location of those data files (mainly the icons which are used at
run-time). It does a "terrible" job of trying several well-known
locations until it either reaches the file or fails with a laconic
error. I guess using ``pkg_resources`` data-access API would be much
better, right?


Finally, I'm also concerned about Linux distribution packagers, and I
would like to package the application so that it also useful and easy
for them to repackage and distribute it.


After reading setuptools/distribute and distutils documentations, I'm
still not what is the best way to proceed. Any hints would be greatly
appreciated.

Regards,

 Jonathan


More information about the Distutils-SIG mailing list