From 20c1071eed26cda6aeda8e78a37bb8c98b0e3b44 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 5 Jun 2013 08:34:02 -0400 Subject: [PATCH] Explicitly install install_requires. PBR uses distutils.install instead of setuptools.install to provide non-egg based installs. This is effectively the same behavior as the --single-version-externally-managed flag to setuptools, which is what distro packagers use inside of debs and rpms. We do this so that we can do things like install manpages and config files. Unfortunately, this has the unintended consequence of completely skipping dependency processing. Add the logic from distribute into our install class to ensure that the contents of install_requires are installed appropriately. In the future, we'll want to replace this method with one that uses pip instead of easy_install. Since we're doing the work now in our code, we might as well do it well. Change-Id: Id5465766f762ab37f121ee3d72a82098654e30db --- pbr/packaging.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/pbr/packaging.py b/pbr/packaging.py index 02fd5cd1..d7bb2506 100644 --- a/pbr/packaging.py +++ b/pbr/packaging.py @@ -29,6 +29,8 @@ import sys from d2to1.extern import six from distutils.command import install as du_install from distutils import log +import pkg_resources +from setuptools.command import easy_install from setuptools.command import install from setuptools.command import sdist @@ -236,7 +238,43 @@ class DistutilsInstall(install.install): command_name = 'install' + def fetch_build_egg(self, req): + """Fetch an egg needed for building.""" + try: + cmd = self._egg_fetcher + cmd.package_index.to_scan = [] + except AttributeError: + dist = self.distribution.__class__( + {'script_args': ['easy_install']}) + dist.parse_config_files() + opts = dist.get_option_dict('easy_install') + keep = ( + 'find_links', 'site_dirs', 'index_url', 'optimize', + 'site_dirs', 'allow_hosts' + ) + for key in opts.keys(): + if key not in keep: + del opts[key] # don't use any other settings + if self.distribution.dependency_links: + links = self.distribution.dependency_links[:] + if 'find_links' in opts: + links = opts['find_links'][1].split() + links + opts['find_links'] = ('setup', links) + cmd = easy_install.easy_install( + dist, args=["x"], + always_copy=False, build_directory=None, editable=False, + upgrade=False, multi_version=True, no_report=True + ) + cmd.ensure_finalized() + self._egg_fetcher = cmd + return cmd.easy_install(req) + def run(self): + for dist in pkg_resources.working_set.resolve( + pkg_resources.parse_requirements( + self.distribution.install_requires), + installer=self.fetch_build_egg): + pkg_resources.working_set.add(dist) return du_install.install.run(self)