c72061d4ee3c244fd1f060f8718b4e697479ddde
"""distutils.command.install_data
Implements the Distutils 'install_data' command, for installing
platform-independent data files."""
# contributed by Bastian Kleineidam
# This module should be kept compatible with Python 2.1.
__revision__
= "$Id: install_data.py,v 1.22 2004/11/10 22:23:15 loewis Exp $"
from types
import StringType
from distutils
.core
import Command
from distutils
.util
import change_root
, convert_path
class install_data (Command
):
description
= "install data files"
"base directory for installing data files "
"(default: installation base dir)"),
"install everything relative to this alternate root directory"),
('force', 'f', "force installation (overwrite existing files)"),
boolean_options
= ['force']
def initialize_options (self
):
self
.data_files
= self
.distribution
.data_files
def finalize_options (self
):
self
.set_undefined_options('install',
('install_data', 'install_dir'),
self
.mkpath(self
.install_dir
)
for f
in self
.data_files
:
if type(f
) is StringType
:
# it's a simple file, so copy it
self
.warn("setup script did not provide a directory for "
"'%s' -- installing right in '%s'" %
(out
, _
) = self
.copy_file(f
, self
.install_dir
)
self
.outfiles
.append(out
)
# it's a tuple with path to install to and a list of files
if not os
.path
.isabs(dir):
dir = os
.path
.join(self
.install_dir
, dir)
dir = change_root(self
.root
, dir)
# If there are no files listed, the user must be
# trying to create an empty directory, so add the
# directory to the list of output files.
self
.outfiles
.append(dir)
# Copy files, adding them to the list of output files.
data
= convert_path(data
)
(out
, _
) = self
.copy_file(data
, dir)
self
.outfiles
.append(out
)
return self
.data_files
or []