2000-05-12 01:58:29 +00:00
|
|
|
"""distutils.command.install_data
|
|
|
|
|
|
|
|
Implements the Distutils 'install_data' command, for installing
|
|
|
|
platform-independent data files."""
|
|
|
|
|
|
|
|
# contributed by Bastian Kleineidam
|
|
|
|
|
|
|
|
__revision__ = "$Id$"
|
|
|
|
|
2000-05-25 01:19:18 +00:00
|
|
|
import os
|
|
|
|
from types import StringType
|
|
|
|
from distutils.core import Command
|
2000-05-25 02:14:26 +00:00
|
|
|
from distutils.util import change_root
|
2000-05-12 00:52:23 +00:00
|
|
|
|
2000-05-25 01:19:18 +00:00
|
|
|
class install_data (Command):
|
2000-05-12 00:52:23 +00:00
|
|
|
|
|
|
|
description = "install data files"
|
|
|
|
|
2000-05-25 01:19:18 +00:00
|
|
|
user_options = [
|
|
|
|
('install-dir=', 'd',
|
2000-07-27 02:13:20 +00:00
|
|
|
"base directory for installing data files "
|
2000-06-24 17:36:24 +00:00
|
|
|
"(default: installation base dir)"),
|
2000-05-25 01:19:18 +00:00
|
|
|
('root=', None,
|
|
|
|
"install everything relative to this alternate root directory"),
|
2000-09-13 01:02:25 +00:00
|
|
|
('force', 'f', "force installation (overwrite existing files)"),
|
2000-05-25 01:19:18 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def initialize_options (self):
|
|
|
|
self.install_dir = None
|
2000-06-21 03:13:51 +00:00
|
|
|
self.outfiles = []
|
2000-05-25 01:19:18 +00:00
|
|
|
self.root = None
|
2000-09-13 01:02:25 +00:00
|
|
|
self.force = 0
|
2000-05-25 01:19:18 +00:00
|
|
|
self.data_files = self.distribution.data_files
|
|
|
|
|
2000-05-12 00:52:23 +00:00
|
|
|
def finalize_options (self):
|
2000-05-25 01:19:18 +00:00
|
|
|
self.set_undefined_options('install',
|
|
|
|
('install_data', 'install_dir'),
|
|
|
|
('root', 'root'),
|
2000-09-13 01:02:25 +00:00
|
|
|
('force', 'force'),
|
2000-05-25 01:19:18 +00:00
|
|
|
)
|
2000-05-12 00:52:23 +00:00
|
|
|
|
|
|
|
def run (self):
|
2000-05-25 01:19:18 +00:00
|
|
|
self.mkpath(self.install_dir)
|
|
|
|
for f in self.data_files:
|
|
|
|
if type(f) == StringType:
|
2000-06-24 17:36:24 +00:00
|
|
|
# it's a simple file, so copy it
|
|
|
|
self.warn("setup script did not provide a directory for "
|
|
|
|
"'%s' -- installing right in '%s'" %
|
|
|
|
(f, self.install_dir))
|
2000-06-21 03:13:51 +00:00
|
|
|
out = self.copy_file(f, self.install_dir)
|
|
|
|
self.outfiles.append(out)
|
2000-05-25 01:19:18 +00:00
|
|
|
else:
|
2000-06-24 17:36:24 +00:00
|
|
|
# it's a tuple with path to install to and a list of files
|
2000-05-25 01:19:18 +00:00
|
|
|
dir = f[0]
|
|
|
|
if not os.path.isabs(dir):
|
|
|
|
dir = os.path.join(self.install_dir, dir)
|
|
|
|
elif self.root:
|
2000-05-25 02:14:26 +00:00
|
|
|
dir = change_root(self.root, dir)
|
2000-05-25 01:19:18 +00:00
|
|
|
self.mkpath(dir)
|
|
|
|
for data in f[1]:
|
2000-06-21 03:13:51 +00:00
|
|
|
out = self.copy_file(data, dir)
|
|
|
|
self.outfiles.append(out)
|
2000-05-13 03:07:53 +00:00
|
|
|
|
|
|
|
def get_inputs (self):
|
2000-05-25 01:19:18 +00:00
|
|
|
return self.data_files or []
|
|
|
|
|
|
|
|
def get_outputs (self):
|
2000-06-21 03:13:51 +00:00
|
|
|
return self.outfiles
|