Commit 71ac370d authored by Jean Jordaan's avatar Jean Jordaan

Editing while reading, fixed `<` option (should be `<=`)

parent 039ac65d
......@@ -1088,10 +1088,10 @@ Extending sections (macros)
---------------------------
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
substitution. This, together with the ability to refer to variables
of the current section allows sections to be used as macros.
of the current section, allows sections to be used as macros.
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -1130,9 +1130,9 @@ of the current section allows sections to be used as macros.
path mydata
recipe recipes:debug
In this example, the debug, with_file1 and with_file2 sections act as
macros. In particular, the variable substitutions are performed
relative to the myfiles section.
In this example, the ``debug``, ``with_file1`` and ``with_file2`` sections act
as macros. In particular, the variable substitutions are performed
relative to the ``myfiles`` section.
Conditional sections
--------------------
......@@ -1177,8 +1177,8 @@ Some things to note:
was reversed, the conditional section would have no effect.
In addition to the normal built-ins, the expression has access to
global variable that make common cases short and description as shown
above:
global variables that make common cases short and descriptive as shown
below
sys
the ``sys`` module
......@@ -1264,10 +1264,10 @@ Expressions must not contain either the ``#`` or the ``;`` character.
Adding and removing options
---------------------------
We can append and remove values to an option by using the + and -
We can append and remove values to an option by using the ``+`` and ``-``
operators.
This is illustrated below; first we define a base configuration.
This is illustrated below; first we define a base configuration::
>>> write(sample_buildout, 'base.cfg',
... """
......@@ -1295,7 +1295,7 @@ This is illustrated below; first we define a base configuration.
... """)
Extending this configuration, we can "adjust" the values set in the
base configuration file.
base configuration file::
>>> write(sample_buildout, 'extension1.cfg',
... """
......@@ -1326,7 +1326,7 @@ base configuration file.
...
... """)
An additional extension.
An additional extension::
>>> write(sample_buildout, 'extension2.cfg',
... """
......@@ -1344,7 +1344,7 @@ An additional extension.
... """)
To verify that the options are adjusted correctly, we'll set up an
extension that prints out the options.
extension that prints out the options::
>>> mkdir(sample_buildout, 'demo')
>>> write(sample_buildout, 'demo', 'demo.py',
......@@ -1366,7 +1366,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',
... """
......@@ -1380,7 +1380,7 @@ Set up a buildout configuration for this extension.
... # doctest: +ELLIPSIS
Develop: '/sample-buildout/demo'...
Verify option values.
Verify option values::
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -1395,7 +1395,7 @@ Verify option values.
Develop: '/sample-buildout/demo'
Annotated sections output shows which files are responsible for which
operations.
operations::
>>> print_(system(os.path.join('bin', 'buildout') + ' annotate'), end='')
... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
......@@ -1451,7 +1451,7 @@ operations.
DEFAULT_VALUE
<BLANKLINE>
Cleanup.
Cleanup::
>>> os.remove(os.path.join(sample_buildout, 'base.cfg'))
>>> os.remove(os.path.join(sample_buildout, 'extension1.cfg'))
......@@ -1460,7 +1460,7 @@ Cleanup.
Multiple configuration files
----------------------------
A configuration file can "extend" another configuration file.
A configuration file can *extend* another configuration file.
Options are read from the other configuration file if they aren't
already defined by your configuration file.
......@@ -1468,7 +1468,7 @@ The configuration files your file extends can extend
other configuration files. The same file may be
used more than once although, of course, cycles aren't allowed.
To see how this works, we use an example:
To see how this works, we use an example::
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -1501,7 +1501,7 @@ pretty common. In a more practical example, the base buildout might
represent a product and the extending buildout might be a
customization.
Here is a more elaborate example.
Here is a more elaborate example::
>>> other = tmpdir('other')
......@@ -1575,7 +1575,7 @@ Here is a more elaborate example.
There are several things to note about this example:
- We can name multiple files in an extends option.
- We can name multiple files in an ``extends`` option.
- We can reference files recursively.
......@@ -1586,7 +1586,7 @@ Loading Configuration from URLs
-------------------------------
Configuration files can be loaded from URLs. To see how this works,
we'll set up a web server with some configuration files.
we'll set up a web server with some configuration files::
>>> server_data = tmpdir('server_data')
......@@ -1621,7 +1621,6 @@ we'll set up a web server with some configuration files.
... name = base
... """ % dict(url=server_url))
>>> print_(system(buildout+ ' -c client.cfg'), end='')
Develop: '/sample-buildout/recipes'
Uninstalling debug.
......@@ -1633,12 +1632,12 @@ we'll set up a web server with some configuration files.
recipe recipes:debug
Here we specified a URL for the file we extended. The file we
downloaded, itself referred to a file on the server using a relative
downloaded itself referred to a file on the server using a relative
URL reference. Relative references are interpreted relative to the
base URL when they appear in configuration files loaded via URL.
We can also specify a URL as the configuration file to be used by a
buildout.
buildout::
>>> os.remove('client.cfg')
>>> write(server_data, 'remote.cfg',
......@@ -1658,10 +1657,10 @@ buildout.
Initializing.
Error: Missing option: buildout:directory
Normally, the buildout directory defaults to directory
Normally, the buildout directory defaults to a directory
containing a configuration file. This won't work for configuration
files loaded from URLs. In this case, the buildout directory would
normally be defined on the command line:
normally be defined on the command line::
>>> print_(system(buildout
... + ' -c ' + server_url + '/remote.cfg'
......@@ -1679,10 +1678,10 @@ normally be defined on the command line:
User defaults
-------------
If the file $HOME/.buildout/default.cfg, exists, it is read before
reading the configuration file. ($HOME is the value of the HOME
environment variable. The '/' is replaced by the operating system file
delimiter.)
If the file ``$HOME/.buildout/default.cfg`` exists, it is read before
reading the configuration file. (``$HOME`` is the value of the ``HOME``
environment variable. The ``/`` is replaced by the operating system file
delimiter.)::
>>> old_home = os.environ['HOME']
>>> home = tmpdir('home')
......@@ -1709,8 +1708,8 @@ delimiter.)
op7 7
recipe recipes:debug
A buildout command-line argument, -U, can be used to suppress reading
user defaults:
A buildout command-line argument, ``-U``, can be used to suppress reading
user defaults::
>>> print_(system(buildout + ' -U'), end='')
Develop: '/sample-buildout/recipes'
......@@ -1725,10 +1724,10 @@ user defaults:
op5 b3base 5
recipe recipes:debug
If the environment variable BUILDOUT_HOME is non-empty, that is used to
locate default.cfg instead of looking in ~/.buildout/. Let's set up a
If the environment variable ``BUILDOUT_HOME`` is non-empty, that is used to
locate ``default.cfg`` instead of looking in ``~/.buildout/``. Let's set up a
configuration file in an alternate directory and verify that we get the
appropriate set of defaults:
appropriate set of defaults::
>>> alterhome = tmpdir('alterhome')
>>> write(alterhome, 'default.cfg',
......@@ -1755,8 +1754,8 @@ appropriate set of defaults:
op8 eight!
recipe recipes:debug
The -U argument still suppresses reading of the default.cfg file from
BUILDOUT_HOME:
The ``-U`` argument still suppresses reading of the ``default.cfg`` file from
``BUILDOUT_HOME``::
>>> print_(system(buildout + ' -U'), end='')
Develop: '/sample-buildout/recipes'
......@@ -1777,9 +1776,9 @@ BUILDOUT_HOME:
Log level
---------
We can control the level of logging by specifying a log level in out
configuration file. For example, so suppress info messages, we can
set the logging level to WARNING
We can control the level of logging by specifying a log level in our
configuration file. For example, to suppress info messages, we can
set the logging level to *WARNING*::
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -1799,7 +1798,7 @@ Socket timeout
--------------
The timeout of the connections to egg and configuration servers can be
configured in the buildout section. Its value is configured in seconds.
configured in the buildout section. Its value is configured in seconds::
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -1821,8 +1820,8 @@ configured in the buildout section. Its value is configured in seconds.
op timeout
recipe recipes:debug
If the socket-timeout is not numeric, a warning is issued and the default
timeout of the Python socket module is used.
If the ``socket-timeout`` is not numeric, a warning is issued and the default
timeout of the Python socket module is used::
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -1852,24 +1851,24 @@ As we've seen, when parts are installed, buildout keeps track of files
and directories that they create. When the parts are uninstalled these
files and directories are deleted.
Sometimes more clean up is needed. For example, a recipe might add a
system service by calling chkconfig --add during installation. Later
during uninstallation, chkconfig --del will need to be called to
Sometimes more clean-up is needed. For example, a recipe might add a
system service by calling ``chkconfig --add`` during installation. Later
during uninstallation, ``chkconfig --del`` will need to be called to
remove the system service.
In order to deal with these uninstallation issues, you can register
uninstall recipes. Uninstall recipes are registered using the
'zc.buildout.uninstall' entry point. Parts specify uninstall recipes
using the 'uninstall' option.
``zc.buildout.uninstall`` entry point. Parts specify uninstall recipes
using the ``uninstall`` option.
In comparison to regular recipes, uninstall recipes are much
simpler. They are simply callable objects that accept the name of the
part to be uninstalled and the part's options dictionary. Uninstall
recipes don't have access to the part itself since it maybe not be
able to be instantiated at uninstallation time.
recipes don't have access to the part itself since it may be
impossible to instantiate at uninstallation time.
Here's a recipe that simulates installation of a system service, along
with an uninstall recipe that simulates removing the service.
with an uninstall recipe that simulates removing the service::
>>> write(sample_buildout, 'recipes', 'service.py',
... """
......@@ -1897,7 +1896,7 @@ with an uninstall recipe that simulates removing the service.
To use these recipes we must register them using entry points. Make
sure to use the same name for the recipe and uninstall recipe. This is
required to let buildout know which uninstall recipe goes with which
recipe.
recipe::
>>> write(sample_buildout, 'recipes', 'setup.py',
... """
......@@ -1915,7 +1914,7 @@ recipe.
... setup(name="recipes", entry_points=entry_points)
... """)
Here's how these recipes could be used in a buildout:
Here's how these recipes could be used in a buildout::
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -1928,7 +1927,7 @@ Here's how these recipes could be used in a buildout:
... script = /path/to/script
... """)
When the buildout is run the service will be installed
When the buildout is run the service will be installed::
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
......@@ -1937,14 +1936,14 @@ When the buildout is run the service will be installed
chkconfig --add /path/to/script
The service has been installed. If the buildout is run again with no
changes, the service shouldn't be changed.
changes, the service shouldn't be changed::
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Updating service.
Now we change the service part to trigger uninstallation and
re-installation.
re-installation::
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -1965,7 +1964,7 @@ re-installation.
Installing service.
chkconfig --add /path/to/a/different/script
Now we remove the service part, and add another part.
Now we remove the service part, and add another part::
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -1993,7 +1992,7 @@ recipe before they are deleted.
For example, here's an uninstallation recipe that simulates backing up
a directory before it is deleted. It is designed to work with the
mkdir recipe introduced earlier.
``mkdir`` recipe introduced earlier::
>>> write(sample_buildout, 'recipes', 'backup.py',
... """
......@@ -2005,9 +2004,9 @@ mkdir recipe introduced earlier.
... % (path, size))
... """)
It must be registered with the zc.buildout.uninstall entry
point. Notice how it is given the name 'mkdir' to associate it with
the mkdir recipe.
It must be registered with the ``zc.buildout.uninstall`` entry
point. Notice how it is given the name ``mkdir`` to associate it with
the ``mkdir`` recipe::
>>> write(sample_buildout, 'recipes', 'setup.py',
... """
......@@ -2026,7 +2025,7 @@ the mkdir recipe.
... setup(name="recipes", entry_points=entry_points)
... """)
Now we can use it with a mkdir part.
Now we can use it with a mkdir part::
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -2042,7 +2041,7 @@ Now we can use it with a mkdir part.
... recipe = recipes:debug
... """)
Run the buildout to install the part.
Run the buildout to install the part::
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
......@@ -2052,7 +2051,7 @@ Run the buildout to install the part.
Installing debug.
recipe recipes:debug
Now we remove the part from the configuration file.
Now we remove the part from the configuration file::
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -2065,7 +2064,7 @@ Now we remove the part from the configuration file.
... """)
When the buildout is run the part is removed, and the uninstall recipe
is run before the directory is deleted.
is run before the directory is deleted::
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
......@@ -2076,7 +2075,7 @@ is run before the directory is deleted.
recipe recipes:debug
Now we will return the registration to normal for the benefit of the
rest of the examples.
rest of the examples::
>>> write(sample_buildout, 'recipes', 'setup.py',
... """
......@@ -2111,7 +2110,6 @@ The following options are supported:
-t socket_timeout
Specify the socket timeout in seconds.
-v
......@@ -2161,7 +2159,7 @@ which is equivalent to::
Options and assignments can be given in any order.
Here's an example:
Here's an example::
>>> write(sample_buildout, 'other.cfg',
... """
......@@ -2177,7 +2175,7 @@ Here's an example:
... """)
Note that we used the installed buildout option to specify an
alternate file to store information about installed parts.
alternate file to store information about installed parts::
>>> print_(system(buildout+' -c other.cfg debug:op1=foo -v'), end='')
Develop: '/sample-buildout/recipes'
......@@ -2186,11 +2184,11 @@ alternate file to store information about installed parts.
op1 foo
recipe recipes:debug
Here we used the -c option to specify an alternate configuration file,
and the -v option to increase the level of logging from the default,
WARNING.
Here we used the ``-c`` option to specify an alternate configuration file,
and the ``-v`` option to increase the level of logging from the default,
*WARNING*.
Options can also be combined in the usual Unix way, as in:
Options can also be combined in the usual Unix way, as in::
>>> print_(system(buildout+' -vcother.cfg debug:op1=foo'), end='')
Develop: '/sample-buildout/recipes'
......@@ -2199,17 +2197,17 @@ Options can also be combined in the usual Unix way, as in:
op1 foo
recipe recipes:debug
Here we combined the -v and -c options with the configuration file
name. Note that the -c option has to be last, because it takes an
argument.
Here we combined the ``-v`` and ``-c`` options with the configuration file
name. Note that the ``-c`` option has to be last, because it takes an
argument::
>>> os.remove(os.path.join(sample_buildout, 'other.cfg'))
>>> os.remove(os.path.join(sample_buildout, '.other.cfg'))
The most commonly used command is 'install' and it takes a list of
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
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',
... """
......@@ -2290,7 +2288,7 @@ the buildout in the usual way:
path = /sample-buildout/d3
recipe = recipes:mkdir
Now we'll update our configuration file:
Now we'll update our configuration file::
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -2315,7 +2313,7 @@ Now we'll update our configuration file:
... x = 1
... """)
and run the buildout specifying just d3 and d4:
and run the buildout specifying just ``d3`` and ``d4``::
>>> print_(system(buildout+' install d3 d4'), end='')
Develop: '/sample-buildout/recipes'
......@@ -2342,10 +2340,11 @@ and run the buildout specifying just d3 and d4:
d parts
d recipes
Only the d3 and d4 recipes ran. d3 was removed and data3 and data2-extra
Only the ``d3`` and ``d4`` recipes ran.
``d3`` was removed and ``data3`` and ``data2-extra``
were created.
The .installed.cfg is only updated for the recipes that ran:
The ``.installed.cfg`` is only updated for the recipes that ran::
>>> cat(sample_buildout, '.installed.cfg')
... # doctest: +NORMALIZE_WHITESPACE
......@@ -2382,11 +2381,12 @@ The .installed.cfg is only updated for the recipes that ran:
path = /sample-buildout/data2-extra
recipe = recipes:mkdir
Note that the installed data for debug, d1, and d2 haven't changed,
because we didn't install those parts and that the d1 and d2
Note that the installed data for ``debug``, ``d1``, and ``d2`` haven't
changed,
because we didn't install those parts, and that the ``d1`` and ``d2``
directories are still there.
Now, if we run the buildout without the install command:
Now, if we run the buildout without the install command::
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
......@@ -2401,8 +2401,8 @@ Now, if we run the buildout without the install command:
Updating d3.
Updating d4.
We see the output of the debug recipe and that data2 was created. We
also see that d1 and d2 have gone away:
We see the output of the debug recipe, and that ``data2`` was created. We
also see that ``d1`` and ``d2`` have gone away::
>>> ls(sample_buildout)
- .installed.cfg
......@@ -2423,9 +2423,9 @@ also see that d1 and d2 have gone away:
Alternate directory and file locations
--------------------------------------
The buildout normally puts the bin, eggs, and parts directories in the
directory in the directory containing the configuration file. You can
provide alternate locations, and even names for these directories.
The buildout normally puts the ``bin``, ``eggs``, and ``parts`` directories in
the directory in the directory containing the configuration file. You can
provide alternate locations, and even names for these directories::
>>> alt = tmpdir('sample-alt')
......@@ -2465,7 +2465,7 @@ provide alternate locations, and even names for these directories.
>>> ls(alt, 'developbasket')
- recipes.egg-link
You can also specify an alternate buildout directory:
You can also specify an alternate buildout directory::
>>> rmdir(alt)
>>> alt = tmpdir('sample-alt')
......@@ -2513,7 +2513,7 @@ log-format
allows an alternate logging for mat to be specified
We've already seen the log level and verbosity. Let's look at an example
of changing the format:
of changing the format::
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -2531,7 +2531,7 @@ than the logger name.
We've also illustrated, with a contrived example, that the log level
can be a numeric value and that the verbosity can be specified in the
configuration file. Because the verbosity is subtracted from the log
level, we get a final log level of 20, which is the INFO level.
level, we get a final log level of 20, which is the INFO level::
>>> print_(system(buildout), end='')
INFO Develop: '/sample-buildout/recipes'
......@@ -2541,9 +2541,9 @@ Predefined buildout options
Buildouts have a number of predefined options that recipes can use
and that users can override in their configuration files. To see
these, we'll run a minimal buildout configuration with a debug logging
level. One of the features of debug logging is that the configuration
database is shown.
these, we'll run a minimal buildout configuration with a ``debug`` logging
level. One of the features of ``debug`` logging is that the configuration
database is shown::
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -2593,18 +2593,19 @@ command-line assignments. We've discussed most of these options
already, but let's review them and touch on some we haven't discussed:
allow-hosts
On some environments the links visited by `zc.buildout` can be forbidden by
paranoid firewalls. These URLs might be in the chain of links visited by
`zc.buildout` as defined by buildout's `find-links` option, or as defined
by various eggs in their `url`, `download_url`, `dependency_links` metadata.
On some environments the links visited by ``zc.buildout`` can be forbidden
by paranoid firewalls. These URLs might be in the chain of links visited
by ``zc.buildout`` as defined by buildout's ``find-links`` option, or as
defined by various eggs in their ``url``, ``download_url``,
``dependency_links`` metadata.
The fact that package_index works like a spider and might visit links and
go to other locations makes this even harder.
The fact that ``package_index`` works like a spider and might visit links
and go to other locations makes this even harder.
The `allow-hosts` option provides a way to prevent this, and
works exactly like the one provided in `easy_install`.
The ``allow-hosts`` option provides a way to prevent this, and
works exactly like the one provided in ``easy_install``.
You can provide a list of allowed host, together with wildcards::
You can provide a list of allowed hosts, together with wildcards::
[buildout]
...
......@@ -2613,7 +2614,7 @@ allow-hosts
*.python.org
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
By default, the buildout will choose the best match for a given requirement
......@@ -2645,7 +2646,7 @@ eggs-directory
find-links
You can specify more locations to search for distributions using the
`find-links` option. All locations specified will be searched for
``find-links`` option. All locations specified will be searched for
distributions along with the package index as described before.
Locations can be urls::
......@@ -2666,7 +2667,7 @@ find-links
...
find-links = /some/path/someegg-1.0.0-py2.3.egg
Any number of locations can be specified in the `find-links` option::
Any number of locations can be specified in the ``find-links`` option::
[buildout]
...
......@@ -2762,9 +2763,9 @@ verbosity
Creating new buildouts and bootstrapping
----------------------------------------
If zc.buildout is installed, you can use it to create a new buildout
with it's own local copies of zc.buildout and setuptools and with
local buildout scripts.
If ``zc.buildout`` is installed, you can use it to create a new buildout
with its own local copies of ``zc.buildout`` and ``setuptools`` and with
local buildout scripts::
>>> sample_bootstrapped = tmpdir('sample-bootstrapped')
......@@ -2778,15 +2779,15 @@ local buildout scripts.
Creating directory '/sample-bootstrapped/develop-eggs'.
Generated script '/sample-bootstrapped/bin/buildout'.
Note that a basic setup.cfg was created for us. This is because we
provided an 'init' argument. By default, the generated
``setup.cfg`` is as minimal as it could be:
Note that a basic ``setup.cfg`` was created for us. This is because we
provided an ``init`` argument. By default, the generated
``setup.cfg`` is as minimal as can be::
>>> cat(sample_bootstrapped, 'setup.cfg')
[buildout]
parts =
We also get other buildout artifacts:
We also get other buildout artifacts::
>>> ls(sample_bootstrapped)
d bin
......@@ -2803,17 +2804,17 @@ We also get other buildout artifacts:
- setuptools-0.7-py2.3.egg
- zc.buildout-1.0-py2.3.egg
(We list both the eggs and develop-eggs directories because the
buildout or setuptools egg could be installed in the develop-eggs
(We list both the ``eggs`` and ``develop-eggs`` directories because the
buildout or setuptools egg could be installed in the ``develop-eggs``
directory if the original buildout had develop eggs for either
buildout or setuptools.)
Note that the buildout script was installed but not run. To run
the buildout, we'd have to run the installed buildout script.
If we have an existing buildout that already has a buildout.cfg, we'll
normally use the bootstrap command instead of init. It will complain
if there isn't a configuration file:
If we have an existing buildout that already has a ``buildout.cfg``, we'll
normally use the ``bootstrap`` command instead of ``init``. It will complain
if there isn't a configuration file::
>>> sample_bootstrapped2 = tmpdir('sample-bootstrapped2')
......@@ -2839,9 +2840,9 @@ if there isn't a configuration file:
Creating directory '/sample-bootstrapped2/develop-eggs'.
Generated script '/sample-bootstrapped2/bin/buildout'.
Similarly, if there is a configuration file and we use the init
Similarly, if there is a configuration file and we use the ``init``
command, we'll get an error that the configuration file already
exists:
exists::
>>> print_(system(buildout
... +' -c'+os.path.join(sample_bootstrapped, 'setup.cfg')
......
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