[Checkins] SVN: zc.buildout/branches/prefer-final/ r96852@Avalon:
jim | 2007-07-09 07:36:59 -0400
Jim Fulton
jim at zope.com
Tue Jul 10 07:25:11 EDT 2007
Log message for revision 77674:
r96852 at Avalon: jim | 2007-07-09 07:36:59 -0400
Added additional tests and fixed bugs found in handling final
preference.
Changed:
_U zc.buildout/branches/prefer-final/
U zc.buildout/branches/prefer-final/src/zc/buildout/easy_install.py
U zc.buildout/branches/prefer-final/src/zc/buildout/tests.py
-=-
Property changes on: zc.buildout/branches/prefer-final
___________________________________________________________________
Name: svk:merge
- 62d5b8a3-27da-0310-9561-8e5933582275:/zc.buildout/trunk:77455
c0866d8a-16ff-402e-90a7-1844f7e98520:/prefer-final:96851
+ 62d5b8a3-27da-0310-9561-8e5933582275:/zc.buildout/trunk:77455
c0866d8a-16ff-402e-90a7-1844f7e98520:/prefer-final:96852
Modified: zc.buildout/branches/prefer-final/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/branches/prefer-final/src/zc/buildout/easy_install.py 2007-07-10 11:25:08 UTC (rev 77673)
+++ zc.buildout/branches/prefer-final/src/zc/buildout/easy_install.py 2007-07-10 11:25:10 UTC (rev 77674)
@@ -217,24 +217,38 @@
'Using our best, %s.',
str(req), best_available)
return best_we_have, None
+
+ if self._prefer_final:
+ if _final_version(best_available.parsed_version):
+ if _final_version(best_we_have.parsed_version):
+ if (best_we_have.parsed_version
+ <
+ best_available.parsed_version
+ ):
+ return None, best_available
+ else:
+ return None, best_available
+ else:
+ if (not _final_version(best_we_have.parsed_version)
+ and
+ (best_we_have.parsed_version
+ <
+ best_available.parsed_version
+ )
+ ):
+ return None, best_available
else:
- # Let's find out if we already have the best available:
- if ((best_we_have.parsed_version >= best_available.parsed_version)
- or
- (self._prefer_final
- and
- _final_version(best_we_have.parsed_version)
- and not _final_version(best_available.parsed_version)
- )
+ if (best_we_have.parsed_version
+ <
+ best_available.parsed_version
):
- # Yup. Use it.
- logger.debug(
- 'We have the best distribution that satisfies %r.',
- str(req))
- return best_we_have, None
+ return None, best_available
+
+ logger.debug(
+ 'We have the best distribution that satisfies %r.',
+ str(req))
+ return best_we_have, None
- return None, best_available
-
def _load_dist(self, dist):
dists = pkg_resources.Environment(
dist.location,
Modified: zc.buildout/branches/prefer-final/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/branches/prefer-final/src/zc/buildout/tests.py 2007-07-10 11:25:08 UTC (rev 77673)
+++ zc.buildout/branches/prefer-final/src/zc/buildout/tests.py 2007-07-10 11:25:10 UTC (rev 77674)
@@ -558,23 +558,6 @@
"""
-# Why?
-## def error_for_undefined_install_parts():
-## """
-## Any parts we pass to install on the command line must be
-## listed in the configuration.
-
-## >>> print system(join('bin', 'buildout') + ' install foo'),
-## Invalid install parts: foo.
-## Install parts must be listed in the configuration.
-
-## >>> print system(join('bin', 'buildout') + ' install foo bar'),
-## Invalid install parts: foo bar.
-## Install parts must be listed in the configuration.
-
-## """
-
-
bootstrap_py = os.path.join(
os.path.dirname(
os.path.dirname(
@@ -2073,23 +2056,148 @@
"""
+
+def create_egg(name, version, dest):
+ d = tempfile.mkdtemp()
+ if dest=='available':
+ extras = dict(x=['x'])
+ else:
+ extras = {}
+
+ try:
+ open(os.path.join(d, 'setup.py'), 'w').write(
+ 'from setuptools import setup\n'
+ 'setup(name=%r, version=%r, extras_require=%r, zip_safe=True,\n'
+ ' py_modules=["setup"]\n)'
+ % (name, str(version), extras)
+ )
+ zc.buildout.testing.bdist_egg(d, sys.executable, os.path.abspath(dest))
+ finally:
+ shutil.rmtree(d)
+
+def prefer_final_permutation(existing, available):
+ for d in ('existing', 'available'):
+ if os.path.exists(d):
+ shutil.rmtree(d)
+ os.mkdir(d)
+ for version in existing:
+ create_egg('spam', version, 'existing')
+ for version in available:
+ create_egg('spam', version, 'available')
+
+ zc.buildout.easy_install.clear_index_cache()
+ [dist] = list(
+ zc.buildout.easy_install.install(['spam'], 'existing', ['available'],
+ always_unzip=True)
+ )
+
+ if dist.extras:
+ print 'downloaded', dist.version
+ else:
+ print 'had', dist.version
+ sys.path_importer_cache.clear()
+
+def prefer_final():
+ """
+This test tests several permutations:
+
+Using different version numbers to work around zip impporter cache problems. :(
+
+- With prefer final:
+
+ - no existing and newer dev available
+ >>> prefer_final_permutation((), [1, '2a1'])
+ downloaded 1
+
+ - no existing and only dev available
+ >>> prefer_final_permutation((), ['3a1'])
+ downloaded 3a1
+
+ - final existing and only dev acailable
+ >>> prefer_final_permutation([4], ['5a1'])
+ had 4
+
+ - final existing and newer final available
+ >>> prefer_final_permutation([6], [7])
+ downloaded 7
+
+ - final existing and same final available
+ >>> prefer_final_permutation([8], [8])
+ had 8
+
+ - final existing and older final available
+ >>> prefer_final_permutation([10], [9])
+ had 10
+
+ - only dev existing and final available
+ >>> prefer_final_permutation(['12a1'], [11])
+ downloaded 11
+
+ - only dev existing and no final available newer dev available
+ >>> prefer_final_permutation(['13a1'], ['13a2'])
+ downloaded 13a2
+
+ - only dev existing and no final available older dev available
+ >>> prefer_final_permutation(['15a1'], ['14a1'])
+ had 15a1
+
+ - only dev existing and no final available same dev available
+ >>> prefer_final_permutation(['16a1'], ['16a1'])
+ had 16a1
+
+- Without prefer final:
+
+ >>> _ = zc.buildout.easy_install.prefer_final(False)
+
+ - no existing and newer dev available
+ >>> prefer_final_permutation((), [18, '19a1'])
+ downloaded 19a1
+
+ - no existing and only dev available
+ >>> prefer_final_permutation((), ['20a1'])
+ downloaded 20a1
+
+ - final existing and only dev acailable
+ >>> prefer_final_permutation([21], ['22a1'])
+ downloaded 22a1
+
+ - final existing and newer final available
+ >>> prefer_final_permutation([23], [24])
+ downloaded 24
+
+ - final existing and same final available
+ >>> prefer_final_permutation([25], [25])
+ had 25
+
+ - final existing and older final available
+ >>> prefer_final_permutation([27], [26])
+ had 27
+
+ - only dev existing and final available
+ >>> prefer_final_permutation(['29a1'], [28])
+ had 29a1
+
+ - only dev existing and no final available newer dev available
+ >>> prefer_final_permutation(['30a1'], ['30a2'])
+ downloaded 30a2
+
+ - only dev existing and no final available older dev available
+ >>> prefer_final_permutation(['32a1'], ['31a1'])
+ had 32a1
+
+ - only dev existing and no final available same dev available
+ >>> prefer_final_permutation(['33a1'], ['33a1'])
+ had 33a1
+
+ >>> _ = zc.buildout.easy_install.prefer_final(True)
+
+ """
+
+
# XXX Tests needed:
# Link added from package meta data
-# prefer final:
-# - no existing and newer dev available
-# - no existing and only dev available
-# - final existing and only dev acailable
-# - final existing and newer final available
-# - final existing and same final available
-# - final existing and older final available
-# - only dev existing and final available
-# - only dev existing and no final available newer dev available
-# - only dev existing and no final available older dev available
-# - only dev existing and no final available same dev available
-# Maybe same variations for non-prefer-final case.
-# Looks like a job for something fit like.
######################################################################
More information about the Checkins
mailing list