Install Path

Python's Distutils script accepts several options for setting the install path. These are:

  • --prefix to set the install path for everything

  • --install-libs to set the install path for libraries only

  • --install-scripts to set the install path for scripts only

  • --install-data to set the install path for data files only

If your script sets file paths appropriately, then you'll be able to install your Python package in /opt with a few quick changes in the debian/rules file. You can use a prefix to install everything under /opt, such as:

        dh_auto_install -- --prefix=/opt/

Or, you can choose specific types of files to install in /opt, with the other install options:

        dh_auto_install -- --install-lib=$(PKGDIR) --install-scripts=$(PKGDIR) --install-data=$(PKGDIR)

You don't have to use all three options together, you could choose just libraries, just scripts, just data, or some other combination of the options.


For the install options to work, you need to use file paths correctly in Specifically, executable scripts should be listed under 'scripts', and any data files like icons should be listed under 'data_files'. You can also use 'data_files' to install the few files that never install under /opt, like the extras-myapp.desktop file, apparmor profiles, and lenses and scopes. Here is one complete working script as an example.

from distutils.core import setup
from DistUtilsExtra.command import *

import glob

      author="My Name",
      license="GNU General Public License Version 2 (GPLv2)",
          ('icons', glob.glob('icons/*.png')),
          ('/usr/share/applications', ['extras-myapp-packagename.desktop']),
          ('/etc/apparmor.d', [
      cmdclass={"build":  build_extra.build_extra, }

We strongly encourage you not to include arbitrary code in your script (and may set policy disallowing it in the future).

AppReviewBoard/Submissions/PythonTips (last edited 2012-05-25 18:17:38 by allison)