3
# Subclass of normal distutils install_data command to allow more
4
# configurable installation of data files.
7
from distutils.command.install_data import install_data
8
from distutils.util import change_root, convert_path
10
class install_data_ext(install_data):
12
def initialize_options(self):
13
self.install_base = None
14
self.install_platbase = None
15
self.install_purelib = None
16
self.install_headers = None
17
self.install_lib = None
18
self.install_scripts = None
19
self.install_data = None
24
self.data_files = self.distribution.data_files
28
def finalize_options(self):
29
self.set_undefined_options('install',
32
('install_base', 'install_base'),
39
('install_lib', 'install_lib'),
42
('install_data', 'install_data'))
47
This is where the meat is. Basically the data_files list must
48
now be a list of tuples of 3 entries. The first
49
entry is one of 'base', 'platbase', etc, which indicates which
50
base to install from. The second entry is the path to install
51
too. The third entry is a list of files to install.
53
for lof in self.data_files:
55
base = getattr(self, 'install_' + lof[0])
57
base = getattr(self, 'install_base')
58
dir = convert_path(lof[1])
59
if not os.path.isabs(dir):
60
dir = os.path.join(base, dir)
62
dir = change_root(self.root, dir)
67
# If there are no files listed, the user must be
68
# trying to create an empty directory, so add the the
69
# directory to the list of output files.
70
self.outfiles.append(dir)
72
# Copy files, adding them to the list of output files.
75
(out, _) = self.copy_file(f, dir)
76
#print "DEBUG: ", out # dbg
77
self.outfiles.append(out)