Commit d05717a2 authored by Reinout van Rees's avatar Reinout van Rees Committed by GitHub

Merge pull request #275 from jean/master

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