Accessing prefix within setup.py (distutils)

Graham Ashton graham at effectif.com
Mon Oct 4 19:06:39 EDT 2004


I'm writing a setup.py script for installing my application and have a
quick distutils question. My application has a .py file, a
.conf file and a .glade file. I would like them to get installed as
follows:

   /usr/local/bin/myprogram.py
   /usr/local/etc/myprogram.conf
   /usr/local/share/myprogram/glade/myprogram.glade

This is quite achievable if I specify a prefix of /usr/local, with the
following:

    setup(...,
          scripts=["myprogram.py"],
          data_files=[("share/myprogram/glade", ["myprogram.glade"]),
                      ("etc", ["myprogram.conf"])]
          )

My question is how to avoid installing myprogram.conf into /usr/etc
(instead of /etc) if the installer specifies a prefix of /usr? Doesn't
distutils know the difference between a data file and a config file?

If I could detect what the --prefix parameter was set to I could deal with
it myself within setup.py, but I don't seem to be able to get hold of it.

Thanks in advance.

-- Graham



More information about the Python-list mailing list