Commit b3cbe68c authored by Jim Fulton's avatar Jim Fulton

Added support for the buildout newest option.

Also added a missing tests for upgrading.
parent c13d5c58
...@@ -8,6 +8,14 @@ To do ...@@ -8,6 +8,14 @@ To do
Change History Change History
************** **************
1.0.0b5 (2007-02-??)
====================
Feature Changes
---------------
- Added support for the buildout newest option.
1.0.0b4 (2007-01-17) 1.0.0b4 (2007-01-17)
==================== ====================
......
...@@ -7,7 +7,7 @@ def read(*rnames): ...@@ -7,7 +7,7 @@ def read(*rnames):
name = "zc.recipe.egg" name = "zc.recipe.egg"
setup( setup(
name = name, name = name,
version = "1.0.0b4", version = "1.0.0b5",
author = "Jim Fulton", author = "Jim Fulton",
author_email = "jim@zope.com", author_email = "jim@zope.com",
description = "Recipe for installing Python package distributions as eggs", description = "Recipe for installing Python package distributions as eggs",
......
...@@ -64,8 +64,6 @@ specified where to find distributions using the find-links option. ...@@ -64,8 +64,6 @@ specified where to find distributions using the find-links option.
Let's run the buildout: Let's run the buildout:
>>> import os >>> import os
>>> os.chdir(sample_buildout)
>>> buildout = os.path.join(sample_buildout, 'bin', 'buildout')
>>> print system(buildout), >>> print system(buildout),
buildout: Installing demo buildout: Installing demo
zc.buildout.easy_install: Getting new distribution for demo<0.3 zc.buildout.easy_install: Getting new distribution for demo<0.3
...@@ -83,9 +81,9 @@ Now, if we look at the buildout eggs directory: ...@@ -83,9 +81,9 @@ Now, if we look at the buildout eggs directory:
We see that we got an egg for demo that met the requirement, as well We see that we got an egg for demo that met the requirement, as well
as the egg for demoneeded, which demo requires. (We also see an egg as the egg for demoneeded, which demo requires. (We also see an egg
link for the recipe. This egg link was actually created as part of link for the recipe in the develop-eggs directory. This egg link was
the sample buildout setup. Normally, when using the recipe, you'll get actually created as part of the sample buildout setup. Normally, when
a regular egg installation.) using the recipe, you'll get a regular egg installation.)
Script generation Script generation
----------------- -----------------
...@@ -186,7 +184,7 @@ This is useful for debugging and testing. ...@@ -186,7 +184,7 @@ This is useful for debugging and testing.
If we run the demo script, it prints out some minimal data: If we run the demo script, it prints out some minimal data:
>>> print system(os.path.join(sample_buildout, 'bin', 'demo')), >>> print system(join(sample_buildout, 'bin', 'demo')),
2 1 2 1
The value it prints out happens to be some values defined in the The value it prints out happens to be some values defined in the
...@@ -195,7 +193,7 @@ modules installed. ...@@ -195,7 +193,7 @@ modules installed.
We can also run the py-demo script. Here we'll just print out We can also run the py-demo script. Here we'll just print out
the bits if the path added to reflect the eggs: the bits if the path added to reflect the eggs:
>>> print system(os.path.join(sample_buildout, 'bin', 'py-demo'), >>> print system(join(sample_buildout, 'bin', 'py-demo'),
... """import os, sys ... """import os, sys
... for p in sys.path: ... for p in sys.path:
... if 'demo' in p: ... if 'demo' in p:
...@@ -206,8 +204,13 @@ the bits if the path added to reflect the eggs: ...@@ -206,8 +204,13 @@ the bits if the path added to reflect the eggs:
demo-0.2-py2.4.egg demo-0.2-py2.4.egg
demoneeded-1.1-py2.4.egg demoneeded-1.1-py2.4.egg
The recipe gets the most recent distribution that satisfies the Egg updating
specification. For example, We remove the restriction on demo: ------------
The recipe normally gets the most recent distribution that satisfies the
specification. It won't do this is the buildout is either in
non-newest mode or in offline mode. To see how this works, we'll
remove the restriction on demo:
>>> write(sample_buildout, 'buildout.cfg', >>> write(sample_buildout, 'buildout.cfg',
... """ ... """
...@@ -220,9 +223,34 @@ specification. For example, We remove the restriction on demo: ...@@ -220,9 +223,34 @@ specification. For example, We remove the restriction on demo:
... index = %(server)s/index ... index = %(server)s/index
... """ % dict(server=link_server)) ... """ % dict(server=link_server))
>>> print system(buildout), and run the buildout in non-newest mode:
>>> print system(buildout+' -N'),
buildout: Uninstalling demo buildout: Uninstalling demo
buildout: Installing demo buildout: Installing demo
Note that we removed the eggs option, and the eggs defaulted to the
part name. Because we removed the eggs option, the demo was
reinstalled.
We'll also run the buildout in off-line mode:
>>> print system(buildout+' -o'),
buildout: Updating demo
We didn't get an update for demo:
>>> ls(sample_buildout, 'eggs')
- demo-0.2-py2.3.egg
- demoneeded-1.1-py2.3.egg
- setuptools-0.6-py2.3.egg
- zc.buildout-1.0-py2.3.egg
If we run the buildout on the default online and newest modes,
we'll get an update for demo:
>>> print system(buildout),
buildout: Updating demo
zc.buildout.easy_install: Getting new distribution for demo zc.buildout.easy_install: Getting new distribution for demo
zc.buildout.easy_install: Got demo 0.3 zc.buildout.easy_install: Got demo 0.3
...@@ -235,12 +263,9 @@ Then we'll get a new demo egg: ...@@ -235,12 +263,9 @@ Then we'll get a new demo egg:
- setuptools-0.6-py2.4.egg - setuptools-0.6-py2.4.egg
- zc.buildout-1.0-py2.4.egg - zc.buildout-1.0-py2.4.egg
Note that we removed the eggs option, and the eggs
defaulted to the part name.
The script is updated too: The script is updated too:
>>> print system(os.path.join(sample_buildout, 'bin', 'demo')), >>> print system(join(sample_buildout, 'bin', 'demo')),
3 1 3 1
Controlling script generation Controlling script generation
...@@ -442,7 +467,6 @@ Offline mode ...@@ -442,7 +467,6 @@ Offline mode
If the buildout offline option is set to "true", then no attempt will If the buildout offline option is set to "true", then no attempt will
be made to contact an index server: be made to contact an index server:
>>> write(sample_buildout, 'buildout.cfg', >>> write(sample_buildout, 'buildout.cfg',
... """ ... """
... [buildout] ... [buildout]
......
...@@ -61,12 +61,15 @@ class Custom(Base): ...@@ -61,12 +61,15 @@ class Custom(Base):
if buildout['buildout'].get('offline') == 'true': if buildout['buildout'].get('offline') == 'true':
self.install = lambda: () self.install = lambda: ()
self.newest = buildout['buildout'].get('newest') == 'true'
def install(self): def install(self):
options = self.options options = self.options
distribution = options.get('eggs', self.name).strip() distribution = options.get('eggs', self.name).strip()
return zc.buildout.easy_install.build( return zc.buildout.easy_install.build(
distribution, options['_d'], self.build_ext, distribution, options['_d'], self.build_ext,
self.links, self.index, options['executable'], [options['_e']], self.links, self.index, options['executable'], [options['_e']],
newest=self.newest,
) )
class Develop(Base): class Develop(Base):
......
...@@ -132,8 +132,6 @@ the egg: ...@@ -132,8 +132,6 @@ the egg:
... include-dirs = include ... include-dirs = include
... """ % dict(server=link_server)) ... """ % dict(server=link_server))
>>> buildout = join('bin', 'buildout')
>>> print system(buildout), >>> print system(buildout),
buildout: Installing extdemo buildout: Installing extdemo
zip_safe flag not set; analyzing archive contents... zip_safe flag not set; analyzing archive contents...
...@@ -200,6 +198,51 @@ When we run the script, we'll 42 printed: ...@@ -200,6 +198,51 @@ When we run the script, we'll 42 printed:
>>> print system(join('bin', 'demo')), >>> print system(join('bin', 'demo')),
42 42
Updating
--------
The custom recipe will normally check for new source distributions
that meet the given specification. This can be suppressed using the
buildout non-newest and offline modes. We'll generate a new source
distribution for extdemo:
>>> update_extdemo()
If we run the buildout in non-newest or offline modes:
>>> print system(buildout+' -N'),
buildout: Develop: /sample-buildout/demo
buildout: Updating extdemo
buildout: Updating demo
>>> print system(buildout+' -o'),
buildout: Develop: /sample-buildout/demo
buildout: Updating extdemo
buildout: Updating demo
We won't get an update.
>>> ls(sample_buildout, 'develop-eggs')
- demo.egg-link
d extdemo-1.4-py2.4-unix-i686.egg
- zc.recipe.egg.egg-link
But if we run the buildout in the default on-line and newest modes, we
will:
>>> print system(buildout),
buildout: Develop: /sample-buildout/demo
buildout: Updating extdemo
zip_safe flag not set; analyzing archive contents...
buildout: Updating demo
>>> ls(sample_buildout, 'develop-eggs')
- demo.egg-link
d extdemo-1.4-py2.4-linux-i686.egg
d extdemo-1.5-py2.4-linux-i686.egg
- zc.recipe.egg.egg-link
Controlling develop-egg generation Controlling develop-egg generation
================================== ==================================
......
...@@ -76,7 +76,8 @@ class Eggs(object): ...@@ -76,7 +76,8 @@ class Eggs(object):
index = self.index, index = self.index,
executable = options['executable'], executable = options['executable'],
always_unzip=options.get('unzip') == 'true', always_unzip=options.get('unzip') == 'true',
path=[options['develop-eggs-directory']] path=[options['develop-eggs-directory']],
newest=self.buildout['buildout'].get('newest') == 'true',
) )
return orig_distributions, ws return orig_distributions, ws
......
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