Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
slapos.buildout
Commits
f16efa06
Commit
f16efa06
authored
Mar 19, 2007
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for a download cache.
parent
06ecdb42
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
168 additions
and
0 deletions
+168
-0
CHANGES.txt
CHANGES.txt
+9
-0
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+23
-0
src/zc/buildout/downloadcache.txt
src/zc/buildout/downloadcache.txt
+136
-0
No files found.
CHANGES.txt
View file @
f16efa06
...
@@ -14,6 +14,15 @@ Change History
...
@@ -14,6 +14,15 @@ Change History
1.0.0b23 (2007-03-??)
1.0.0b23 (2007-03-??)
=====================
=====================
Feature Changes
---------------
- Added support for download caches. A buildout can specify a cache
for distribution downloads. The cache can be shared among buildouts
to reduce network access and to support creating source
distributions for applications allowing install without network
access.
Bugs Fixed
Bugs Fixed
----------
----------
...
...
src/zc/buildout/buildout.py
View file @
f16efa06
...
@@ -149,6 +149,29 @@ class Buildout(UserDict.DictMixin):
...
@@ -149,6 +149,29 @@ class Buildout(UserDict.DictMixin):
if
versions
:
if
versions
:
zc
.
buildout
.
easy_install
.
default_versions
(
dict
(
self
[
versions
]))
zc
.
buildout
.
easy_install
.
default_versions
(
dict
(
self
[
versions
]))
download_cache
=
options
.
get
(
'download-cache'
)
if
download_cache
:
download_cache
=
os
.
path
.
join
(
options
[
'directory'
],
download_cache
)
if
not
os
.
path
.
isdir
(
download_cache
):
raise
zc
.
buildout
.
UserError
(
'The specified download cache:
\
n
'
'%r
\
n
'
"Doesn't exist.
\
n
"
%
download_cache
)
download_cache
=
os
.
path
.
join
(
download_cache
,
'dist'
)
if
not
os
.
path
.
isdir
(
download_cache
):
os
.
mkdir
(
download_cache
)
zc
.
buildout
.
easy_install
.
download_cache
(
download_cache
)
install_from_cache
=
options
.
get
(
'install-from-cache'
)
if
install_from_cache
:
if
install_from_cache
not
in
(
'true'
,
'false'
):
self
.
_error
(
'Invalid value for install-from-cache option: %s'
,
install_from_cache
)
if
install_from_cache
==
'true'
:
zc
.
buildout
.
easy_install
.
install_from_cache
(
True
)
# "Use" each of the defaults so they aren't reported as unused options.
# "Use" each of the defaults so they aren't reported as unused options.
for
name
in
_buildout_default_options
:
for
name
in
_buildout_default_options
:
options
[
name
]
options
[
name
]
...
...
src/zc/buildout/downloadcache.txt
0 → 100644
View file @
f16efa06
Using a download cache
======================
Normally, when distributions are installed, if any processing is
needed, they are downloaded from the internet to a temporary directory
and then installed from there. A download cache can be used to avoid
the download step. This can be useful to reduce network access and to
create source distributions of an entire buildout.
The buildout download-cache option can be used to specify a directory
to be used as a download cache.
In this example, we'll create a directory to hold the cache:
>>> cache = tmpdir('cache')
And set up a buildout that downloads some eggs:
>>> write('buildout.cfg',
... '''
... [buildout]
... parts = eggs
... download-cache = %(cache)s
... find-links = %(link_server)s
...
... [eggs]
... recipe = zc.recipe.egg
... eggs = demo ==0.2
... ''' % globals())
We specified a link server that has some distributions available for
download:
>>> print get(link_server),
<html><body>
<a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
<a href="demo-0.2-py2.4.egg">demo-0.2-py2.4.egg</a><br>
<a href="demo-0.3-py2.4.egg">demo-0.3-py2.4.egg</a><br>
<a href="demoneeded-1.0.zip">demoneeded-1.0.zip</a><br>
<a href="demoneeded-1.1.zip">demoneeded-1.1.zip</a><br>
<a href="extdemo-1.4.zip">extdemo-1.4.zip</a><br>
<a href="index/">index/</a><br>
<a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br>
</body></html>
We'll enable logging on the link server so we can see what's going on:
>>> get(link_server+'enable_server_logging')
GET 200 /enable_server_logging
''
We also specified a download cache.
If we run the buildout, we'll see the eggs installed from the link
server as usual:
>>> print system(buildout),
GET 200 /
GET 200 /demo-0.2-py2.4.egg
GET 200 /demoneeded-1.1.zip
buildout: Installing eggs
zc.buildout.easy_install: Getting new distribution for demo==0.2
zc.buildout.easy_install: Got demo 0.2
zc.buildout.easy_install: Getting new distribution for demoneeded
zc.buildout.easy_install: Got demoneeded 1.1
We'll also get the download cache populated. The buildout doesn't put
files in the cache directly. It creates an intermediate directory,
dist:
>>> ls(cache)
d dist
>>> ls(cache, 'dist')
- demo-0.2-py2.4.egg
- demoneeded-1.1.zip
If we remove the installed eggs from eggs directory and re-run the buildout:
>>> import os
>>> for f in os.listdir('eggs'):
... if f.startswith('demo'):
... remove('eggs', f)
>>> print system(buildout),
GET 200 /
buildout: Updating eggs
zc.buildout.easy_install: Getting new distribution for demo==0.2
zc.buildout.easy_install: Got demo 0.2
zc.buildout.easy_install: Getting new distribution for demoneeded
zc.buildout.easy_install: Got demoneeded 1.1
We see that the distributions aren't downloaded, because they're
downloaded from the cache.
Installing solely from a download cache
---------------------------------------
A download cache can be used as the basis of application source
releases. In an application source release, we want to distribute an
application that can be built without making any network accesses. In
this case, we distribute a buildout with download cache and tell the
buildout to install from the download cache only, without making
network accesses. The buildout install-from-cache option can be used
to signal that packages should be installed only from the download
cache.
Let's remove our installed eggs and run the buildout with the
install-from-cache option set to true:
>>> for f in os.listdir('eggs'):
... if f.startswith('demo'):
... remove('eggs', f)
>>> write('buildout.cfg',
... '''
... [buildout]
... parts = eggs
... download-cache = %(cache)s
... install-from-cache = true
... find-links = %(link_server)s
...
... [eggs]
... recipe = zc.recipe.egg
... eggs = demo
... ''' % globals())
>>> print system(buildout),
buildout: Uninstalling eggs
buildout: Installing eggs
zc.buildout.easy_install: Getting new distribution for demo
zc.buildout.easy_install: Got demo 0.2
zc.buildout.easy_install: Getting new distribution for demoneeded
zc.buildout.easy_install: Got demoneeded 1.1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment