Commit 07f1a31c authored by tarek's avatar tarek

no_fake needs to be True by default fixes #74

--HG--
branch : distribute
extra : rebase_source : 158f5abb9528d7ea6cd436996d5022cb6bcda89e
parent 33e3ec5e
...@@ -6,6 +6,7 @@ CHANGES ...@@ -6,6 +6,7 @@ CHANGES
0.6.7 0.6.7
----- -----
* Issue 74: no_fake should be True by default.
----- -----
0.6.6 0.6.6
......
...@@ -124,7 +124,7 @@ def _do_download(version, download_base, to_dir, download_delay): ...@@ -124,7 +124,7 @@ def _do_download(version, download_base, to_dir, download_delay):
def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, 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 # making sure we use the absolute path
to_dir = os.path.abspath(to_dir) to_dir = os.path.abspath(to_dir)
was_imported = 'pkg_resources' in sys.modules or \ was_imported = 'pkg_resources' in sys.modules or \
...@@ -134,7 +134,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, ...@@ -134,7 +134,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
import pkg_resources import pkg_resources
if not hasattr(pkg_resources, '_distribute'): if not hasattr(pkg_resources, '_distribute'):
if not no_fake: if not no_fake:
fake_setuptools() _fake_setuptools()
raise ImportError raise ImportError
except ImportError: except ImportError:
return _do_download(version, download_base, to_dir, download_delay) return _do_download(version, download_base, to_dir, download_delay)
...@@ -159,7 +159,8 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, ...@@ -159,7 +159,8 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
return _do_download(version, download_base, to_dir, return _do_download(version, download_base, to_dir,
download_delay) download_delay)
finally: 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, def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=os.curdir, delay=15): to_dir=os.curdir, delay=15):
...@@ -319,7 +320,7 @@ def _patch_egg_dir(path): ...@@ -319,7 +320,7 @@ def _patch_egg_dir(path):
def _before_install(): def _before_install():
log.warn('Before install bootstrap.') log.warn('Before install bootstrap.')
fake_setuptools() _fake_setuptools()
def _under_prefix(location): def _under_prefix(location):
...@@ -340,7 +341,7 @@ def _under_prefix(location): ...@@ -340,7 +341,7 @@ def _under_prefix(location):
return True return True
def fake_setuptools(): def _fake_setuptools():
log.warn('Scanning installed packages') log.warn('Scanning installed packages')
try: try:
import pkg_resources import pkg_resources
......
...@@ -57,5 +57,17 @@ class TestSetup(unittest.TestCase): ...@@ -57,5 +57,17 @@ class TestSetup(unittest.TestCase):
distribute_setup.python_cmd = _faked distribute_setup.python_cmd = _faked
_install(self.tarball) _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__': if __name__ == '__main__':
unittest.main() unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment