Suppose we have a program called foo.
If use absolute path:
setup(...,
data_files=[...,
('/etc', ['foo.cfg'])]
)
Then foo$ python setup.py --prefix=/usr/local and we will have /etc/foo.cfg.
But we should have /usr/local/etc/foo.cfg instead according to FHS.
What if we use a relative path?
setup(...,
data_files=[...,
('etc', ['foo.cfg'])]
)
Then if we use the default install path, i.e. install to /usr, we will have /usr/etc/foo.cfg. Bad
luck again.
So how to do it right?
P.S. To avoid make the problem more complicated, we assume that this program
foo cannot run under non unix environment.
Sub-classing
distutils.command.install.installis not strictly necessary. Instead,data_filescould be passed tosetup, as perdistutilsdocumentation on 'Installing Additional Files'.e.g.
where
conf_pathis calculated as per your own requirements. i.e. construct it by testingsys.prefix(instead ofself.prefix), like @weakish did above.