diff options
author | Monty Taylor <mordred@inaugust.com> | 2013-06-05 08:34:02 -0400 |
---|---|---|
committer | Monty Taylor <mordred@inaugust.com> | 2013-06-05 08:41:37 -0400 |
commit | 20c1071eed26cda6aeda8e78a37bb8c98b0e3b44 (patch) | |
tree | a324a3ca6a83b547fab703a2f86ae9f3c2135e7b | |
parent | eb3ebd540c48a341d828b5fb9e1e8c7a2d8c3f57 (diff) | |
download | pbr-20c1071eed26cda6aeda8e78a37bb8c98b0e3b44.tar.gz |
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
-rw-r--r-- | pbr/packaging.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/pbr/packaging.py b/pbr/packaging.py index 02fd5cd..d7bb250 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) |