Personal tools
You are here: Home Documentation Tutorials Introduction to zc.buildout Recipes to install eggs, scripts and custom interpreters

Recipes to install eggs, scripts and custom interpreters

Commonly used recipes
Jim Fulton's tutorial for using buildout, originally given at DZUG 2007
Page 9 of 17.

zc.recipe.egg

Set of recipes for:

  • installing eggs
  • generating scripts
  • custom egg compilation
  • custom interpreters

See: http://www.python.org/pypi/zc.recipe.egg.

Installing eggs

[buildout]
parts = some-eggs

[some-eggs]
recipe = zc.recipe.egg:eggs
eggs = docutils
       ZODB3 <=3.8
       zope.event
handout

The eggs option accepts one or more distribution requirements. Because requirements may contain spaces, each requirement must be on a separate line. We used the eggs option to specify the eggs we want.

Any dependencies of the named eggs will also be installed.

Installing scripts

[buildout]
parts = rst2

[rst2]
recipe = zc.recipe.egg:scripts
eggs = zc.rst2
handout

If any of the named eggs have console_script entry points, then scripts will be generated for the entry points.

If a distribution doesn't use setuptools, it may not declare it's entry points. In that case, you can specify entry points in the recipe data.

Script initialization

[buildout]
develop = codeblock
parts = rst2
find-links = http://sourceforge.net/project/showfiles.php?group_id=45693

[rst2]
recipe = zc.recipe.egg
eggs = zc.rst2
       codeblock
initialization =
    sys.argv[1:1] = (
      's5 '
      '--stylesheet ${buildout:directory}/zope/docutils.css '
      '--theme-url file://${buildout:directory}/zope'
      ).split()
scripts = rst2=s5
handout

In this example, we omitted the recipe entry point entry name because the scripts recipe is the default recipe for the zc.recipe.egg egg.

The initialization option lets us specify some Python code to be included.

We can control which scripts get installed and what their names are with the scripts option. In this example, we've used the scripts option to request a script named s5 from the rst2 entry point.

Custom interpreters

The script recipe allows an interpreter script to be created.

[buildout]
parts = mypy

[mypy]
recipe = zc.recipe.egg:script
eggs = zope.component
interpreter = py

This will cause a bin/py script to created.

handout

Custom interpreters can be used to get an interactive Python prompt with the specified eggs and and their dependencies on sys.path.

You can also use custom interpreters to run scripts, just like you would with the usual Python interpreter. Just call the interpreter with the script path and arguments, if any.