diff options
-rw-r--r-- | CHANGES.txt | 2 | ||||
-rw-r--r-- | distribute_setup.py | 11 | ||||
-rw-r--r-- | pkg_resources.py | 15 | ||||
-rwxr-xr-x | setup.py | 6 | ||||
-rw-r--r-- | tests/test_distribute_setup.py | 12 |
5 files changed, 40 insertions, 6 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 3aed457b..3aceb5ac 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,6 +11,8 @@ CHANGES * use_setuptools now properly respects the requested version * use_setuptools will no longer try to import a distribute egg for the wrong Python version +* Issue 74: no_fake should be True by default. +* Issue 72: avoid a bootstrapping issue with easy_install -U ----- 0.6.6 diff --git a/distribute_setup.py b/distribute_setup.py index db75a3c6..de7b1f6d 100644 --- a/distribute_setup.py +++ b/distribute_setup.py @@ -125,7 +125,7 @@ def _do_download(version, download_base, to_dir, download_delay): def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, - to_dir=os.curdir, download_delay=15, no_fake=False): + to_dir=os.curdir, download_delay=15, no_fake=True): # making sure we use the absolute path to_dir = os.path.abspath(to_dir) was_imported = 'pkg_resources' in sys.modules or \ @@ -135,7 +135,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, import pkg_resources if not hasattr(pkg_resources, '_distribute'): if not no_fake: - fake_setuptools() + _fake_setuptools() raise ImportError except ImportError: return _do_download(version, download_base, to_dir, download_delay) @@ -160,7 +160,8 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, return _do_download(version, download_base, to_dir, download_delay) finally: - _create_fake_setuptools_pkg_info(to_dir) + if not no_fake: + _create_fake_setuptools_pkg_info(to_dir) def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15): @@ -320,7 +321,7 @@ def _patch_egg_dir(path): def _before_install(): log.warn('Before install bootstrap.') - fake_setuptools() + _fake_setuptools() def _under_prefix(location): @@ -341,7 +342,7 @@ def _under_prefix(location): return True -def fake_setuptools(): +def _fake_setuptools(): log.warn('Scanning installed packages') try: import pkg_resources diff --git a/pkg_resources.py b/pkg_resources.py index 49c26620..31d83554 100644 --- a/pkg_resources.py +++ b/pkg_resources.py @@ -21,7 +21,14 @@ except NameError: from sets import ImmutableSet as frozenset # capture these to bypass sandboxing -from os import utime, rename, unlink, mkdir +from os import utime +try: + from os import mkdir, rename, unlink + WRITE_SUPPORT = True +except ImportError: + # no write support, probably under GAE + WRITE_SUPPORT = False + from os import open as os_open from os.path import isdir, split @@ -36,6 +43,8 @@ _distribute = True def _bypass_ensure_directory(name, mode=0777): # Sandbox-bypassing version of ensure_directory() + if not WRITE_SUPPORT: + raise IOError('"os.mkdir" not supported on this platform.') dirname, filename = split(name) if dirname and filename and not isdir(dirname): _bypass_ensure_directory(dirname) @@ -1332,6 +1341,10 @@ class ZipProvider(EggProvider): timestamp = time.mktime(date_time) try: + if not WRITE_SUPPORT: + raise IOError('"os.rename" and "os.unlink" are not supported ' + 'on this platform') + real_path = manager.get_cache_path( self.egg_name, self._parts(zip_path) ) @@ -67,6 +67,12 @@ class build_py(_build_py): self.copy_file(srcfile, exe_target) srcfile = os.path.abspath(srcfile) + + # avoid a bootstrapping issue with easy_install -U (when the + # previous version doesn't have convert_2to3_doctests) + if not hasattr(self.distribution, 'convert_2to3_doctests'): + return + if copied and srcfile in self.distribution.convert_2to3_doctests: self.__doctests_2to3.append(outf) diff --git a/tests/test_distribute_setup.py b/tests/test_distribute_setup.py index 4c9079a7..4151587f 100644 --- a/tests/test_distribute_setup.py +++ b/tests/test_distribute_setup.py @@ -57,5 +57,17 @@ class TestSetup(unittest.TestCase): distribute_setup.python_cmd = _faked _install(self.tarball) + def test_use_setuptools(self): + self.assertEquals(use_setuptools(), None) + + # make sure fake_setuptools is not called by default + import pkg_resources + del pkg_resources._distribute + def fake_setuptools(*args): + raise AssertionError + + pkg_resources._fake_setuptools = fake_setuptools + use_setuptools() + if __name__ == '__main__': unittest.main() |