[Python-checkins] python/nondist/sandbox/setuptools/setuptools/command bdist_egg.py, 1.10, 1.11
![](https://secure.gravatar.com/avatar/c51d7515c8d4b2d95ebf14c7e3eb5b62.jpg?s=120&d=mm&r=g)
Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9321/setuptools/command Modified Files: bdist_egg.py Log Message: Reorganize bdist_egg's handling of 'install_data' to better deal with the various kludges legacy packages are using to install data in their package directories. Some use absolute paths in 'distribution.data_files', while others create various subclasses of 'install_data', each with their own way of finding out what directory to use! So 'bdist_egg' now does all its 'install_lib' activity before 'install_data', and pokes the desired build directory into a wide variety of places, so that all of the known kludges so far will work correctly. It also checks for absolute paths in 'data_files' (carefully working around other packages' 'data_files' kludges!) and converts them back to relative ones, if they are subpaths of site-packages. Clearly, we need to get the word out about 'package_files' in Python 2.4 and above, and suggest using 'setuptools' for Python 2.3. Index: bdist_egg.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/bdist_egg.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- bdist_egg.py 29 May 2005 22:05:39 -0000 1.10 +++ bdist_egg.py 30 May 2005 06:46:01 -0000 1.11 @@ -7,7 +7,7 @@ from distutils.core import Command from distutils.util import get_platform from distutils.dir_util import create_tree, remove_tree, ensure_relative,mkpath -from distutils.sysconfig import get_python_version +from distutils.sysconfig import get_python_version, get_python_lib from distutils.errors import * from distutils import log from pkg_resources import parse_requirements, get_platform @@ -95,19 +95,39 @@ ])) f.close() + def do_install_data(self): + self.get_finalized_command('install').install_lib = self.bdist_dir + site_packages = os.path.normcase(os.path.realpath(get_python_lib())) + old, self.distribution.data_files = self.distribution.data_files,[] + for item in old: + if isinstance(item,tuple) and len(item)==2: + if os.path.isabs(item[0]): + realpath = os.path.realpath(item[0]) + normalized = os.path.normcase(realpath) + if normalized==site_packages or normalized.startswith( + site_packages+os.sep + ): + item = realpath[len(site_packages)+1:], item[1] + # XXX else: raise ??? + self.distribution.data_files.append(item) + try: + install = self.reinitialize_command('install_data') + # kludge for setups that use a 3-tuple inst_data + install.install_dir = install.install_base = \ + install.install_data = install.install_lib = self.bdist_dir + install.force = 0; install.root = None + log.info("installing package data to %s" % self.bdist_dir) + self.run_command('install_data') + finally: + self.distribution.data_files = old def run(self): + if not self.skip_build: self.run_command('build') - if self.distribution.data_files: - install = self.reinitialize_command('install_data') - install.install_dir = self.bdist_dir - install.force = 0 - install.root = None - log.info("installing package data to %s" % self.bdist_dir) - self.run_command('install_data') - + # We run install_lib before install_data, because some data hacks + # pull their data path from the install_lib command. install = self.reinitialize_command('install_lib', reinit_subcommands=1) install.install_dir = self.bdist_dir install.skip_build = self.skip_build @@ -120,7 +140,6 @@ log.info("installing library code to %s" % self.bdist_dir) self.run_command('install_lib') - to_compile = [] for ext_name in ext_outputs: filename,ext = os.path.splitext(ext_name) @@ -133,6 +152,9 @@ if to_compile: install.byte_compile(to_compile) + if self.distribution.data_files: + self.do_install_data() + # And make an archive relative to the root of the # pseudo-installation tree. archive_basename = "%s-%s-py%s" % ( self.egg_name.replace('-','_'), @@ -213,6 +235,15 @@ return match.group(1) + + + + + + + + + def make_zipfile (zip_filename, base_dir, verbose=0, dry_run=0): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_dir' + ".zip". Uses either the "zipfile" @@ -244,3 +275,13 @@ return zip_filename + + + + + + + + + +
participants (1)
-
pje@users.sourceforge.net