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
Xavier Thompson
slapos.buildout
Commits
d05717a2
Commit
d05717a2
authored
Sep 05, 2016
by
Reinout van Rees
Committed by
GitHub
Sep 05, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #275 from jean/master
Editing while reading
parents
0e4f731c
93d1d037
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
352 additions
and
336 deletions
+352
-336
src/zc/buildout/bootstrap.txt
src/zc/buildout/bootstrap.txt
+15
-15
src/zc/buildout/buildout.txt
src/zc/buildout/buildout.txt
+337
-321
No files found.
src/zc/buildout/bootstrap.txt
View file @
d05717a2
...
...
@@ -47,7 +47,7 @@ Make sure the bootstrap script actually works::
X...
d zc.buildout-...egg
By default it gets the latest version:
By default it gets the latest version:
:
>>> buildout_script = join(sample_buildout, 'bin', 'buildout')
>>> if sys.platform.startswith('win'):
...
...
@@ -59,8 +59,8 @@ By default it gets the latest version:
'/sample/eggs/zc.buildout-22.0.0...egg',
]...
Now trying the `
--buildout-version` option, that let you define a version for
`zc.buildout
`.
Now trying the `
`--buildout-version`` option, that let you define a version
for ``zc.buildout`
`.
Let's try with an unknown version::
...
...
@@ -73,7 +73,7 @@ Let's try with an unknown version::
No local packages or...download links found for zc.buildout==UNKNOWN
...
Now let's try with `
2.0.0
`, which happens to exist::
Now let's try with `
`2.0.0`
`, which happens to exist::
>>> print_('X'); print_(system(
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
...
...
@@ -81,7 +81,7 @@ Now let's try with `2.0.0`, which happens to exist::
... # doctest: +ELLIPSIS
X...Generated script '/sample/bin/buildout'...X
Let's make sure the generated `
buildout
` script uses it::
Let's make sure the generated `
`buildout`
` script uses it::
>>> print_(open(buildout_script).read()) # doctest: +ELLIPSIS
#...
...
...
@@ -90,10 +90,10 @@ Let's make sure the generated `buildout` script uses it::
'/sample/eggs/zc.buildout-2.0.0...egg',
]...
Now trying the `
--setuptools-version` option, that let you define a version for
`setuptools
`.
Now trying the `
`--setuptools-version`` option, that lets you define a version
for ``setuptools`
`.
Now let's try with `
8.0
`, which happens to exist::
Now let's try with `
`8.0`
`, which happens to exist::
>>> print_('X'); print_(system(
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
...
...
@@ -101,7 +101,7 @@ Now let's try with `8.0`, which happens to exist::
... # doctest: +ELLIPSIS
X...Generated script '/sample/bin/buildout'...X
Let's make sure the generated `
buildout
` script uses it::
Let's make sure the generated `
`buildout`
` script uses it::
>>> print_(open(buildout_script).read()) # doctest: +ELLIPSIS
#...
...
...
@@ -110,7 +110,7 @@ Let's make sure the generated `buildout` script uses it::
'/sample/eggs/zc.buildout-...egg',
]...
Now let's try specifying both `
zc.buildout` and `setuptools
` to versions
Now let's try specifying both `
`zc.buildout`` and ``setuptools`
` to versions
which happens to exist::
>>> print_('X'); print_(system(
...
...
@@ -119,7 +119,7 @@ which happens to exist::
... # doctest: +ELLIPSIS
X...Generated script '/sample/bin/buildout'...X
Let's make sure the generated `
buildout
` script uses it::
Let's make sure the generated `
`buildout`
` script uses it::
>>> print_(open(buildout_script).read()) # doctest: +ELLIPSIS
#...
...
...
@@ -128,8 +128,8 @@ Let's make sure the generated `buildout` script uses it::
'/sample/eggs/zc.buildout-2.0.0...egg',
]...
For a completely offline install we want to avoid downloading
ez_setup.py
,
specify the setuptools version, and to reuse the setuptools zipfile
.
For a completely offline install we want to avoid downloading
``ez_setup.py``
,
specify the setuptools version, and to reuse the setuptools zipfile
::
>>> try:
... from urllib.request import urlopen
...
...
@@ -160,12 +160,12 @@ specify the setuptools version, and to reuse the setuptools zipfile.
'/sample/eggs/zc.buildout-2.0.0...egg',
]...
You can ask
bootstrap.py
for its version. This is really the day the last
You can ask
``bootstrap.py``
for its version. This is really the day the last
change was made. A date leads to less confusion than a version number separate
from buildout's own version number. Similarly, tracking buildout's version
number leads to bootstraps with a new version number but without changes or to
bootstraps with version number from an already-older buildout. So: a date is
best
.
best
::
>>> print_('X'); print_(system(
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
...
...
src/zc/buildout/buildout.txt
View file @
d05717a2
...
...
@@ -14,17 +14,17 @@ This document describes how to define buildouts using buildout
configuration files and recipes. There are three ways to set up the
buildout software and create a buildout instance:
1. Install the
zc.buildout egg with easy_install
and use the buildout
1. Install the
``zc.buildout`` egg with ``easy_install``
and use the buildout
script installed in a Python scripts area.
2. Use the buildout bootstrap script to create a buildout that
includes both the
setuptools and zc.buildout
eggs. This allows you
includes both the
``setuptools`` and ``zc.buildout``
eggs. This allows you
to use the buildout software without modifying a Python install.
The buildout script is installed into your buildout local scripts
area.
3. Use a buildout command from an already installed buildout to
bootstrap a new buildout. (See the section on bootstraping later
bootstrap a new buildout. (See the section on bootstrap
p
ing later
in this document.)
Often, a software project will be managed in a software repository,
...
...
@@ -32,13 +32,13 @@ such as a subversion repository, that includes some software source
directories, buildout configuration files, and a copy of the buildout
bootstrap script. To work on the project, one would check out the
project from the repository and run the bootstrap script which
installs
setuptools and zc.buildout
into the checkout as well as any
installs
``setuptools`` and ``zc.buildout``
into the checkout as well as any
parts defined.
We have a sample buildout that we created using the bootstrap command
of an existing buildout (method 3 above). It has the absolute minimum
information. We have
bin, develop-eggs, eggs and parts directories,
and a configuration file
:
information. We have
``bin``, ``develop-eggs``, ``eggs`` and ``parts``
directories, and a configuration file:
:
>>> ls(sample_buildout)
d bin
...
...
@@ -47,7 +47,7 @@ and a configuration file:
d eggs
d parts
The
bin directory contains scripts.
The
``bin`` directory contains scripts::
>>> ls(sample_buildout, 'bin')
- buildout
...
...
@@ -56,32 +56,32 @@ The bin directory contains scripts.
- setuptools-0.7-py3.3.egg
- zc.buildout.egg-link
The
develop-eggs and parts directories are initially empty
:
The
``develop-eggs`` and ``parts`` directories are initially empty:
:
>>> ls(sample_buildout, 'develop-eggs')
>>> ls(sample_buildout, 'parts')
The
develop-eggs
directory holds egg links for software being
developed in the buildout. We separate
develop-eggs
and other eggs to
The
``develop-eggs``
directory holds egg links for software being
developed in the buildout. We separate
``develop-eggs``
and other eggs to
allow eggs directories to be shared across multiple buildouts. For
example, a common developer technique is to define a common eggs
directory in their home that all non-develop eggs are stored in. This
allows larger buildouts to be set up much more quickly and saves disk
space.
The
parts
directory provides an area where recipes can install
The
``parts``
directory provides an area where recipes can install
part data. For example, if we built a custom Python, we would
install it in the
part
directory. Part data is stored in a
install it in the
``parts``
directory. Part data is stored in a
sub-directory of the parts directory with the same name as the part.
Buildouts are defined using configuration files. These are in the
format defined by the Python
ConfigParser
module, with extensions
format defined by the Python
``ConfigParser``
module, with extensions
that we'll describe later. By default, when a buildout is run, it
looks for the file
buildout.cfg
in the directory where the buildout is
looks for the file
``buildout.cfg``
in the directory where the buildout is
run.
The minimal configuration file has a
buildout
section that defines no
parts:
The minimal configuration file has a
``buildout``
section that defines no
parts:
:
>>> cat(sample_buildout, 'buildout.cfg')
[buildout]
...
...
@@ -107,11 +107,11 @@ developed.
Let's create a recipe as part of the sample project. We'll create a
recipe for creating directories. First, we'll create a recipes source
directory for our local recipes:
directory for our local recipes:
:
>>> mkdir(sample_buildout, 'recipes')
and then we'll create a source file for our
mkdir recipe
:
and then we'll create a source file for our
``mkdir`` recipe:
:
>>> write(sample_buildout, 'recipes', 'mkdir.py',
... """
...
...
@@ -158,15 +158,15 @@ changed if it's options, after adjusting for data read from other
sections, has changed, or if the recipe has changed. Only the options
for the part are considered. If data are read from other sections,
then that information has to be reflected in the parts options. In
the
Mkdir
example, the given path is interpreted relative to the
the
``mkdir``
example, the given path is interpreted relative to the
buildout directory, and data from the buildout directory is read. The
path option is updated to reflect this. If the directory option was
changed in the buildout sections, we would know to update parts
created using the
mkdir
recipe using relative path names.
created using the
``mkdir``
recipe using relative path names.
When buildout is run, it saves configuration data for installed parts
in a file named
".installed.cfg"
. In subsequent runs, it compares
part-configuration data stored in the
.installed.cfg
file and the
in a file named
``.installed.cfg``
. In subsequent runs, it compares
part-configuration data stored in the
``.installed.cfg``
file and the
part-configuration data loaded from the configuration files as
modified by recipe constructors to decide if the configuration of a
part has changed. If the configuration has changed, or if the recipe
...
...
@@ -176,7 +176,7 @@ configure the part needs to be reflected in the part's options. It is
the job of a recipe constructor to make sure that the options include
all relevant data.
Of course, parts are also uninstalled if they are no
-
longer used.
Of course, parts are also uninstalled if they are no
longer used.
The recipe defines a constructor that takes a buildout object, a part
name, and an options dictionary. It saves them in instance attributes.
...
...
@@ -190,13 +190,13 @@ directory.
The install method is responsible for creating the part. In this
case, we need the path of the directory to create. We'll use a path
option from our options dictionary. The install method logs what it's
doing using the Python
logging
call. We return the path that we
doing using the Python
``logging``
call. We return the path that we
installed. If the part is uninstalled or reinstalled, then the path
returned will be removed by the buildout machinery. A recipe install
method is expected to return a string, or an iterable of strings
containing paths to be removed if a part is uninstalled. For most
recipes, this is all of the uninstall support needed. For more complex
uninstallation scenarios use `Uninstall recipes`_.
uninstallation scenarios
,
use `Uninstall recipes`_.
The update method is responsible for updating an already installed
part. An empty method is often provided, as in this example, if parts
...
...
@@ -209,7 +209,7 @@ We need to provide packaging information so that our recipe can be
installed as a develop egg. The minimum information we need to specify
is a name. For recipes, we also need to define the
names of the recipe classes as entry points. Packaging information is
provided via a
setup.py script
:
provided via a
``setup.py`` script:
:
>>> write(sample_buildout, 'recipes', 'setup.py',
... """
...
...
@@ -221,18 +221,18 @@ provided via a setup.py script:
... )
... """)
Our setup script defines an
entry point
. Entry points provide
Our setup script defines an
*entry point*
. Entry points provide
a way for an egg to define the services it provides. Here we've said
that we define a
zc.buildout entry point named mkdir
. Recipe
classes must be exposed as entry points in the
zc.buildout group. w
e
that we define a
``zc.buildout`` entry point named ``mkdir``
. Recipe
classes must be exposed as entry points in the
``zc.buildout`` group. W
e
give entry points names within the group.
We also need a
README.txt
for our recipes to avoid an annoying warning
from
distutils, on which setuptools and zc.buildout are based
:
We also need a
``README.txt``
for our recipes to avoid an annoying warning
from
``distutils`` (which ``setuptools`` and ``zc.buildout`` are based on):
:
>>> write(sample_buildout, 'recipes', 'README.txt', " ")
Now let's update our
buildout.cfg
:
Now let's update our
``buildout.cfg``:
:
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -254,7 +254,7 @@ Any number of paths can be listed. The paths can be relative or
absolute. If relative, they are treated as relative to the buildout
directory. They can be directory or file paths. If a file path is
given, it should point to a Python setup script. If a directory path
is given, it should point to a directory containing a
setup.py
file.
is given, it should point to a directory containing a
``setup.py``
file.
Development eggs are installed before building any parts, as they may
provide locally-defined recipes needed by the parts.
...
...
@@ -262,8 +262,8 @@ provide locally-defined recipes needed by the parts.
parts = data-dir
Here we've named a part to be "built". We can use any name we want
except that
different part names must
be unique and recipes will often
Here we've named a part to be "built". We can use any name we want
,
except that
part names have to
be unique and recipes will often
use the part name to decide what to do.
::
...
...
@@ -279,7 +279,7 @@ the recipe to be used to install the part. In this case, we also
specify the path to be created.
Let's run the buildout. We do so by running the build script in the
buildout:
buildout:
:
>>> import os
>>> os.chdir(sample_buildout)
...
...
@@ -289,7 +289,7 @@ buildout:
Installing data-dir.
data-dir: Creating directory mystuff
We see that the recipe created the directory, as expected:
We see that the recipe created the directory, as expected:
:
>>> ls(sample_buildout)
- .installed.cfg
...
...
@@ -302,7 +302,7 @@ We see that the recipe created the directory, as expected:
d recipes
In addition, .installed.cfg has been created containing information
about the part we installed:
about the part we installed:
:
>>> cat(sample_buildout, '.installed.cfg')
[buildout]
...
...
@@ -320,7 +320,7 @@ In addition, the path option includes the actual destination
directory.
If we change the name of the directory in the configuration file,
we'll see that the directory gets removed and recreated:
we'll see that the directory gets removed and recreated:
:
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -350,7 +350,7 @@ we'll see that the directory gets removed and recreated:
d recipes
If any of the files or directories created by a recipe are removed,
the part will be reinstalled:
the part will be reinstalled:
:
>>> rmdir(sample_buildout, 'mydata')
>>> print_(system(buildout), end='')
...
...
@@ -362,14 +362,14 @@ the part will be reinstalled:
Error reporting
---------------
If a user makes an error
, an error needs to be printed
and work needs
If a user makes an error
the error needs to be reported,
and work needs
to stop. This is accomplished by logging a detailed error message and
then raising a
(or an instance of a subclass of a)
zc.buildout.UserError exception. Raising an error other than a
UserError still displays the error, but labels it as a bug in the
buildout software or recipe. In the sample above, of someone gives a
non-existent directory to create the directory in:
then raising a
``zc.buildout.UserError`` exception (or a subclass of this exception).
Raising an error other than a
``UserError`` still displays the error, but labels it as a bug in the
buildout software or recipe. In the sample above, if someone gives a
non-existent directory to create the directory in::
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -382,7 +382,7 @@ non-existent directory to create the directory in:
... path = /xxx/mydata
... """)
We'll get a user error, not a traceback.
we'll get a user error, not a traceback::
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
...
...
@@ -399,7 +399,7 @@ Recipe Error Handling
If an error occurs during installation, it is up to the recipe to
clean up any system side effects, such as files created. Let's update
the
mkdir recipe to support multiple paths
:
the
``mkdir`` recipe to support multiple paths:
:
>>> write(sample_buildout, 'recipes', 'mkdir.py',
... """
...
...
@@ -440,7 +440,7 @@ the mkdir recipe to support multiple paths:
>>> clean_up_pyc(sample_buildout, 'recipes', 'mkdir.py')
If there is an error creating a path, the install method will exit and
leave previously created paths in place:
leave previously created paths in place:
:
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -467,13 +467,13 @@ leave previously created paths in place:
Traceback (most recent call last):
... exists...
We meant to create a directory
bins, but typed bin. Now foo
was
left behind
.
We meant to create a directory
``bins``, but typed ``bin``. Now ``foo``
was
left behind
::
>>> os.path.exists('foo')
True
If we fix the typo:
If we fix the typo:
:
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -498,11 +498,11 @@ If we fix the typo:
Traceback (most recent call last):
... exists...
Now they fail because
foo exists, because it was left behind.
Now they fail because
``foo`` exists, because it was left behind::
>>> remove('foo')
Let's fix the recipe:
Let's fix the recipe:
:
>>> write(sample_buildout, 'recipes', 'mkdir.py',
... """
...
...
@@ -556,7 +556,7 @@ Let's fix the recipe:
>>> clean_up_pyc(sample_buildout, 'recipes', 'mkdir.py')
And put back the typo:
And put back the typo:
:
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -569,7 +569,7 @@ And put back the typo:
... path = foo bin
... """)
When we rerun the buildout:
When we rerun the buildout:
:
>>> print_(system(buildout)) # doctest: +ELLIPSIS
Develop: '/sample-buildout/recipes'
...
...
@@ -585,7 +585,7 @@ When we rerun the buildout:
Traceback (most recent call last):
... exists...
we get the same error, but we don't get the directory left behind:
we get the same error, but we don't get the directory left behind:
:
>>> os.path.exists('foo')
False
...
...
@@ -593,12 +593,12 @@ we get the same error, but we don't get the directory left behind:
It's critical that recipes clean up partial effects when errors
occur. Because recipes most commonly create files and directories,
buildout provides a helper API for removing created files when an
error occurs. Option objects have a
created
method that can be called
to record files as they are created. If the
install or update
method
error occurs. Option objects have a
``created``
method that can be called
to record files as they are created. If the
``install`` or ``update``
method
returns with an error, then any registered paths are removed
automatically. The method returns the files registered and can be
used to return the files created. Let's use this API to simplify the
recipe:
recipe:
:
>>> write(sample_buildout, 'recipes', 'mkdir.py',
... """
...
...
@@ -640,12 +640,12 @@ recipe:
>>> clean_up_pyc(sample_buildout, 'recipes', 'mkdir.py')
We returned by calling
created
, taking advantage of the fact that it
We returned by calling
``created``
, taking advantage of the fact that it
returns the registered paths. We did this for illustrative purposes.
It would be simpler
just to
return the paths as before.
It would be simpler
to just
return the paths as before.
If we rerun the buildout
,
again, we'll get the error and no
directories will be created:
If we rerun the buildout again, we'll get the error and no
directories will be created:
:
>>> print_(system(buildout)) # doctest: +ELLIPSIS
Develop: '/sample-buildout/recipes'
...
...
@@ -663,7 +663,7 @@ directories will be created:
>>> os.path.exists('foo')
False
Now, we'll fix the typo again and we'll get the directories we expect:
Now, we'll fix the typo again and we'll get the directories we expect:
:
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -691,30 +691,30 @@ Configuration file syntax
-------------------------
A buildout configuration file consists of a sequence of sections. A
section has a
section header followed by 0 or more section options
.
section has a
*section header* followed by 0 or more *section options*
.
(Buildout configuration files may be viewed as a variation on INI
files.)
A section header consists of a section name enclosed in square braces.
A section name consists of one or more non-whitespace characters other
than square braces (
'[', ']'), curly braces ('{', '}'), colons (':'
)
or equal signs (
'='
). Whitespace surrounding section names is ignored.
than square braces (
``[``, ``]``), curly braces (``{``, ``}``), colons (``:``
)
or equal signs (
``=``
). Whitespace surrounding section names is ignored.
A section header can optionally have a condition expression separated
by a colon. See `Conditional sections`_.
Options consist of option names, followed by optional space or tab
characters, an optional plus or minus sign and an equal sign
s
and
characters, an optional plus or minus sign and an equal sign and
values. An option value may be spread over multiple lines as long as
the lines after the first start with a whitespace character. An
option name consists of one or more non-whitespace characters other
than equal signs, square braces (
"[", "]"), curly braces ("{", "}"
),
plus signs or colons (
":"). The option name '<'
is reserved. An
than equal signs, square braces (
``[``, ``]``), curly braces (``{``, ``}``
),
plus signs or colons (
``:``). The option name ``<``
is reserved. An
option's data consists of the characters following the equal sign on
the start line, plus the continuation lines.
Option values have extra whitespace stripped. How this is done
depends on whether the value has non-whitespace character
t
s on the
depends on whether the value has non-whitespace characters on the
first line. If an option value has non-whitespace characters on the
first line, then each line is stripped and blank lines are removed.
For example, in::
...
...
@@ -738,7 +738,7 @@ For example, in::
The value of of ``bar`` is ``'1'`` and the value of ``baz`` is
``'a\nb\nc'``.
If the first line of an option does
n't
contain whitespace, then the
If the first line of an option does
**not**
contain whitespace, then the
value is dedented (with ``textwrap.dedent``), trailing spaces in lines
are removed, and leading and trailing blank lines are removed. For
example, in::
...
...
@@ -761,18 +761,18 @@ example, in::
The value of bar is ``''``, and the value of baz is ``'a\n b\n\nc'``.
Lines starting with
'#' or ';'
characters are comments. Comments can
also be placed after the closing square bracket (
']'
) in a section header.
Lines starting with
``#`` or ``;``
characters are comments. Comments can
also be placed after the closing square bracket (
``]``
) in a section header.
Buildout configuration data are Python strings, which are bytes in
Python 2 and unicode in Python 3.
Sections and options within sections may be repeated. Multiple
occurrences of
of
a section are treated as if they were concatenated.
occurrences of a section are treated as if they were concatenated.
The last option value for a given name in a section overrides previous
values.
In addition to
p
the syntactic details above:
In addition to the syntactic details above:
- option names are case sensitive
...
...
@@ -785,11 +785,11 @@ In addition top the syntactic details above:
Annotated sections
------------------
When used with the `
annotate
` command, buildout displays annotated sections.
When used with the `
`annotate`
` command, buildout displays annotated sections.
All sections are displayed, sorted alphabetically. For each section,
all key-value pairs are displayed, sorted alphabetically, along with
the origin of the value (file name or
COMPUTED_VALUE, DEFAULT_VALUE
,
COMMAND_LINE_VALUE).
the origin of the value (file name or
``COMPUTED_VALUE``, ``DEFAULT_VALUE``
,
``COMMAND_LINE_VALUE``)::
>>> print_(system(buildout+ ' annotate'), end='')
... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
...
...
@@ -865,7 +865,7 @@ Variable substitutions
Buildout configuration files support variable substitution.
To illustrate this, we'll create an debug recipe to
allow us to see interactions with the buildout:
allow us to see interactions with the buildout:
:
>>> write(sample_buildout, 'recipes', 'debug.py',
... """
...
...
@@ -889,7 +889,7 @@ This recipe doesn't actually create anything. The install method
doesn't return anything, because it didn't create any files or
directories.
We also have to update our setup script:
We also have to update our setup script:
:
>>> write(sample_buildout, 'recipes', 'setup.py',
... """
...
...
@@ -904,11 +904,11 @@ We also have to update our setup script:
... """)
We've rearranged the script a bit to make the entry points easier to
edit.
In particular
, entry points are now defined as a configuration
edit.
Specifically
, entry points are now defined as a configuration
string, rather than a dictionary.
Let's update our configuration to provide variable substitution
examples:
examples:
:
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -927,13 +927,13 @@ examples:
... path = mydata
... """)
We used a string-template substitution for
File-1 and File-2
. This
type of substitution uses the
string.Template
syntax. Names
We used a string-template substitution for
``File-1`` and ``File-2``
. This
type of substitution uses the
``string.Template``
syntax. Names
substituted are qualified option names, consisting of a section name
and option name joined by a colon.
Now, if we run the buildout, we'll see the options with the values
substituted
.
substituted
::
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
...
...
@@ -945,14 +945,14 @@ substituted.
File-2 /sample-buildout/mydata/file/log
recipe recipes:debug
Note that the substitution of the
data-dir
path option reflects the
update to the option performed by the
mkdir
recipe.
Note that the substitution of the
``data-dir``
path option reflects the
update to the option performed by the
``mkdir``
recipe.
It might seem surprising that
mydata
was created again. This is
because we changed our
recipes package by adding the debug
module.
The buildout system didn't know if this module could
effect the mkdir
recipe, so it assumed it could and reinstalled
mydata
. If we rerun
the buildout:
It might seem surprising that
``mydata``
was created again. This is
because we changed our
``recipes`` package by adding the ``debug``
module.
The buildout system didn't know if this module could
affect the ``mkdir``
recipe, so it assumed it could and reinstalled
``mydata``
. If we rerun
the buildout:
:
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
...
...
@@ -962,7 +962,7 @@ the buildout:
File-2 /sample-buildout/mydata/file/log
recipe recipes:debug
We can see that mydata
was not recreated.
we can see that ``mydata``
was not recreated.
Note that, in this case, we didn't specify a log level, so
we didn't get output about what the buildout was doing.
...
...
@@ -973,7 +973,7 @@ restriction might be relaxed in future releases.
We can omit the section name in a variable substitution to refer to
the current section. We can also use the special option,
_buildout_section_name_ to get the current section name.
``_buildout_section_name_`` to get the current section name::
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -1009,7 +1009,7 @@ Automatic part selection and ordering
When a section with a recipe is referred to, either through variable
substitution or by an initializing recipe, the section is treated as a
part and added to the part list before the referencing part. For
example, we can leave
data-dir out of the parts list
:
example, we can leave
``data-dir`` out of the parts list:
:
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -1029,7 +1029,7 @@ example, we can leave data-dir out of the parts list:
... """)
It will still be treated as a part:
It will still be treated as a part:
:
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
...
...
@@ -1046,9 +1046,9 @@ It will still be treated as a part:
parts = data-dir debug
...
Note that the
data-dir part is included *before* the debug
part,
because the
debug part refers to the data-dir
part. Even if we list
the
data-dir part after the debug part, it will be included before
:
Note that the
``data-dir`` part is included *before* the ``debug``
part,
because the
``debug`` part refers to the ``data-dir``
part. Even if we list
the
``data-dir`` part after the ``debug`` part, it will be included before:
:
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -1068,7 +1068,7 @@ the data-dir part after the debug part, it will be included before:
... """)
It will still be treated as a part:
It will still be treated as a part:
:
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
...
...
@@ -1091,7 +1091,7 @@ A section (other than the buildout section) can extend one or more
other sections using the ``<`` option. Options from the referenced
sections are copied to the referring section *before* variable
substitution. This, together with the ability to refer to variables
of the current section
allows sections to be used as macros.
of the current section
, allows sections to be used as macros::
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -1130,9 +1130,13 @@ of the current section allows sections to be used as macros.
path mydata
recipe recipes:debug
In this example, the debug, with_file1 and with_file2 sections act as
macros. In particular, the variable substitutions are performed
relative to the myfiles section.
In this example, the ``debug``, ``with_file1`` and ``with_file2`` sections act
as macros. In particular, the variable substitutions are performed
relative to the ``myfiles`` section.
.. note:: Don't be fooled by the appearance of the ``<= section`` lines ---
though ``<=`` may look like a new operator, it's still just the familiar
``key = value`` syntax.
Extending sections (macros) - Adding and removing options
---------------------------------------------------------
...
...
@@ -1262,8 +1266,8 @@ Some things to note:
was reversed, the conditional section would have no effect.
In addition to the normal built-ins, the expression has access to
global variable
that make common cases short and description
as shown
above:
global variable
s that make common cases short and descriptive
as shown
below
sys
the ``sys`` module
...
...
@@ -1349,10 +1353,10 @@ Expressions must not contain either the ``#`` or the ``;`` character.
Adding and removing options
---------------------------
We can append and remove values to an option by using the
+ and -
We can append and remove values to an option by using the
``+`` and ``-``
operators.
This is illustrated below; first we define a base configuration
.
This is illustrated below; first we define a base configuration
::
>>> write(sample_buildout, 'base.cfg',
... """
...
...
@@ -1380,7 +1384,7 @@ This is illustrated below; first we define a base configuration.
... """)
Extending this configuration, we can "adjust" the values set in the
base configuration file
.
base configuration file
::
>>> write(sample_buildout, 'extension1.cfg',
... """
...
...
@@ -1411,7 +1415,7 @@ base configuration file.
...
... """)
An additional extension
.
An additional extension
::
>>> write(sample_buildout, 'extension2.cfg',
... """
...
...
@@ -1429,7 +1433,7 @@ An additional extension.
... """)
To verify that the options are adjusted correctly, we'll set up an
extension that prints out the options
.
extension that prints out the options
::
>>> mkdir(sample_buildout, 'demo')
>>> write(sample_buildout, 'demo', 'demo.py',
...
...
@@ -1451,7 +1455,7 @@ extension that prints out the options.
... )
... """)
Set up a buildout configuration for this extension
.
Set up a buildout configuration for this extension
::
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -1465,7 +1469,7 @@ Set up a buildout configuration for this extension.
... # doctest: +ELLIPSIS
Develop: '/sample-buildout/demo'...
Verify option values
.
Verify option values
::
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -1480,7 +1484,7 @@ Verify option values.
Develop: '/sample-buildout/demo'
Annotated sections output shows which files are responsible for which
operations
.
operations
::
>>> print_(system(os.path.join('bin', 'buildout') + ' annotate'), end='')
... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
...
...
@@ -1536,7 +1540,7 @@ operations.
DEFAULT_VALUE
<BLANKLINE>
Cleanup
.
Cleanup
::
>>> os.remove(os.path.join(sample_buildout, 'base.cfg'))
>>> os.remove(os.path.join(sample_buildout, 'extension1.cfg'))
...
...
@@ -1545,7 +1549,7 @@ Cleanup.
Multiple configuration files
----------------------------
A configuration file can
"extend"
another configuration file.
A configuration file can
*extend*
another configuration file.
Options are read from the other configuration file if they aren't
already defined by your configuration file.
...
...
@@ -1553,7 +1557,7 @@ The configuration files your file extends can extend
other configuration files. The same file may be
used more than once although, of course, cycles aren't allowed.
To see how this works, we use an example:
To see how this works, we use an example:
:
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -1586,7 +1590,7 @@ pretty common. In a more practical example, the base buildout might
represent a product and the extending buildout might be a
customization.
Here is a more elaborate example
.
Here is a more elaborate example
::
>>> other = tmpdir('other')
...
...
@@ -1660,7 +1664,7 @@ Here is a more elaborate example.
There are several things to note about this example:
- We can name multiple files in an
extends
option.
- We can name multiple files in an
``extends``
option.
- We can reference files recursively.
...
...
@@ -1671,7 +1675,7 @@ Loading Configuration from URLs
-------------------------------
Configuration files can be loaded from URLs. To see how this works,
we'll set up a web server with some configuration files
.
we'll set up a web server with some configuration files
::
>>> server_data = tmpdir('server_data')
...
...
@@ -1706,7 +1710,6 @@ we'll set up a web server with some configuration files.
... name = base
... """ % dict(url=server_url))
>>> print_(system(buildout+ ' -c client.cfg'), end='')
Develop: '/sample-buildout/recipes'
Uninstalling debug.
...
...
@@ -1718,12 +1721,12 @@ we'll set up a web server with some configuration files.
recipe recipes:debug
Here we specified a URL for the file we extended. The file we
downloaded
,
itself referred to a file on the server using a relative
downloaded itself referred to a file on the server using a relative
URL reference. Relative references are interpreted relative to the
base URL when they appear in configuration files loaded via URL.
We can also specify a URL as the configuration file to be used by a
buildout
.
buildout
::
>>> os.remove('client.cfg')
>>> write(server_data, 'remote.cfg',
...
...
@@ -1743,10 +1746,10 @@ buildout.
Initializing.
Error: Missing option: buildout:directory
Normally, the buildout directory defaults to directory
Normally, the buildout directory defaults to
a
directory
containing a configuration file. This won't work for configuration
files loaded from URLs. In this case, the buildout directory would
normally be defined on the command line:
normally be defined on the command line:
:
>>> print_(system(buildout
... + ' -c ' + server_url + '/remote.cfg'
...
...
@@ -1764,10 +1767,10 @@ normally be defined on the command line:
User defaults
-------------
If the file
$HOME/.buildout/default.cfg,
exists, it is read before
reading the configuration file. (
$HOME is the value of the HOME
environment variable. The
'/'
is replaced by the operating system file
delimiter.)
If the file
``$HOME/.buildout/default.cfg``
exists, it is read before
reading the configuration file. (
``$HOME`` is the value of the ``HOME``
environment variable. The
``/``
is replaced by the operating system file
delimiter.)
::
>>> old_home = os.environ['HOME']
>>> home = tmpdir('home')
...
...
@@ -1794,8 +1797,8 @@ delimiter.)
op7 7
recipe recipes:debug
A buildout command-line argument,
-U
, can be used to suppress reading
user defaults:
A buildout command-line argument,
``-U``
, can be used to suppress reading
user defaults:
:
>>> print_(system(buildout + ' -U'), end='')
Develop: '/sample-buildout/recipes'
...
...
@@ -1810,10 +1813,10 @@ user defaults:
op5 b3base 5
recipe recipes:debug
If the environment variable
BUILDOUT_HOME
is non-empty, that is used to
locate
default.cfg instead of looking in ~/.buildout/
. Let's set up a
If the environment variable
``BUILDOUT_HOME``
is non-empty, that is used to
locate
``default.cfg`` instead of looking in ``~/.buildout/``
. Let's set up a
configuration file in an alternate directory and verify that we get the
appropriate set of defaults:
appropriate set of defaults:
:
>>> alterhome = tmpdir('alterhome')
>>> write(alterhome, 'default.cfg',
...
...
@@ -1840,8 +1843,8 @@ appropriate set of defaults:
op8 eight!
recipe recipes:debug
The
-U argument still suppresses reading of the default.cfg
file from
BUILDOUT_HOME
:
The
``-U`` argument still suppresses reading of the ``default.cfg``
file from
``BUILDOUT_HOME``:
:
>>> print_(system(buildout + ' -U'), end='')
Develop: '/sample-buildout/recipes'
...
...
@@ -1862,9 +1865,9 @@ BUILDOUT_HOME:
Log level
---------
We can control the level of logging by specifying a log level in ou
t
configuration file. For example,
s
o suppress info messages, we can
set the logging level to
WARNING
We can control the level of logging by specifying a log level in ou
r
configuration file. For example,
t
o suppress info messages, we can
set the logging level to
*WARNING*::
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -1884,7 +1887,7 @@ Socket timeout
--------------
The timeout of the connections to egg and configuration servers can be
configured in the buildout section. Its value is configured in seconds
.
configured in the buildout section. Its value is configured in seconds
::
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -1906,8 +1909,8 @@ configured in the buildout section. Its value is configured in seconds.
op timeout
recipe recipes:debug
If the
socket-timeout
is not numeric, a warning is issued and the default
timeout of the Python socket module is used
.
If the
``socket-timeout``
is not numeric, a warning is issued and the default
timeout of the Python socket module is used
::
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -1937,24 +1940,24 @@ As we've seen, when parts are installed, buildout keeps track of files
and directories that they create. When the parts are uninstalled these
files and directories are deleted.
Sometimes more clean
up is needed. For example, a recipe might add a
system service by calling
chkconfig --add
during installation. Later
during uninstallation,
chkconfig --del
will need to be called to
Sometimes more clean
-
up is needed. For example, a recipe might add a
system service by calling
``chkconfig --add``
during installation. Later
during uninstallation,
``chkconfig --del``
will need to be called to
remove the system service.
In order to deal with these uninstallation issues, you can register
uninstall recipes. Uninstall recipes are registered using the
'zc.buildout.uninstall'
entry point. Parts specify uninstall recipes
using the
'uninstall'
option.
``zc.buildout.uninstall``
entry point. Parts specify uninstall recipes
using the
``uninstall``
option.
In comparison to regular recipes, uninstall recipes are much
simpler. They are simply callable objects that accept the name of the
part to be uninstalled and the part's options dictionary. Uninstall
recipes don't have access to the part itself since it may
be not
be
able to be instantiated
at uninstallation time.
recipes don't have access to the part itself since it may be
impossible to instantiate
at uninstallation time.
Here's a recipe that simulates installation of a system service, along
with an uninstall recipe that simulates removing the service
.
with an uninstall recipe that simulates removing the service
::
>>> write(sample_buildout, 'recipes', 'service.py',
... """
...
...
@@ -1982,7 +1985,7 @@ with an uninstall recipe that simulates removing the service.
To use these recipes we must register them using entry points. Make
sure to use the same name for the recipe and uninstall recipe. This is
required to let buildout know which uninstall recipe goes with which
recipe
.
recipe
::
>>> write(sample_buildout, 'recipes', 'setup.py',
... """
...
...
@@ -2000,7 +2003,7 @@ recipe.
... setup(name="recipes", entry_points=entry_points)
... """)
Here's how these recipes could be used in a buildout:
Here's how these recipes could be used in a buildout:
:
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -2013,7 +2016,7 @@ Here's how these recipes could be used in a buildout:
... script = /path/to/script
... """)
When the buildout is run the service will be installed
When the buildout is run the service will be installed
::
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
...
...
@@ -2022,14 +2025,14 @@ When the buildout is run the service will be installed
chkconfig --add /path/to/script
The service has been installed. If the buildout is run again with no
changes, the service shouldn't be changed
.
changes, the service shouldn't be changed
::
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Updating service.
Now we change the service part to trigger uninstallation and
re-installation
.
re-installation
::
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -2050,7 +2053,7 @@ re-installation.
Installing service.
chkconfig --add /path/to/a/different/script
Now we remove the service part, and add another part
.
Now we remove the service part, and add another part
::
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -2078,7 +2081,7 @@ recipe before they are deleted.
For example, here's an uninstallation recipe that simulates backing up
a directory before it is deleted. It is designed to work with the
mkdir recipe introduced earlier.
``mkdir`` recipe introduced earlier::
>>> write(sample_buildout, 'recipes', 'backup.py',
... """
...
...
@@ -2090,9 +2093,9 @@ mkdir recipe introduced earlier.
... % (path, size))
... """)
It must be registered with the
zc.buildout.uninstall
entry
point. Notice how it is given the name
'mkdir'
to associate it with
the
mkdir recipe.
It must be registered with the
``zc.buildout.uninstall``
entry
point. Notice how it is given the name
``mkdir``
to associate it with
the
``mkdir`` recipe::
>>> write(sample_buildout, 'recipes', 'setup.py',
... """
...
...
@@ -2111,7 +2114,7 @@ the mkdir recipe.
... setup(name="recipes", entry_points=entry_points)
... """)
Now we can use it with a
mkdir part.
Now we can use it with a
``mkdir`` part::
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -2127,7 +2130,7 @@ Now we can use it with a mkdir part.
... recipe = recipes:debug
... """)
Run the buildout to install the part
.
Run the buildout to install the part
::
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
...
...
@@ -2137,7 +2140,7 @@ Run the buildout to install the part.
Installing debug.
recipe recipes:debug
Now we remove the part from the configuration file
.
Now we remove the part from the configuration file
::
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -2150,7 +2153,7 @@ Now we remove the part from the configuration file.
... """)
When the buildout is run the part is removed, and the uninstall recipe
is run before the directory is deleted
.
is run before the directory is deleted
::
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
...
...
@@ -2161,7 +2164,7 @@ is run before the directory is deleted.
recipe recipes:debug
Now we will return the registration to normal for the benefit of the
rest of the examples
.
rest of the examples
::
>>> write(sample_buildout, 'recipes', 'setup.py',
... """
...
...
@@ -2186,57 +2189,56 @@ command usage is::
The following options are supported:
-h (or --help
)
``-h`` (or ``--help``
)
Print basic usage information. If this option is used, then all
other options are ignored.
-c filename
The -c option can be used to specify a configuration file, rather than
buildout.cfg in the current directory.
``-c`` filename
The ``-c`` option can be used to specify a configuration file, rather than
``buildout.cfg`` in the current directory.
-t socket_timeout
``-t`` socket_timeout
Specify the socket timeout in seconds.
-v
``-v``
Increment the verbosity by 10. The verbosity is used to adjust
the logging level. The verbosity is subtracted from the numeric
value of the log-level option specified in the configuration file.
-q
``-q``
Decrement the verbosity by 10.
-U
``-U``
Don't read user-default configuration.
-o
``-o``
Run in off-line mode. This is equivalent to the assignment
buildout:offline=true
.
``buildout:offline=true``
.
-O
``-O``
Run in non-off-line mode. This is equivalent to the assignment
buildout:offline=false
. This is the default buildout mode. The
-O
option would normally be used to override a true offline
``buildout:offline=false``
. This is the default buildout mode. The
``-O``
option would normally be used to override a true offline
setting in a configuration file.
-n
``-n``
Run in newest mode. This is equivalent to the assignment
buildout:newest=true
. With this setting, which is the default,
``buildout:newest=true``
. With this setting, which is the default,
buildout will try to find the newest versions of distributions
available that satisfy its requirements.
-N
``-N``
Run in non-newest mode. This is equivalent to the assignment
buildout:newest=false
. With this setting, buildout will not seek
new distributions if installed distributions satisfy it
'
s
``buildout:newest=false``
. With this setting, buildout will not seek
new distributions if installed distributions satisfy its
requirements.
Assignments are of the form::
section_name:option_name=value
O
r::
o
r::
option_name=value
...
...
@@ -2246,7 +2248,7 @@ which is equivalent to::
Options and assignments can be given in any order.
Here's an example:
Here's an example:
:
>>> write(sample_buildout, 'other.cfg',
... """
...
...
@@ -2262,7 +2264,7 @@ Here's an example:
... """)
Note that we used the installed buildout option to specify an
alternate file to store information about installed parts
.
alternate file to store information about installed parts
::
>>> print_(system(buildout+' -c other.cfg debug:op1=foo -v'), end='')
Develop: '/sample-buildout/recipes'
...
...
@@ -2271,11 +2273,11 @@ alternate file to store information about installed parts.
op1 foo
recipe recipes:debug
Here we used the
-c
option to specify an alternate configuration file,
and the
-v
option to increase the level of logging from the default,
WARNING
.
Here we used the
``-c``
option to specify an alternate configuration file,
and the
``-v``
option to increase the level of logging from the default,
*WARNING*
.
Options can also be combined in the usual Unix way, as in:
Options can also be combined in the usual Unix way, as in:
:
>>> print_(system(buildout+' -vcother.cfg debug:op1=foo'), end='')
Develop: '/sample-buildout/recipes'
...
...
@@ -2284,17 +2286,17 @@ Options can also be combined in the usual Unix way, as in:
op1 foo
recipe recipes:debug
Here we combined the
-v and -c
options with the configuration file
name. Note that the
-c
option has to be last, because it takes an
argument
.
Here we combined the
``-v`` and ``-c``
options with the configuration file
name. Note that the
``-c``
option has to be last, because it takes an
argument
::
>>> os.remove(os.path.join(sample_buildout, 'other.cfg'))
>>> os.remove(os.path.join(sample_buildout, '.other.cfg'))
The most commonly used command is
'install'
and it takes a list of
parts to install.
i
f any parts are specified, only those parts are
The most commonly used command is
``install``,
and it takes a list of
parts to install.
I
f any parts are specified, only those parts are
installed. To illustrate this, we'll update our configuration and run
the buildout in the usual way:
the buildout in the usual way:
:
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -2375,7 +2377,7 @@ the buildout in the usual way:
path = /sample-buildout/d3
recipe = recipes:mkdir
Now we'll update our configuration file:
Now we'll update our configuration file:
:
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -2400,7 +2402,7 @@ Now we'll update our configuration file:
... x = 1
... """)
and run the buildout specifying just
d3 and d4
:
and run the buildout specifying just
``d3`` and ``d4``:
:
>>> print_(system(buildout+' install d3 d4'), end='')
Develop: '/sample-buildout/recipes'
...
...
@@ -2427,10 +2429,11 @@ and run the buildout specifying just d3 and d4:
d parts
d recipes
Only the d3 and d4 recipes ran. d3 was removed and data3 and data2-extra
Only the ``d3`` and ``d4`` recipes ran.
``d3`` was removed and ``data3`` and ``data2-extra``
were created.
The
.installed.cfg is only updated for the recipes that ran
:
The
``.installed.cfg`` is only updated for the recipes that ran:
:
>>> cat(sample_buildout, '.installed.cfg')
... # doctest: +NORMALIZE_WHITESPACE
...
...
@@ -2467,11 +2470,12 @@ The .installed.cfg is only updated for the recipes that ran:
path = /sample-buildout/data2-extra
recipe = recipes:mkdir
Note that the installed data for debug, d1, and d2 haven't changed,
because we didn't install those parts and that the d1 and d2
Note that the installed data for ``debug``, ``d1``, and ``d2`` haven't
changed,
because we didn't install those parts, and that the ``d1`` and ``d2``
directories are still there.
Now, if we run the buildout without the install command:
Now, if we run the buildout without the install command:
:
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
...
...
@@ -2486,8 +2490,8 @@ Now, if we run the buildout without the install command:
Updating d3.
Updating d4.
We see the output of the debug recipe
and that data2
was created. We
also see that
d1 and d2 have gone away
:
We see the output of the debug recipe
, and that ``data2``
was created. We
also see that
``d1`` and ``d2`` have gone away:
:
>>> ls(sample_buildout)
- .installed.cfg
...
...
@@ -2508,9 +2512,9 @@ also see that d1 and d2 have gone away:
Alternate directory and file locations
--------------------------------------
The buildout normally puts the
bin, eggs, and parts directories in the
directory in the directory containing the configuration file. You can
provide alternate locations, and even names for these directories
.
The buildout normally puts the
``bin``, ``eggs``, and ``parts`` directories in
the
directory in the directory containing the configuration file. You can
provide alternate locations, and even names for these directories
::
>>> alt = tmpdir('sample-alt')
...
...
@@ -2550,7 +2554,7 @@ provide alternate locations, and even names for these directories.
>>> ls(alt, 'developbasket')
- recipes.egg-link
You can also specify an alternate buildout directory:
You can also specify an alternate buildout directory:
:
>>> rmdir(alt)
>>> alt = tmpdir('sample-alt')
...
...
@@ -2588,17 +2592,17 @@ Logging control
Three buildout options are used to control logging:
log-level
``log-level``
specifies the log level
verbosity
``verbosity``
adjusts the log level
log-format
allows an alternate logging for
mat to be specified
``log-format``
allows an alternate logging format to be specified
We've already seen the log level and verbosity. Let's look at an example
of changing the format:
of changing the format:
:
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -2616,7 +2620,7 @@ than the logger name.
We've also illustrated, with a contrived example, that the log level
can be a numeric value and that the verbosity can be specified in the
configuration file. Because the verbosity is subtracted from the log
level, we get a final log level of 20, which is the
INFO level.
level, we get a final log level of 20, which is the
*INFO* level::
>>> print_(system(buildout), end='')
INFO Develop: '/sample-buildout/recipes'
...
...
@@ -2626,9 +2630,9 @@ Predefined buildout options
Buildouts have a number of predefined options that recipes can use
and that users can override in their configuration files. To see
these, we'll run a minimal buildout configuration with a
debug
logging
level. One of the features of
debug
logging is that the configuration
database is shown
.
these, we'll run a minimal buildout configuration with a
``debug``
logging
level. One of the features of
``debug``
logging is that the configuration
database is shown
::
>>> write(sample_buildout, 'buildout.cfg',
... """
...
...
@@ -2677,19 +2681,20 @@ All of these options can be overridden by configuration files or by
command-line assignments. We've discussed most of these options
already, but let's review them and touch on some we haven't discussed:
allow-hosts
On some environments the links visited by `zc.buildout` can be forbidden by
paranoid firewalls. These URLs might be in the chain of links visited by
`zc.buildout` as defined by buildout's `find-links` option, or as defined
by various eggs in their `url`, `download_url`, `dependency_links` metadata.
``allow-hosts``
On some environments the links visited by ``zc.buildout`` can be forbidden
by paranoid firewalls. These URLs might be in the chain of links visited
by ``zc.buildout`` as defined by buildout's ``find-links`` option, or as
defined by various eggs in their ``url``, ``download_url``,
``dependency_links`` metadata.
The fact that
package_index works like a spider and might visit links and
go to other locations makes this even harder.
The fact that
``package_index`` works like a spider and might visit links
and
go to other locations makes this even harder.
The `
allow-hosts
` option provides a way to prevent this, and
works exactly like the one provided in `
easy_install
`.
The `
`allow-hosts`
` option provides a way to prevent this, and
works exactly like the one provided in `
`easy_install`
`.
You can provide a list of allowed host, together with wildcards::
You can provide a list of allowed host
s
, together with wildcards::
[buildout]
...
...
...
@@ -2698,42 +2703,47 @@ allow-hosts
*.python.org
example.com
All URLs that do
es
not match these hosts will not be visited.
All URLs that do not match these hosts will not be visited.
allow-picked-versions
By default, the buildout will choose the best match for a given requirement
``allow-picked-versions``
By default, the buildout will choose the best match for a given
requirement
if the requirement is not specified precisely (for instance, using the
"versions"
option. This behavior corresponds to the
"allow-picked-versions" being set to its default value, "true"
. If
"allow-picked-versions" is "false,"
instead of picking the best match,
``versions``
option. This behavior corresponds to the
``allow-picked-versions`` being set to its default value, ``true``
. If
``allow-picked-versions`` is ``false``,
instead of picking the best match,
buildout will raise an error. This helps enforce repeatability.
bin-directory
``bin-directory``
The directory path where scripts are written. This can be a
relative path, which is interpreted relative to the directory
option.
develop-eggs-directory
``develop-eggs-directory``
The directory path where development egg links are created for software
being created in the local project. This can be a relative path,
which is interpreted relative to the directory option.
directory
``directory``
The buildout directory. This is the base for other buildout file
and directory locations, when relative locations are used.
eggs-directory
``eggs-directory``
The directory path where downloaded eggs are put. It is common to share
this directory across buildouts.
Eggs in this directory should
*never* be modified.
This can be a relative path, which is
this directory across buildouts.
This can be a relative path, which is
interpreted relative to the directory option.
find-links
.. warning::
Eggs in this directory should *never* be modified.
``find-links``
You can specify more locations to search for distributions using the
`
find-links
` option. All locations specified will be searched for
`
`find-links`
` option. All locations specified will be searched for
distributions along with the package index as described before.
Locations can be
url
s::
Locations can be
URL
s::
[buildout]
...
...
...
@@ -2751,7 +2761,7 @@ find-links
...
find-links = /some/path/someegg-1.0.0-py2.3.egg
Any number of locations can be specified in the `
find-links
` option::
Any number of locations can be specified in the `
`find-links`
` option::
[buildout]
...
...
...
@@ -2760,96 +2770,102 @@ find-links
/some/otherpath
/some/path/someegg-1.0.0-py2.3.egg
install-from-cache
``install-from-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
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
distribute a buildout along with a 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
buildout
``install-from-cache``
option can be used to signal that packages
should be installed only from the download cache.
installed
``installed``
The file path where information about the results of the previous
buildout run is written. This can be a relative path, which is
interpreted relative to the directory option. This file provides
an inventory of installed parts with information needed to decide
which if any parts need to be uninstalled.
log-format
``log-format``
The format used for logging messages.
log-level
``log-level``
The log level before verbosity adjustment
newest
``newest``
By default buildout and recipes will try to find the newest versions of
distributions needed to satisfy requirements. This can be very time
consuming, especially when incrementally working on setting up a buildout
or working on a recipe. The buildout
"newest"
option can be used to to
suppress this. If the
"newest"
option is set to false, then new
or working on a recipe. The buildout
``newest``
option can be used to to
suppress this. If the
``newest``
option is set to false, then new
distributions won't be sought if an installed distribution meets
requirements. The "newest" option can also be set to false using the -N
command-line option. See also the "offline" option.
offline
The "offline" option goes a bit further than the "newest" option. If the
buildout "offline" option is given a value of "true", the buildout and
recipes that are aware of the option will avoid doing network access. This
requirements. The ``newest`` option can also be set to false using the -N
command-line option. See also the ``offline`` option.
``offline``
The ``offline`` option goes a bit further than the ``newest`` option.
If the
buildout ``offline`` option is given a value of ``true``, the buildout and
recipes that are aware of the option will avoid doing network access.
This
is handy when running the buildout when not connected to the internet. It
also makes buildouts run much faster. This option is typically set using
the buildout
-o
option.
the buildout
``-o``
option.
parts
A white
space
separated list of parts to be installed.
``parts``
A white
space-
separated list of parts to be installed.
parts-directory
``parts-directory``
A working directory that parts can used to store data.
prefer-final
``prefer-final``
Currently, when searching for new releases, the newest available
release is used. This isn't usually ideal, as you may get a
development release or alpha releases not ready to be widely used.
You can request that final releases be preferred using the
prefer
final option in the buildout
section::
You can request that final releases be preferred using the
``prefer-final`` option in the ``buildout``
section::
[buildout]
...
prefer-final = true
When the prefer-final option is set to true, then when searching for
When the ``prefer-final`` option is set to ``true``, then when searching
for
new releases, final releases are preferred. If there are final
releases that satisfy distribution requirements, then those releases
are used even if newer non-final releases are available. The buildout
prefer-final
option can be used to override this behavior.
``prefer-final``
option can be used to override this behavior.
In buildout version 2, final releases will be preferred by default.
You will then need to use a
false value for prefer-final to get the
newest releases.
You will then need to use a
``false`` value for ``prefer-final`` to get
the
newest releases.
use-dependency-links
By default buildout will obey the setuptools
dependency_links
metadata
``use-dependency-links``
By default buildout will obey the setuptools
``dependency_links``
metadata
when it looks for dependencies. This behavior can be controlled with
the
use-dependency-links
buildout option::
the
``use-dependency-links``
buildout option::
[buildout]
...
use-dependency-links = false
The option defaults to true. If you set it to false, then dependency
links are only looked for in the locations specified by find-links.
The option defaults to ``true``. If you set it to ``false``, then
dependency links are only looked for in the locations specified by
``find-links``.
verbosity
A log-level adjustment. Typically, this is set via the
-q and -v
``verbosity``
A log-level adjustment. Typically, this is set via the
``-q`` and ``-v``
command-line options.
Creating new buildouts and bootstrapping
----------------------------------------
If
zc.buildout
is installed, you can use it to create a new buildout
with it
's own local copies of zc.buildout and setuptools
and with
local buildout scripts
.
If
``zc.buildout``
is installed, you can use it to create a new buildout
with it
s own local copies of ``zc.buildout`` and ``setuptools``
and with
local buildout scripts
::
>>> sample_bootstrapped = tmpdir('sample-bootstrapped')
...
...
@@ -2863,15 +2879,15 @@ local buildout scripts.
Creating directory '/sample-bootstrapped/develop-eggs'.
Generated script '/sample-bootstrapped/bin/buildout'.
Note that a basic
setup.cfg
was created for us. This is because we
provided an
'init'
argument. By default, the generated
``setup.cfg`` is as minimal as
it could be
:
Note that a basic
``setup.cfg``
was created for us. This is because we
provided an
``init``
argument. By default, the generated
``setup.cfg`` is as minimal as
can be:
:
>>> cat(sample_bootstrapped, 'setup.cfg')
[buildout]
parts =
We also get other buildout artifacts:
We also get other buildout artifacts:
:
>>> ls(sample_bootstrapped)
d bin
...
...
@@ -2888,17 +2904,17 @@ We also get other buildout artifacts:
- setuptools-0.7-py2.3.egg
- zc.buildout-1.0-py2.3.egg
(We list both the
eggs and develop-eggs
directories because the
buildout or setuptools egg could be installed in the
develop-eggs
(We list both the
``eggs`` and ``develop-eggs``
directories because the
buildout or setuptools egg could be installed in the
``develop-eggs``
directory if the original buildout had develop eggs for either
buildout or setuptools.)
Note that the buildout script was installed but not run. To run
the buildout, we'd have to run the installed buildout script.
If we have an existing buildout that already has a
buildout.cfg
, we'll
normally use the
bootstrap command instead of init
. It will complain
if there isn't a configuration file:
If we have an existing buildout that already has a
``buildout.cfg``
, we'll
normally use the
``bootstrap`` command instead of ``init``
. It will complain
if there isn't a configuration file:
:
>>> sample_bootstrapped2 = tmpdir('sample-bootstrapped2')
...
...
@@ -2924,9 +2940,9 @@ if there isn't a configuration file:
Creating directory '/sample-bootstrapped2/develop-eggs'.
Generated script '/sample-bootstrapped2/bin/buildout'.
Similarly, if there is a configuration file and we use the
init
Similarly, if there is a configuration file and we use the
``init``
command, we'll get an error that the configuration file already
exists:
exists:
:
>>> print_(system(buildout
... +' -c'+os.path.join(sample_bootstrapped, 'setup.cfg')
...
...
@@ -2939,7 +2955,7 @@ Initial eggs
------------
When using the ``init`` command, you can specify distribution requirements
or paths to use:
or paths to use:
:
>>> cd(sample_bootstrapped)
>>> remove('setup.cfg')
...
...
@@ -2959,8 +2975,8 @@ or paths to use:
Generated script '/sample-bootstrapped/bin/distutilsscript'.
Generated interpreter '/sample-bootstrapped/bin/py'.
This causes a ``py`` part to be included that sets up a custom
p
ython
interpreter with the given requirements or paths:
This causes a ``py`` part to be included that sets up a custom
P
ython
interpreter with the given requirements or paths:
:
>>> cat('setup.cfg')
[buildout]
...
...
@@ -2975,16 +2991,16 @@ interpreter with the given requirements or paths:
extra-paths =
./src
Passing requirements or paths causes the
the
buildout to be run as part
Passing requirements or paths causes the buildout to be run as part
of initialization. In the example above, we got a number of
distributions installed and 2 scripts generated. The first, ``demo``,
was defined by the ``demo`` project. The second, ``py`` was defined by
the generated configuration. It's a
"custom interpreter"
that behaves
like a standard Python interpreter, except that includes the specified
eggs and extra paths in it
'
s Python path.
the generated configuration. It's a
*custom interpreter*
that behaves
like a standard Python interpreter, except that i
t i
ncludes the specified
eggs and extra paths in its Python path.
We specified a source directory that didn't exist. Buildout created it
for us:
for us:
:
>>> ls('.')
- .installed.cfg
...
...
@@ -3033,15 +3049,15 @@ distributions. The latest version of the distribution that meets the
requirements of the buildout will always be used.
You can also specify more locations to search for distributions using
the `
find-links
` option. See its description above.
the `
`find-links`
` option. See its description above.
Controlling the installation database
-------------------------------------
The buildout
installed
option is used to specify the file used to save
The buildout
``installed``
option is used to specify the file used to save
information on installed parts. This option is initialized to
".installed.cfg"
, but it can be overridden in the configuration file
or on the command line:
``.installed.cfg``
, but it can be overridden in the configuration file
or on the command line:
:
>>> write('buildout.cfg',
... """
...
...
@@ -3072,7 +3088,7 @@ or on the command line:
d recipes
The installation database can be disabled by supplying an empty
buildout installed option:
buildout installed option:
:
>>> os.remove('inst.cfg')
>>> print_(system(buildout+' buildout:installed='), end='')
...
...
@@ -3093,7 +3109,7 @@ buildout installed option:
d recipes
Note that there will be no installation database if there are no parts:
Note that there will be no installation database if there are no parts:
:
>>> write('buildout.cfg',
... """
...
...
@@ -3118,12 +3134,12 @@ Note that there will be no installation database if there are no parts:
Extensions
----------
A feature allows code to be loaded and run
after
configuration files have been read
but before
the buildout has begun
A feature allows code to be loaded and run
*after*
configuration files have been read
, but *before*
the buildout has begun
any processing. The intent is to allow special plugins such as
urllib2
request handlers to be loaded.
``urllib2``
request handlers to be loaded.
To load an extension
, we use the extensions
option and list one or
To load an extension
we use the ``extensions``
option and list one or
more distribution requirements, on separate lines. The distributions
named will be loaded and any ``zc.buildout.extension`` entry points found
will be called with the buildout as an argument. When buildout
...
...
@@ -3131,7 +3147,7 @@ finishes processing, any ``zc.buildout.unloadextension`` entry points
found will be called with the buildout as an argument.
Let's create a sample extension in our sample buildout created in the
previous section:
previous section:
:
>>> mkdir(sample_bootstrapped, 'demo')
...
...
@@ -3160,8 +3176,8 @@ previous section:
Our extension just prints out the word 'demo', and lists the sections
found in the buildout passed to it.
We'll update our
buildout.cfg
to list the demo directory as a develop
egg to be built:
We'll update our
``buildout.cfg``
to list the demo directory as a develop
egg to be built:
:
>>> write(sample_bootstrapped, 'buildout.cfg',
... """
...
...
@@ -3175,12 +3191,12 @@ egg to be built:
... end='')
Develop: '/sample-bootstrapped/demo'
Now we can add the
extensions
option. We were a bit tricky and ran
Now we can add the
``extensions``
option. We were a bit tricky and ran
the buildout once with the demo develop egg defined but without the
extension option. This is because extensions are loaded before the
buildout creates develop eggs. We needed to use a separate buildout
run to create the develop egg. Normally, when eggs are loaded from
the network, we wouldn't need to do anything special.
the network, we wouldn't need to do anything special.
::
>>> write(sample_bootstrapped, 'buildout.cfg',
... """
...
...
@@ -3190,7 +3206,7 @@ the network, we wouldn't need to do anything special.
... parts =
... """)
We see that our extension is loaded and executed:
We see that our extension is loaded and executed:
:
>>> print_(system(os.path.join(sample_bootstrapped, 'bin', 'buildout')),
... end='')
...
...
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