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
Rafael Monnerat
slapos.buildout
Commits
0a947cab
Commit
0a947cab
authored
Mar 19, 2007
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added an option to install only from a download cache.
parent
5a3fb4b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
3 deletions
+75
-3
src/zc/buildout/easy_install.py
src/zc/buildout/easy_install.py
+20
-3
src/zc/buildout/easy_install.txt
src/zc/buildout/easy_install.txt
+55
-0
No files found.
src/zc/buildout/easy_install.py
View file @
0a947cab
...
...
@@ -104,11 +104,11 @@ _easy_install_cmd = _safe_arg(
'
from
setuptools.command.easy_install
import
main
;
main
()
'
)
class Installer:
_versions = {}
_download_cache = None
_install_from_cache = False
def __init__(self,
dest=None,
...
...
@@ -121,6 +121,14 @@ class Installer:
versions=None,
):
self._dest = dest
if self._install_from_cache:
if not self._download_cache:
raise ValueError("install_from_cache set to true with no"
" download cache")
links = ()
index = '
file
:
//
' + self._download_cache
self._links = links = list(links)
if self._download_cache and (self._download_cache not in links):
links.insert(0, self._download_cache)
...
...
@@ -453,7 +461,9 @@ class Installer:
# XXX Need test for this
for
dist
in
dists
:
if
dist
.
has_metadata
(
'dependency_links.txt'
):
if
(
dist
.
has_metadata
(
'dependency_links.txt'
)
and
not
self
.
_install_from_cache
):
for
link
in
dist
.
get_metadata_lines
(
'dependency_links.txt'
):
link
=
link
.
strip
()
if
link
not
in
self
.
_links
:
...
...
@@ -625,7 +635,6 @@ class Installer:
if
tmp
!=
self
.
_download_cache
:
shutil
.
rmtree
(
tmp
)
def
default_versions
(
versions
=
None
):
old
=
Installer
.
_versions
if
versions
is
not
None
:
...
...
@@ -635,9 +644,17 @@ def default_versions(versions=None):
def
download_cache
(
path
=-
1
):
old
=
Installer
.
_download_cache
if
path
!=
-
1
:
if
path
:
path
=
os
.
path
.
abspath
(
path
)
Installer
.
_download_cache
=
path
return
old
def
install_from_cache
(
setting
=
None
):
old
=
Installer
.
_install_from_cache
if
setting
is
not
None
:
Installer
.
_install_from_cache
=
bool
(
setting
)
return
old
def
install
(
specs
,
dest
,
links
=
(),
index
=
None
,
executable
=
sys
.
executable
,
always_unzip
=
False
,
...
...
src/zc/buildout/easy_install.txt
View file @
0a947cab
...
...
@@ -919,7 +919,62 @@ Now when we install the distributions:
Note that we didn't download the distributions from the link server.
If we remove the restriction on demo, we'll download a newer version
from the link server:
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest,
... links=[link_server], index=link_server+'index/',
... always_unzip=True)
GET 200 /demo-0.3-py2.4.egg
Normally, the download cache is the prefered source of downloads, but
not the only one.
Installing solely from a download cache
A download cache can be used as the basis of application sources
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 download cache and tell the easy_install
module to install from the download cache only, without making network
accesses. The install_from_cache function can be used to signal that
packages should be installed only from the download cache. The
function always returns the previous setting. Calling it with no
arguments returns the current setting without changing it:
>>> zc.buildout.easy_install.install_from_cache()
False
Calling it with a boolean value changes the setting and returns the
previous setting:
>>> zc.buildout.easy_install.install_from_cache(True)
False
Let's remove demo-0.3-py2.4.egg from the cache, clear the index cache,
recreate the destination directory, and reinstall demo:
>>> remove(cache, 'demo-0.3-py2.4.egg')
>>> zc.buildout.easy_install.clear_index_cache()
>>> remove(dest)
>>> dest = tmpdir('sample-install')
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest,
... links=[link_server], index=link_server+'index/',
... always_unzip=True)
>>> ls(dest)
d demo-0.2-py2.4.egg
d demoneeded-1.1-py2.4.egg
This time, we didn't download from or even query the link server.
.. Disable the download cache:
>>> zc.buildout.easy_install.download_cache(None)
'/cache'
>>> zc.buildout.easy_install.install_from_cache(False)
True
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