1 """distutils.command.install_data
3 Implements the Distutils 'install_data' command, for installing
4 platform-independent data files."""
6 # contributed by Bastian Kleineidam
11 from types
import StringType
12 from distutils
.core
import Command
13 from distutils
.util
import change_root
, convert_path
15 class install_data (Command
):
17 description
= "install data files"
21 "base directory for installing data files "
22 "(default: installation base dir)"),
24 "install everything relative to this alternate root directory"),
25 ('force', 'f', "force installation (overwrite existing files)"),
28 boolean_options
= ['force']
30 def initialize_options (self
):
31 self
.install_dir
= None
36 self
.data_files
= self
.distribution
.data_files
39 def finalize_options (self
):
40 self
.set_undefined_options('install',
41 ('install_data', 'install_dir'),
47 self
.mkpath(self
.install_dir
)
48 for f
in self
.data_files
:
49 if type(f
) == StringType
:
50 # it's a simple file, so copy it
53 self
.warn("setup script did not provide a directory for "
54 "'%s' -- installing right in '%s'" %
55 (f
, self
.install_dir
))
56 (out
, _
) = self
.copy_file(f
, self
.install_dir
)
57 self
.outfiles
.append(out
)
59 # it's a tuple with path to install to and a list of files
60 dir = convert_path(f
[0])
61 if not os
.path
.isabs(dir):
62 dir = os
.path
.join(self
.install_dir
, dir)
64 dir = change_root(self
.root
, dir)
67 data
= convert_path(data
)
68 (out
, _
) = self
.copy_file(data
, dir)
69 self
.outfiles
.append(out
)
71 def get_inputs (self
):
72 return self
.data_files
or []
74 def get_outputs (self
):