diff options
author | PJ Eby <distutils-sig@python.org> | 2005-05-30 06:46:01 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2005-05-30 06:46:01 +0000 |
commit | c3e492cc9aa7c5cb92a9fb0fa8a8188d8a477a5b (patch) | |
tree | 2f8d43bf02b39d0021c682d558c5d7317dbcfed5 /setuptools | |
parent | 3dbc1ee171326dd01058c92878878f83a4d65748 (diff) | |
download | external_python_setuptools-c3e492cc9aa7c5cb92a9fb0fa8a8188d8a477a5b.tar.gz external_python_setuptools-c3e492cc9aa7c5cb92a9fb0fa8a8188d8a477a5b.tar.bz2 external_python_setuptools-c3e492cc9aa7c5cb92a9fb0fa8a8188d8a477a5b.zip |
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.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041028
Diffstat (limited to 'setuptools')
-rw-r--r-- | setuptools/command/bdist_egg.py | 61 |
1 files changed, 51 insertions, 10 deletions
diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 8a2a8619..39042fb8 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -7,7 +7,7 @@ import os 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 @@ class bdist_egg(Command): ])) 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 @@ class bdist_egg(Command): 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 @@ class bdist_egg(Command): 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 @@ class bdist_egg(Command): 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 @@ def make_zipfile (zip_filename, base_dir, verbose=0, dry_run=0): return zip_filename + + + + + + + + + + |