source: TI12-security/trunk/NDGSecurity/python/buildout/ndgsecurity/eggs/zc.buildout-1.2.1-py2.5.egg/zc/buildout/update.txt @ 7081

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg-security/TI12-security/trunk/NDGSecurity/python/buildout/ndgsecurity/eggs/zc.buildout-1.2.1-py2.5.egg/zc/buildout/update.txt@7081
Revision 7081, 5.2 KB checked in by pjkersha, 11 years ago (diff)
  • Property svn:keywords set to Id
Line 
1Automatic Buildout Updates
2==========================
3
4When a buildout is run, one of the first steps performed is to check
5for updates to either zc.buildout or setuptools.  To demonstrate this,
6we've creates some "new releases" of buildout and setuptools in a
7new_releases folder:
8
9    >>> ls(new_releases)
10    d  setuptools
11    -  setuptools-99.99-py2.4.egg
12    d  zc.buildout
13    -  zc.buildout-99.99-py2.4.egg
14
15Let's update the sample buildout.cfg to look in this area:
16
17    >>> write(sample_buildout, 'buildout.cfg',
18    ... """
19    ... [buildout]
20    ... find-links = %(new_releases)s
21    ... index = %(new_releases)s
22    ... parts = show-versions
23    ... develop = showversions
24    ...
25    ... [show-versions]
26    ... recipe = showversions
27    ... """ % dict(new_releases=new_releases))
28
29We'll also include a recipe that echos the versions of setuptools and
30zc.buildout used:
31
32    >>> mkdir(sample_buildout, 'showversions')
33
34    >>> write(sample_buildout, 'showversions', 'showversions.py',
35    ... """
36    ... import pkg_resources
37    ...
38    ... class Recipe:
39    ...
40    ...     def __init__(self, buildout, name, options):
41    ...         pass
42    ...
43    ...     def install(self):
44    ...         for project in 'zc.buildout', 'setuptools':
45    ...             req = pkg_resources.Requirement.parse(project)
46    ...             print project, pkg_resources.working_set.find(req).version
47    ...         return ()
48    ...     update = install
49    ... """)
50
51
52    >>> write(sample_buildout, 'showversions', 'setup.py',
53    ... """
54    ... from setuptools import setup
55    ...
56    ... setup(
57    ...     name = "showversions",
58    ...     entry_points = {'zc.buildout': ['default = showversions:Recipe']},
59    ...     )
60    ... """)
61
62
63Now if we run the buildout, the buildout will upgrade itself to the
64new versions found in new releases:
65
66    >>> print system(buildout),
67    Getting distribution for 'zc.buildout'.
68    Got zc.buildout 99.99.
69    Getting distribution for 'setuptools'.
70    Got setuptools 99.99.
71    Upgraded:
72      zc.buildout version 99.99,
73      setuptools version 99.99;
74    restarting.
75    Generated script '/sample-buildout/bin/buildout'.
76    Develop: '/sample-buildout/showversions'
77    Installing show-versions.
78    zc.buildout 99.99
79    setuptools 99.99
80
81Our buildout script has been updated to use the new eggs:
82
83    >>> cat(sample_buildout, 'bin', 'buildout')
84    #!/usr/local/bin/python2.4
85    <BLANKLINE>
86    import sys
87    sys.path[0:0] = [
88      '/sample-buildout/eggs/zc.buildout-99.99-py2.4.egg',
89      '/sample-buildout/eggs/setuptools-99.99-py2.4.egg',
90      ]
91    <BLANKLINE>
92    import zc.buildout.buildout
93    <BLANKLINE>
94    if __name__ == '__main__':
95        zc.buildout.buildout.main()
96
97Now, let's recreate the sample buildout. If we specify constraints on
98the versions of zc.buildout and setuptools to use, running the
99buildout will install earlier versions of these packages:
100
101    >>> write(sample_buildout, 'buildout.cfg',
102    ... """
103    ... [buildout]
104    ... find-links = %(new_releases)s
105    ... index = %(new_releases)s
106    ... parts = show-versions
107    ... develop = showversions
108    ... zc.buildout-version = < 99
109    ... setuptools-version = < 99
110    ...
111    ... [show-versions]
112    ... recipe = showversions
113    ... """ % dict(new_releases=new_releases))
114
115Now we can see that we actually "upgrade" to an earlier version.
116
117    >>> print system(buildout),
118    Upgraded:
119      zc.buildout version 1.0.0,
120      setuptools version 0.6;
121    restarting.
122    Generated script '/sample-buildout/bin/buildout'.
123    Develop: '/sample-buildout/showversions'
124    Updating show-versions.
125    zc.buildout 1.0.0
126    setuptools 0.6
127
128There are a number of cases, described below, in which the updates
129don't happen.
130
131We won't upgrade in offline mode:
132
133    >>> write(sample_buildout, 'buildout.cfg',
134    ... """
135    ... [buildout]
136    ... find-links = %(new_releases)s
137    ... index = %(new_releases)s
138    ... parts = show-versions
139    ... develop = showversions
140    ...
141    ... [show-versions]
142    ... recipe = showversions
143    ... """ % dict(new_releases=new_releases))
144
145    >>> print system(buildout+' -o'),
146    Develop: '/sample-buildout/showversions'
147    Updating show-versions.
148    zc.buildout 1.0.0
149    setuptools 0.6
150
151Or in non-newest mode:
152
153    >>> print system(buildout+' -N'),
154    Develop: '/sample-buildout/showversions'
155    Updating show-versions.
156    zc.buildout 1.0.0
157    setuptools 0.6
158
159We also won't upgrade if the buildout script being run isn't in the
160buildouts bin directory.  To see this we'll create a new buildout
161directory:
162
163    >>> sample_buildout2 = tmpdir('sample_buildout2')
164    >>> write(sample_buildout2, 'buildout.cfg',
165    ... """
166    ... [buildout]
167    ... find-links = %(new_releases)s
168    ... index = %(new_releases)s
169    ... parts =
170    ... """ % dict(new_releases=new_releases))
171   
172    >>> cd(sample_buildout2)
173    >>> print system(buildout),
174    Creating directory '/sample_buildout2/bin'.
175    Creating directory '/sample_buildout2/parts'.
176    Creating directory '/sample_buildout2/eggs'.
177    Creating directory '/sample_buildout2/develop-eggs'.
178    Getting distribution for 'zc.buildout'.
179    Got zc.buildout 99.99.
180    Getting distribution for 'setuptools'.
181    Got setuptools 99.99.
182    Not upgrading because not running a local buildout command.
183
184    >>> ls('bin')
Note: See TracBrowser for help on using the repository browser.