+++ /dev/null
-"""distutils.command.install_data\r
-\r
-Implements the Distutils 'install_data' command, for installing\r
-platform-independent data files."""\r
-\r
-# contributed by Bastian Kleineidam\r
-\r
-__revision__ = "$Id$"\r
-\r
-import os\r
-from distutils.core import Command\r
-from distutils.util import change_root, convert_path\r
-\r
-class install_data(Command):\r
-\r
- description = "install data files"\r
-\r
- user_options = [\r
- ('install-dir=', 'd',\r
- "base directory for installing data files "\r
- "(default: installation base dir)"),\r
- ('root=', None,\r
- "install everything relative to this alternate root directory"),\r
- ('force', 'f', "force installation (overwrite existing files)"),\r
- ]\r
-\r
- boolean_options = ['force']\r
-\r
- def initialize_options(self):\r
- self.install_dir = None\r
- self.outfiles = []\r
- self.root = None\r
- self.force = 0\r
- self.data_files = self.distribution.data_files\r
- self.warn_dir = 1\r
-\r
- def finalize_options(self):\r
- self.set_undefined_options('install',\r
- ('install_data', 'install_dir'),\r
- ('root', 'root'),\r
- ('force', 'force'),\r
- )\r
-\r
- def run(self):\r
- self.mkpath(self.install_dir)\r
- for f in self.data_files:\r
- if isinstance(f, str):\r
- # it's a simple file, so copy it\r
- f = convert_path(f)\r
- if self.warn_dir:\r
- self.warn("setup script did not provide a directory for "\r
- "'%s' -- installing right in '%s'" %\r
- (f, self.install_dir))\r
- (out, _) = self.copy_file(f, self.install_dir)\r
- self.outfiles.append(out)\r
- else:\r
- # it's a tuple with path to install to and a list of files\r
- dir = convert_path(f[0])\r
- if not os.path.isabs(dir):\r
- dir = os.path.join(self.install_dir, dir)\r
- elif self.root:\r
- dir = change_root(self.root, dir)\r
- self.mkpath(dir)\r
-\r
- if f[1] == []:\r
- # If there are no files listed, the user must be\r
- # trying to create an empty directory, so add the\r
- # directory to the list of output files.\r
- self.outfiles.append(dir)\r
- else:\r
- # Copy files, adding them to the list of output files.\r
- for data in f[1]:\r
- data = convert_path(data)\r
- (out, _) = self.copy_file(data, dir)\r
- self.outfiles.append(out)\r
-\r
- def get_inputs(self):\r
- return self.data_files or []\r
-\r
- def get_outputs(self):\r
- return self.outfiles\r