From 2f4cac4296fd0a067506d57fc13719ad364ad16f Mon Sep 17 00:00:00 2001 From: "Erik M. Bray" Date: Thu, 2 Apr 2015 12:26:39 -0400 Subject: [PATCH 1/2] Move cleanup of any existing astropy_helpers in sys.modules to the beginning of the bootstrap process so this is done in all cases. This assumes nested setups are being used, which will restore sys.modules to its previous state when the setup calling this ah_bootstrap is completed. --- ah_bootstrap.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ah_bootstrap.py b/ah_bootstrap.py index e9521ea8..7e145e3d 100644 --- a/ah_bootstrap.py +++ b/ah_bootstrap.py @@ -282,6 +282,19 @@ def run(self): strategies = ['local_directory', 'local_file', 'index'] dist = None + # First, remove any previously imported versions of astropy_helpers; + # this is necessary for nested installs where one package's installer + # is installing another package via setuptools.sandbox.run_setup, as in + # the case of setup_requires + for key in list(sys.modules): + try: + if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'): + del sys.modules[key] + except AttributeError: + # Sometimes mysterious non-string things can turn up in + # sys.modules + continue + # Check to see if the path is a submodule self.is_submodule = self._check_submodule() @@ -311,19 +324,6 @@ def run(self): # Note: Adding the dist to the global working set also activates it # (makes it importable on sys.path) by default. - # But first, remove any previously imported versions of - # astropy_helpers; this is necessary for nested installs where one - # package's installer is installing another package via - # setuptools.sandbox.run_set, as in the case of setup_requires - for key in list(sys.modules): - try: - if key == PACKAGE_NAME or key.startswith(PACKAGE_NAME + '.'): - del sys.modules[key] - except AttributeError: - # Sometimes mysterious non-string things can turn up in - # sys.modules - continue - try: pkg_resources.working_set.add(dist, replace=True) except TypeError: From 90367d023dda73646899d7985aa2a0c8ce4c663d Mon Sep 17 00:00:00 2001 From: "Erik M. Bray" Date: Thu, 2 Apr 2015 16:44:22 -0400 Subject: [PATCH 2/2] Add changelog entry for #147 --- CHANGES.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index d7bcc6bd..ba3e908a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -17,6 +17,10 @@ astropy-helpers Changelog - Various fixes enabling the astropy-helpers Sphinx build command and Sphinx extensions to work with Sphinx 1.3. [#148] +- More improvement to the ability to handle multiple versions of + astropy-helpers being imported in the same Python interpreter session + in the (somewhat rare) case of nested installs. [#147] + 1.0.1 (2015-03-04) ------------------