[Checkins] SVN: zc.buildout/trunk/ Fixed bug:
Jim Fulton
jim at zope.com
Sun Oct 28 12:11:16 EDT 2007
Log message for revision 81175:
Fixed bug:
When using a local find links or index, distributions weren't copied
to the download cache.
Changed:
U zc.buildout/trunk/CHANGES.txt
U zc.buildout/trunk/src/zc/buildout/easy_install.py
U zc.buildout/trunk/src/zc/buildout/tests.py
-=-
Modified: zc.buildout/trunk/CHANGES.txt
===================================================================
--- zc.buildout/trunk/CHANGES.txt 2007-10-28 15:13:19 UTC (rev 81174)
+++ zc.buildout/trunk/CHANGES.txt 2007-10-28 16:11:15 UTC (rev 81175)
@@ -24,6 +24,9 @@
- The setup command raised a stupid exception if run without arguments.
+- When using a local find links or index, distributions weren't copied
+ to the download cache.
+
1.0.0b30 (2007-08-20)
=====================
Modified: zc.buildout/trunk/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/easy_install.py 2007-10-28 15:13:19 UTC (rev 81174)
+++ zc.buildout/trunk/src/zc/buildout/easy_install.py 2007-10-28 16:11:15 UTC (rev 81175)
@@ -400,9 +400,24 @@
best.sort()
return best[-1]
- def _fetch(self, dist, tmp):
- return dist.clone(location=self._index.download(dist.location, tmp))
+ def _fetch(self, dist, tmp, download_cache):
+ if (download_cache
+ and (os.path.dirname(dist.location) == download_cache)
+ ):
+ return dist
+ new_location = self._index.download(dist.location, tmp)
+ if (download_cache
+ and (new_location == dist.location)
+ and os.path.isfile(new_location)
+ ):
+ # setuptools avoids making extra copies, but we want to copy
+ # to the download cache
+ shutil.copy2(new_location, tmp)
+ new_location = os.path.join(tmp, os.path.basename(new_location))
+
+ return dist.clone(location=new_location)
+
def _get_dist(self, requirement, ws, always_unzip):
__doing__ = 'Getting distribution for %r.', str(requirement)
@@ -424,15 +439,11 @@
sys.path_importer_cache.clear()
tmp = self._download_cache
+ if tmp is None:
+ tmp = tempfile.mkdtemp('get_dist')
+
try:
- if tmp:
- if os.path.dirname(avail.location) == tmp:
- dist = avail
- else:
- dist = self._fetch(avail, tmp)
- else:
- tmp = tempfile.mkdtemp('get_dist')
- dist = self._fetch(avail, tmp)
+ dist = self._fetch(avail, tmp, self._download_cache)
if dist is None:
raise zc.buildout.UserError(
@@ -626,15 +637,11 @@
logger.debug('Building %r', spec)
tmp = self._download_cache
+ if tmp is None:
+ tmp = tempfile.mkdtemp('get_dist')
+
try:
- if tmp:
- if os.path.dirname(avail.location) == tmp:
- dist = avail
- else:
- dist = self._fetch(avail, tmp)
- else:
- tmp = tempfile.mkdtemp('get_dist')
- dist = self._fetch(avail, tmp)
+ dist = self._fetch(avail, tmp, self._download_cache)
build_tmp = tempfile.mkdtemp('build')
try:
Modified: zc.buildout/trunk/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/tests.py 2007-10-28 15:13:19 UTC (rev 81174)
+++ zc.buildout/trunk/src/zc/buildout/tests.py 2007-10-28 16:11:15 UTC (rev 81175)
@@ -2056,7 +2056,37 @@
"""
+def distributions_from_local_find_links_make_it_to_download_cache():
+ """
+If we specify a local directory in find links, distors found there
+need to make it to the download cache.
+
+ >>> mkdir('test')
+ >>> write('test', 'setup.py',
+ ... '''
+ ... from setuptools import setup
+ ... setup(name='foo')
+ ... ''')
+
+ >>> print system(buildout+' setup test bdist_egg'), # doctest: +ELLIPSIS
+ Running setup script 'test/setup.py'.
+ ...
+
+
+ >>> mkdir('cache')
+ >>> old_cache = zc.buildout.easy_install.download_cache('cache')
+ >>> list(zc.buildout.easy_install.install(['foo'], 'eggs',
+ ... links=[join('test', 'dist')])) # doctest: +ELLIPSIS
+ [foo 0.0.0 ...
+
+ >>> ls('cache')
+ - foo-0.0.0-py2.4.egg
+
+ >>> _ = zc.buildout.easy_install.download_cache(old_cache)
+
+ """
+
def create_egg(name, version, dest):
d = tempfile.mkdtemp()
if dest=='available':
More information about the Checkins
mailing list