+++ /dev/null
-"""distutils.command.install_egg_info\r
-\r
-Implements the Distutils 'install_egg_info' command, for installing\r
-a package's PKG-INFO metadata."""\r
-\r
-\r
-from distutils.cmd import Command\r
-from distutils import log, dir_util\r
-import os, sys, re\r
-\r
-class install_egg_info(Command):\r
- """Install an .egg-info file for the package"""\r
-\r
- description = "Install package's PKG-INFO metadata as an .egg-info file"\r
- user_options = [\r
- ('install-dir=', 'd', "directory to install to"),\r
- ]\r
-\r
- def initialize_options(self):\r
- self.install_dir = None\r
-\r
- def finalize_options(self):\r
- self.set_undefined_options('install_lib',('install_dir','install_dir'))\r
- basename = "%s-%s-py%s.egg-info" % (\r
- to_filename(safe_name(self.distribution.get_name())),\r
- to_filename(safe_version(self.distribution.get_version())),\r
- sys.version[:3]\r
- )\r
- self.target = os.path.join(self.install_dir, basename)\r
- self.outputs = [self.target]\r
-\r
- def run(self):\r
- target = self.target\r
- if os.path.isdir(target) and not os.path.islink(target):\r
- dir_util.remove_tree(target, dry_run=self.dry_run)\r
- elif os.path.exists(target):\r
- self.execute(os.unlink,(self.target,),"Removing "+target)\r
- elif not os.path.isdir(self.install_dir):\r
- self.execute(os.makedirs, (self.install_dir,),\r
- "Creating "+self.install_dir)\r
- log.info("Writing %s", target)\r
- if not self.dry_run:\r
- f = open(target, 'w')\r
- self.distribution.metadata.write_pkg_file(f)\r
- f.close()\r
-\r
- def get_outputs(self):\r
- return self.outputs\r
-\r
-\r
-# The following routines are taken from setuptools' pkg_resources module and\r
-# can be replaced by importing them from pkg_resources once it is included\r
-# in the stdlib.\r
-\r
-def safe_name(name):\r
- """Convert an arbitrary string to a standard distribution name\r
-\r
- Any runs of non-alphanumeric/. characters are replaced with a single '-'.\r
- """\r
- return re.sub('[^A-Za-z0-9.]+', '-', name)\r
-\r
-\r
-def safe_version(version):\r
- """Convert an arbitrary string to a standard version string\r
-\r
- Spaces become dots, and all other non-alphanumeric characters become\r
- dashes, with runs of multiple dashes condensed to a single dash.\r
- """\r
- version = version.replace(' ','.')\r
- return re.sub('[^A-Za-z0-9.]+', '-', version)\r
-\r
-\r
-def to_filename(name):\r
- """Convert a project or version name to its filename-escaped form\r
-\r
- Any '-' characters are currently replaced with '_'.\r
- """\r
- return name.replace('-','_')\r