source: TI12-security/trunk/NDGSecurity/python/buildout/ndgsecurity/eggs/zc.buildout-1.2.1-py2.5.egg/zc/buildout/downloadcache.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/downloadcache.txt@7081
Revision 7081, 4.3 KB checked in by pjkersha, 11 years ago (diff)
  • Property svn:keywords set to Id
Line 
1Using a download cache
2======================
3
4Normally, when distributions are installed, if any processing is
5needed, they are downloaded from the internet to a temporary directory
6and then installed from there.  A download cache can be used to avoid
7the download step.  This can be useful to reduce network access and to
8create source distributions of an entire buildout.
9
10The buildout download-cache option can be used to specify a directory
11to be used as a download cache.
12
13In this example, we'll create a directory to hold the cache:
14
15    >>> cache = tmpdir('cache')
16
17And set up a buildout that downloads some eggs:
18
19    >>> write('buildout.cfg',
20    ... '''
21    ... [buildout]
22    ... parts = eggs
23    ... download-cache = %(cache)s
24    ... find-links = %(link_server)s
25    ...
26    ... [eggs]
27    ... recipe = zc.recipe.egg
28    ... eggs = demo ==0.2
29    ... ''' % globals())
30
31We specified a link server that has some distributions available for
32download:
33
34    >>> print get(link_server),
35    <html><body>
36    <a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
37    <a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
38    <a href="demo-0.2-py2.4.egg">demo-0.2-py2.4.egg</a><br>
39    <a href="demo-0.3-py2.4.egg">demo-0.3-py2.4.egg</a><br>
40    <a href="demo-0.4c1-py2.4.egg">demo-0.4c1-py2.4.egg</a><br>
41    <a href="demoneeded-1.0.zip">demoneeded-1.0.zip</a><br>
42    <a href="demoneeded-1.1.zip">demoneeded-1.1.zip</a><br>
43    <a href="demoneeded-1.2c1.zip">demoneeded-1.2c1.zip</a><br>
44    <a href="extdemo-1.4.zip">extdemo-1.4.zip</a><br>
45    <a href="index/">index/</a><br>
46    <a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br>
47    </body></html>
48   
49
50We'll enable logging on the link server so we can see what's going on:
51
52    >>> get(link_server+'enable_server_logging')
53    GET 200 /enable_server_logging
54    ''
55
56We also specified a download cache.
57
58If we run the buildout, we'll see the eggs installed from the link
59server as usual:
60
61    >>> print system(buildout),
62    GET 200 /
63    GET 200 /demo-0.2-py2.4.egg
64    GET 200 /demoneeded-1.2c1.zip
65    Installing eggs.
66    Getting distribution for 'demo==0.2'.
67    Got demo 0.2.
68    Getting distribution for 'demoneeded'.
69    Got demoneeded 1.2c1.
70    Generated script '/sample-buildout/bin/demo'.
71
72We'll also get the download cache populated.  The buildout doesn't put
73files in the cache directly.  It creates an intermediate directory,
74dist:
75
76
77    >>> ls(cache)
78    d  dist
79
80    >>> ls(cache, 'dist')
81    -  demo-0.2-py2.4.egg
82    -  demoneeded-1.2c1.zip
83
84If we remove the installed eggs from eggs directory and re-run the buildout:
85
86    >>> import os
87    >>> for  f in os.listdir('eggs'):
88    ...     if f.startswith('demo'):
89    ...         remove('eggs', f)
90   
91    >>> print system(buildout),
92    GET 200 /
93    Updating eggs.
94    Getting distribution for 'demo==0.2'.
95    Got demo 0.2.
96    Getting distribution for 'demoneeded'.
97    Got demoneeded 1.2c1.
98
99We see that the distributions aren't downloaded, because they're
100downloaded from the cache.
101
102Installing solely from a download cache
103---------------------------------------
104
105A download cache can be used as the basis of application source
106releases.  In an application source release, we want to distribute an
107application that can be built without making any network accesses.  In
108this case, we distribute a buildout with download cache and tell the
109buildout to install from the download cache only, without making
110network accesses.  The buildout install-from-cache option can be used
111to signal that packages should be installed only from the download
112cache.
113
114Let's remove our installed eggs and run the buildout with the
115install-from-cache option set to true:
116
117    >>> for  f in os.listdir('eggs'):
118    ...     if f.startswith('demo'):
119    ...         remove('eggs', f)
120
121    >>> write('buildout.cfg',
122    ... '''
123    ... [buildout]
124    ... parts = eggs
125    ... download-cache = %(cache)s
126    ... install-from-cache = true
127    ... find-links = %(link_server)s
128    ...
129    ... [eggs]
130    ... recipe = zc.recipe.egg
131    ... eggs = demo
132    ... ''' % globals())
133
134    >>> print system(buildout),
135    Uninstalling eggs.
136    Installing eggs.
137    Getting distribution for 'demo'.
138    Got demo 0.2.
139    Getting distribution for 'demoneeded'.
140    Got demoneeded 1.2c1.
141    Generated script '/sample-buildout/bin/demo'.
Note: See TracBrowser for help on using the repository browser.