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
Yusei Tahara
slapos.buildout
Commits
6f6b3ad4
Commit
6f6b3ad4
authored
Jun 29, 2006
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added an API for use by similar recipes.
Added support for offline mode. Used new API for test server management
parent
94378e23
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
181 additions
and
27 deletions
+181
-27
zc.recipe.egg_/src/zc/recipe/egg/README.txt
zc.recipe.egg_/src/zc/recipe/egg/README.txt
+28
-0
zc.recipe.egg_/src/zc/recipe/egg/api.txt
zc.recipe.egg_/src/zc/recipe/egg/api.txt
+106
-0
zc.recipe.egg_/src/zc/recipe/egg/egg.py
zc.recipe.egg_/src/zc/recipe/egg/egg.py
+20
-12
zc.recipe.egg_/src/zc/recipe/egg/tests.py
zc.recipe.egg_/src/zc/recipe/egg/tests.py
+27
-15
No files found.
zc.recipe.egg_/src/zc/recipe/egg/README.txt
View file @
6f6b3ad4
...
...
@@ -35,6 +35,14 @@ unzip
only effective when an egg is installed. If a zipped egg already
exists in the eggs directory, it will not be unzipped.
scripts
Control which scripts are generated. The value should be a list of
zero or more tokens. Each tokem is either a name, or a name,
followed by an '=' and a new name. Only the named scripts are
generated. If no tokens are given, then script generation is
disabled. If the option isn't given at all, then all scripts
defined by the named eggs will be generated.
We have a link server that has a number of eggs:
...
...
@@ -199,3 +207,23 @@ You can also control the name used for scripts:
- buildout
- foo
Offline mode
------------
If the buildout offline option is set to "true", then no attempt will
be made to contact an index server:
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... parts = demo
... offline = true
...
... [demo]
... recipe = zc.recipe.egg
... index = eek!
... scripts = demo=foo
... """ % dict(server=link_server))
>>> print system(buildout),
zc.recipe.egg_/src/zc/recipe/egg/api.txt
0 → 100644
View file @
6f6b3ad4
Egg Recipe API for other Recipes
================================
It is common for recipes to accept a collection of egg specifications
and generate scripts based on the resulting working sets. The egg
recipe provides an API that other recipes can use.
A recipe can reuse the egg recipe, supporting the eggs, find-links,
index, python, and unzip options. This is done by creating an egg
recipe instance in a recipes's contructor. In the recipe's install
script, the egg-recipe instance's working_set method to collect the
requested eggs and working set.
To illustrate, we create a sample recipe that is a very thin layer
around the egg recipe:
>>> mkdir(sample_buildout, 'sample')
>>> write(sample_buildout, 'sample', 'sample.py',
... """
... import logging, os
... import zc.recipe.egg
...
... class Sample:
...
... def __init__(self, buildout, name, options):
... self.egg = zc.recipe.egg.Egg(buildout, name, options)
... self.name = name
... self.options = options
...
... def install(self):
... extras = self.options['extras'].split()
... requirements, ws = self.egg.working_set(extras)
... print 'Part:', self.name
... print 'Egg requirements:'
... for r in requirements:
... print r
... print 'Working set:'
... for d in ws:
... print d
... """)
Here we instantiated the egg recipe in the constructor, saving it in
an attribute. This also initialized the options dictionary.
In our install method, we called the working_set method on the
instance we saved. The working_set method takes an optional sequence
of extra requirements to be included in the working set.
>>> write(sample_buildout, 'sample', 'setup.py',
... """
... from setuptools import setup
...
... setup(
... name = "sample",
... entry_points = {'zc.buildout': ['default = sample:Sample']},
... )
... """)
>>> write(sample_buildout, 'sample', 'README.txt', " ")
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = sample
... parts = sample-part
...
... [sample-part]
... recipe = sample
... eggs = demo<0.3
... find-links = %(server)s
... index = %(server)sindex
... extras = other
... """ % dict(server=link_server))
>>> import os
>>> os.chdir(sample_buildout)
>>> buildout = os.path.join(sample_buildout, 'bin', 'buildout')
>>> print system(buildout),
Part: sample-part
Egg requirements:
demo<0.3
Working set:
demo 0.2
other 1.0
demoneeded 1.1
We can see that the options were augmented with additionl data
computed by the egg recipe by looking at .installed.cfg:
>>> cat(sample_buildout, '.installed.cfg')
[buildout]
parts = sample-part
<BLANKLINE>
[sample-part]
__buildout_installed__ =
__buildout_signature__ = sample-6aWMvV2EJ9Ijq+bR8ugArQ==
_b = /tmp/tmpb7kP9bsample-buildout/bin
_d = /tmp/tmpb7kP9bsample-buildout/develop-eggs
_e = /tmp/tmpb7kP9bsample-buildout/eggs
eggs = demo<0.3
executable = /usr/local/bin/python2.3
extras = other
find-links = http://localhost:27071/
index = http://localhost:27071/index
recipe = sample
zc.recipe.egg_/src/zc/recipe/egg/egg.py
View file @
6f6b3ad4
...
...
@@ -48,7 +48,7 @@ class Egg:
python
=
options
.
get
(
'python'
,
buildout
[
'buildout'
][
'python'
])
options
[
'executable'
]
=
buildout
[
python
][
'executable'
]
def
working_set
(
self
):
def
working_set
(
self
,
extra
=
()
):
"""Separate method to just get the working set
This is intended for reuse by similar recipes.
...
...
@@ -59,17 +59,25 @@ class Egg:
r
.
strip
()
for
r
in
options
.
get
(
'eggs'
,
self
.
name
).
split
(
'
\
n
'
)
if
r
.
strip
()]
ws
=
zc
.
buildout
.
easy_install
.
install
(
distributions
,
options
[
'_e'
],
links
=
self
.
links
,
index
=
self
.
index
,
executable
=
options
[
'executable'
],
always_unzip
=
options
.
get
(
'unzip'
)
==
'true'
,
path
=
[
options
[
'_d'
]]
)
return
distributions
,
ws
orig_distributions
=
distributions
[:]
distributions
.
extend
(
extra
)
if
self
.
buildout
[
'buildout'
].
get
(
'offline'
)
==
'true'
:
ws
=
zc
.
buildout
.
easy_install
.
working_set
(
distributions
,
options
[
'executable'
],
[
options
[
'_d'
],
options
[
'_e'
]]
)
else
:
ws
=
zc
.
buildout
.
easy_install
.
install
(
distributions
,
options
[
'_e'
],
links
=
self
.
links
,
index
=
self
.
index
,
executable
=
options
[
'executable'
],
always_unzip
=
options
.
get
(
'unzip'
)
==
'true'
,
path
=
[
options
[
'_d'
]]
)
return
orig_distributions
,
ws
def
install
(
self
):
distributions
,
ws
=
self
.
working_set
()
...
...
zc.recipe.egg_/src/zc/recipe/egg/tests.py
View file @
6f6b3ad4
...
...
@@ -29,15 +29,8 @@ def setUp(test):
'develop-eggs'
,
'zc.recipe.egg.egg-link'
),
'w'
).
write
(
dirname
(
__file__
,
4
))
zc
.
buildout
.
testing
.
create_sample_eggs
(
test
)
test
.
globs
[
'link_server'
]
=
(
'http://localhost:%s/'
%
zc
.
buildout
.
testing
.
start_server
(
zc
.
buildout
.
testing
.
make_tree
(
test
))
)
zc
.
buildout
.
testing
.
setUpServer
(
test
,
zc
.
buildout
.
testing
.
make_tree
(
test
))
def
tearDown
(
test
):
zc
.
buildout
.
testing
.
buildoutTearDown
(
test
)
zc
.
buildout
.
testing
.
stop_server
(
test
.
globs
[
'link_server'
])
def
setUpPython
(
test
):
zc
.
buildout
.
testing
.
buildoutSetUp
(
test
,
clear_home
=
False
)
...
...
@@ -47,17 +40,14 @@ def setUpPython(test):
'w'
).
write
(
dirname
(
__file__
,
4
))
zc
.
buildout
.
testing
.
multi_python
(
test
)
test
.
globs
[
'link_server'
]
=
(
'http://localhost:%s/'
%
zc
.
buildout
.
testing
.
start_server
(
zc
.
buildout
.
testing
.
make_tree
(
test
))
)
zc
.
buildout
.
testing
.
setUpServer
(
test
,
zc
.
buildout
.
testing
.
make_tree
(
test
))
def
test_suite
():
return
unittest
.
TestSuite
((
#doctest.DocTestSuite(),
doctest
.
DocFileSuite
(
'README.txt'
,
setUp
=
setUp
,
tearDown
=
t
earDown
,
setUp
=
setUp
,
tearDown
=
zc
.
buildout
.
testing
.
buildoutT
earDown
,
checker
=
renormalizing
.
RENormalizing
([
(
re
.
compile
(
'(
\
S+[/%(sep)s]| )
'
'
(
\\
w
+-
)[
^
\
t
\
n
%
(
sep
)
s
/
]
+
.
egg
'
...
...
@@ -67,9 +57,31 @@ def test_suite():
(re.compile('
-
py
\
d
[.]
\
d
.
egg
'), '
-
py2
.
4.
egg
'),
])
),
doctest.DocFileSuite(
'
api
.
txt
',
setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
(re.compile('
_b
=
\
S
+
sample
-
buildout
.
bin
'),
'
_b
=
sample
-
buildout
/
bin
'),
(re.compile('
__buildout_signature__
=
\
S
+
'),
'
__buildout_signature__
=
sample
-
6
aWMvV2EJ9Ijq
+
bR8ugArQ
==
'),
(re.compile('
_d
=
\
S
+
sample
-
buildout
.
develop
-
eggs
'),
'
_d
=
sample
-
buildout
/
develop
-
eggs
'),
(re.compile('
_e
=
\
S
+
sample
-
buildout
.
eggs
'),
'
_e
=
sample
-
buildout
/
eggs
'),
(re.compile('
executable
=
\
S
+
python
\
S
+
'),
'
executable
=
python
'),
(re.compile('
index
=
\
S
+
python
\
S
+
'),
'
executable
=
python
'),
(re.compile('
find
-
links
=
http
:
//
localhost
:
\
d
+/
'),
'
find
-
links
=
http
:
//
localhost
:
8080
/
'),
(re.compile('
index
=
http
:
//
localhost
:
\
d
+/
index
'),
'
index
=
http
:
//
localhost
:
8080
/
index
'),
])
),
doctest.DocFileSuite(
'
selecting
-
python
.
txt
',
setUp=setUpPython, tearDown=
t
earDown,
setUp=setUpPython, tearDown=
zc.buildout.testing.buildoutT
earDown,
checker=renormalizing.RENormalizing([
(re.compile('
\
S
+
sample
-
(
\
w
+
)
%
s
(
\
S
+
)
' % os.path.sep),
r'
/
sample
-
\
1
/
\
2
'),
...
...
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