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) ------------------ 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: