It turns out it is non trivial (afaict) to include a tree of files (a directory) in a python distutils data_files argument. Here’s how I managed to do it, while also allowing the programmer to include manual entries:
NAME = 'project_name'
distutils.core.setup(
# ...
data_files=[
('share/%s' % NAME, ['README']),
('share/%s' % NAME, ['files/somefile']),
('share/%s/templates' % NAME, [
'files/templates/template1.tmpl',
'files/templates/template2.tmpl',
]),
] + [('share/%s/%s' % (NAME, x[0]), map(lambda y: x[0]+'/'+y, x[2])) for x in os.walk('the_directory/')],
# ...
)
Since data_files is a list, I’ve just appended our specially generated list to the end. You can do this as many times as you wish. The list is a comprehension which builds each tuple as it walks through the requested directory. I’ve chosen a root installation directory of ${prefix}/share/project_name/the_directory/ but you can change this code to match…
View original post 47 more words
Advertisements