Skip to main content

zc.buildout recipes to compile and install software or python packages and generate scripts or configuration files.

Project description

Introduction

The egg has those entry point:

  • egg: install python eggs / packages ‘setuptoolisables’

The reasons why i have rewrite yet another buildout recipes builder are:

  • Support for downloading stuff

  • Do not rely on easy_install dependency system

  • Support on the fly patchs for eggs and other distribution.

  • Support multiple hooks at each stage of the build system.

  • Robust offline mode

  • We like pypi, but offer a mode to scan for eggs without need to check the index,

  • Support malformed or not indexed distributions. In other terms, we provide an url, and the recipe builds it, that’s all.

  • Support automaticly minitage dependencies and rpath linking.

You can browse the code on minitage’s following resources:

You can migrate your buldouts without any effort with buildout.minitagificator:

minitage.recipe.egg

Abstract

  • This recipe intends to install eggs and python software

  • Its heavilly inspired by zc.recipe.eggs* and try to completly replace it whereas be API compatbile.

  • You can use it in conjunction with the buildout.minitagificator extension which monkey patch zc.buildout to use minitage recipes.

  • The recipe has a robust offline mode.

  • What we can do that zc.recipe.egg wouldnt do, either at all or not in the way we want to:

    • Don’t rely on easy_install to detect and install dependencies, that can lead to versions inccompatibilities

    • Handles and preserve eggs extra dependencies

    • Apply specific patches for eggs based on their name and them generate a specific egg with a specific version, burried in the buildout via the “versions”.

    • Make the minitage environnent comes into the environment when building if any, making compilation steps easy if you have declared and build the neccessary dependencies.

    • Be able to install unindexed at all stuff, just by precising url to install, that can be even an automatic checkout from any repository.

    • You have hooks to play with the recipe, if it doesnt fit exactly to your need, you can hook for a specific egg at any point of the build.

    • Check md5 on indexes which append md5 fragments on urls, to verify package integrity

  • If you need scripts generation, just use the minitage.recipe:scripts recipe, it’s a specialized recipe of this one. Its use is similar, with just a bunch more options.

Specific options

Please look for options at : http://pypi.python.org/pypi/minitage.recipe.common#options-shared-by-all-the-recipes

  • urls

    See the shared options for more information on how to set them. This is how to specify a distrbituion with is not indexed on pypi and where find-links dance can not work. This is also how to specify to install something from svn:

    urls = http://foo.tld/my_super_egg|svn|666 # checkout and install this egg from svn at revision 666
  • eggs

    A list of egg requirements to install without the version specs bit.:

    Plone
    lxml
  • EGGNAME-patch-options

    patch binary to use for this egg

  • EGGNAME-patch-binary

    Options to give to the patch program when applying patches for this egg

  • EGGNAME-patches

    Specific patchs for an egg name to apply at install time:

    Django-patches = ${buildout:directory}/foo.patch
  • EGGNAME-UNAME-patches

    Same as previous, but will just occurs on this UNAME specifc OS (linux|freebsd|darwin) Specific patchs for an egg name to apply at install time:

    Django-linux-patches = ${buildout:directory}/foo.patch
  • EGGNAME-VERSION-patches

    patches apply only on this specific version

  • EGGNAME-VERSION-UNAME-patches

    patches apply only on this specific version

  • versions

    Default to buildout:versions. versions part to use to pin the version of the installed eggs. It defaults to buildout’s one

  • index

    Custom eggs index (not pypi/simple). It defaults to buildout’s one

  • find-links

    additionnal links vhere we can find eggs. It defaults to buildout’s one

  • extra-paths

    Extra paths to include in a generated script or at build time.

  • relative-paths

    If set to true, then egg paths will be generated relative to the script path. This allows a buildout to be moved without breaking egg paths. This option can be set in either the script section or in the buildout section.

  • Specifying the python to use, two ways:

    • python

      The name of a section to get the Python executable from. If not specified, then the buildout python option is used. The Python executable is found in the executable option of the named section. It defaults to buildout’s one

    • executable

      path to the python executable to use.

  • hooks

    A hook is in the form /path/to/hook:CALLABLE:

    myhook=${buildout:directory}/toto.py:foo

    Where we have toto.py:

    def foo(options, buildout):
        return 'Hourray'

    The complete possible hooks list:

    • post-download-hook

      hook executed after each download

    • post-checkout-hook

      hook executed after each checkout

    • EGGNAME-pre-setup-hook

      hook executed before running the setup.py dance

    • EGGNAME-post-setup-hook

      hook executed after running the setup.py dance

Patches

  • When you use patches for an egg, his version will become

    Django-1.0-final -> Django-1.0-final-ZMinitagePatched-$PatchesNamesComputation$
  • This name have some Z* inside to make some precedence on other eggs at the same version. (see setuptools naming scheme)

  • After that the egg is created, the buildout is backed up and patched to point to this version

  • Thus, you can have in your common egg cache, this egg for your specific project, and the classical one for others. This can be interessant, for example, for the zope RelStorage patch to apply on ZODB code.

Detailled documentation

Let’s create a buildout configuration file:

>>> rmdir(tempdir)
>>> mkdir(tempdir)
>>> cd(tempdir)
>>> a = [mkdir(d) for d in ('eggs', 'develop-eggs', 'bin', 'src')]
>>> install_develop_eggs(['minitage.recipe'])
>>> install_eggs_from_pathes(['zc.buildout'], sys.path)
>>> touch('buildout.cfg')
>>> sh('buildout -o bootstrap')
buildout -o bootstrap...
>>> index_url = start_server(os.path.sep.join(tempdir))

Initializing test env.

>>> if not os.path.exists('foo'):
...     mkdir('foo')
... else:
...     rmdir(foo)
...     mkdir('foo')
>>> touch('foo/setup.py', data="""
... from setuptools import setup
... setup(name='foo', version='1.0')
...
... """)
>>> touch('foo/toto.py', data="""
... def f():
...     print "foo"
...
... """)
>>> noecho = [os.remove(d) for d in os.listdir('.') if '.tar.gz' in d]
>>> os.chdir('foo')
>>> sh('python setup.py sdist')
p...
>>> touch('setup.py', data="""
... from setuptools import setup
... setup(name='foo', version='2.0')
...
... """)
>>> sh('python setup.py sdist')
p...
>>> noecho = [shutil.copy(os.path.join('dist', d), os.path.join('..', d)) for d in os.listdir('dist')]
>>> os.chdir('..')
>>> touch('patch', data="""
... --- foo.old/setup.py    2009-04-18 13:36:40.199680168 +0200
... +++ foo/setup.py        2009-04-18 13:26:12.307692349 +0200
... @@ -2,3 +2,7 @@
...  from setuptools import setup
...  setup(name='foo', version='2.0')
...
... +
... +
... +print 'patched'
... +
... """)

Installing eggs with a patch

Patching is easy, just put your patches in YouEgg-patches.

>>> data = """
... [versions]
... foo=1.0
... [buildout]
... download-cache=${buildout:directory}
... parts =
...     part
... [part]
... recipe=minitage.recipe.egg
... find-links=%(index)s
... foo-patches = ${buildout:directory}/patch
... eggs=foo
... """%{'index': index_url}
>>> touch('buildout.cfg', data=data)
>>> sh('bin/buildout install part')
bin/buildout install part...
minitage.recipe: Running patch -t -Np0 < /tmp/buildout.test/minitage/eggs/patches/foo/1.0/patch_d96115b00b41e282469f73708c68bdaf/patch
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|
|--- foo.old/setup.py...
|+++ foo/setup.py...
--------------------------
No file to patch.  Skipping patch.
1 out of 1 hunk ignored
minitage.recipe: Installation error.
minitage.recipe: Message was:
        ('Failed', 'patch -t -Np0 < /tmp/buildout.test/minitage/eggs/patches/foo/1.0/patch_d96115b00b41e282469f73708c68bdaf/patch')...

Oups, the patch level ! .

>>> data = """\
... [versions]
... foo=1.0
... [buildout]
... download-cache=${buildout:directory}
... parts =
...     part
... [part]
... recipe=minitage.recipe.egg
... find-links=%(index)s
... eggs=foo
... foo-patches = ${buildout:directory}/patch
... foo-patch-options = -Np1
... """%{'index': index_url}
>>> touch('buildout.cfg', data=data)
>>> sh('bin/buildout -vvvvv install part')
b...
minitage.recipe: Pinning custom egg version in buildout, trying to write the configuration
minitage.recipe: CREATING buildout backup in /tmp/buildout.test/buildout.cfg.before.fixed_version.bak...
minitage.recipe: All egg dependencies seem to be installed!...

Now that we have it, try to resintall.

>>> sh('bin/buildout -vvvvv install part')
bin/buildout...
minitage.recipe: We have the distribution that satisfies 'foo==1.0-ZMinitagePatched-Patch'.
minitage.recipe: Pinning custom egg version in buildout, trying to write the configuration
minitage.recipe: Version already pinned, nothing has been wroten...

In all cases our buildout is patched.

>>> cat('buildout.cfg')
[versions]
foo...=...1.0-ZMinitagePatched-Patch...

Offline and newest modes

We have ways to make buildout not download the latest versions found on indexes and be very conservative on what we akready got local.

Removing the version bit, but choosing to be non newest will make buildout not to install the new foo-2.0 version.

>>> data = """\
... [versions]
... [buildout]
... download-cache=${buildout:directory}
... parts =
...     part
... versions = versions
... [t]
... recipe=minitage.recipe.egg
... find-links=%(index)s
... eggs=foo
... """%{'index': index_url}
>>> touch('buildout.cfg', data=data)
>>> sh('bin/buildout -Nvvvvv install t')
b...
minitage.recipe: Installing python egg(s).
minitage.recipe: Picked: foo = 1.0-ZMinitagePatched-Patch
minitage.recipe: All egg dependencies seem to be installed!...

Idem in offline mode.

>>> sh('bin/buildout -ovvvvv install t')
b...
minitage.recipe: Picked: foo = 1.0-ZMinitagePatched-Patch
minitage.recipe: All egg dependencies seem to be installed!...

But then, going online/newest will trigger the installation of the 2.0 egg.

>>> sh('bin/buildout -nvvvvv install t')
b...
Location : /tmp/buildout.test/eggs/foo-2.0-py...egg
minitage.recipe: Got foo 2.0.
minitage.recipe: Picked: foo = 2.0
minitage.recipe: All egg dependencies seem to be installed!...

Installing eggs from an url, the specific way

It s possible to install an egg from a known url without any indexing system.

>>> noecho = [remove(os.path.join('eggs', egg)) for egg in os.listdir('eggs') if 'foo' in egg]
>>> data = """
... [buildout]
... download-cache=${buildout:directory}
... parts =
...     part
... [part]
... recipe=minitage.recipe.egg
... urls=file://${buildout:directory}/foo-1.0.tar.gz
... """
>>> touch('buildout.cfg', data=data)
>>> sh('bin/buildout -vvvvv install part')
bin/buildout -vvvvv install part...
minitage.recipe: We found a source distribution for 'foo==1.0' in '/tmp/buildout.test/minitage/eggs/foo-1.0.tar.gz'...
minitage.recipe: Unpacking in /tmp/...
minitage.recipe: Pinning custom egg version in buildout, trying to write the configuration
minitage.recipe: CREATING buildout backup in /tmp/buildout.test/buildout.cfg.before.fixed_version.bak...

As we are installing from an url, we must pin the version to be sure to use this egg, even if we have some other similar egg on index or find-links.

>>> cat('buildout.cfg')
<BLANKLINE>
[buildout]
download-cache=${buildout:directory}
parts =
    part
versions = versions
[part]
recipe=minitage.recipe.egg
urls=file://${buildout:directory}/foo-1.0.tar.gz...
[versions]
foo...=...1.0...

See that a versions section, and a key in the buildout section have been added.

If we try to install a newer version, via an url, it will work, even if the version is pinned.

>>> data = """
... [buildout]
... download-cache=${buildout:directory}
... parts =
...     part
... [part]
... recipe=minitage.recipe.egg
... urls=file://${buildout:directory}/foo-2.0.tar.gz
... """
>>> touch('buildout.cfg', data=data)
>>> sh('bin/buildout -vvvvv install part')
b...
>>> cat('buildout.cfg')
<BLANKLINE>
[buildout]
download-cache=${buildout:directory}
parts =
    part
versions = versions
[part]
recipe=minitage.recipe.egg
urls=file://${buildout:directory}/foo-2.0.tar.gz...
[versions]
foo = 2.0...

File urls work in offline mode.

>>> noecho = [remove(os.path.join('eggs', egg)) for egg in os.listdir('eggs') if 'foo' in egg]
>>> [egg for egg in os.listdir('eggs') if 'foo' in egg]
[]
>>> sh('bin/buildout -o install part')
b...
>>> [egg for egg in os.listdir('eggs') if 'foo' in egg]
['foo-2.0-py...egg']

If we try to rebuild the egg, we cannot, as the same egg is already built. This is to prevent rebuilding triggered by buildout each time we launch it, and also to delete already good versions present in the cache.

>>> sh('bin/buildout -ovvvvv install part')
b...
minitage.recipe: If you want to rebuild, please do 'rm -rf /tmp/buildout.test/eggs/foo-2.0-py...egg'...

Pypi md5 check support

Pypi has the habit to append an md5 fragment to its egg urls, we ll use it to check the already present distribution files in the cache.

>>> dlcache = os.path.join('minitage', 'eggs')
>>> noecho = [(egg, remove(os.path.join(dlcache, egg))) for egg in os.listdir(dlcache) if 'developer' in egg]
>>> data = """
... [versions]
... mr.developer=0.15
... [buildout]
... versions = versions
... download-cache=${buildout:directory}
... parts =
...     part
... [part]
... recipe = minitage.recipe.egg
... eggs=mr.developer
... """
>>> touch('buildout.cfg', data=data)
>>> sh('bin/buildout install part')
b...
>>> egg = [egg for egg in os.listdir(dlcache) if 'mr.developer' in egg][0]
>>> egg
'mr.developer-0.15.zip'

Resetting the file contents.

>>> touch(os.path.join(dlcache, egg), data='')

Deleting the installed egg.

>>> noecho = [(egg, remove(os.path.join('eggs', egg))) for egg in os.listdir('eggs') if 'developer' in egg]

Trying to reinstall.

>>> sh('bin/buildout -vvvvv install part')
b...
minitage.recipe: Searching cache at /tmp/buildout.test/minitage/eggs
minitage.recipe: MD5SUM mismatch for /tmp/buildout.test/minitage/eggs/mr.developer-0.15.zip: Good:796babbb65820f6c052141cae1fb3e8d != Bad:d41d8cd98f00b204e9800998ecf8427e
Backuping the old file but re download it!
A bakcup will be made in /tmp/buildout.test/minitage/eggs/mr.developer-0.15.zip.md5sum_mismatch.0.
minitage.recipe: Cache download http://pypi.python.org/packages/source/m/mr.developer/mr.developer-0.15.zip#md5=796babbb65820f6c052141cae1fb3e8d as /tmp/buildout.test/minitage/eggs
minitage.recipe: Downloading http://pypi.python.org/packages/source/m/mr.developer/mr.developer-0.15.zip#md5=796babbb65820f6c052141cae1fb3e8d in /tmp/buildout.test/minitage/eggs/mr.developer-0.15.zip...

Static distribution dev+static urls

You can also install directly from urls. we ll use it to check the already present distribution files in the cache.

>>> data = """
... [versions]
... mr.developer=0.15
... [buildout]
... versions = versions
... download-cache=${buildout:directory}
... parts =
...     part
... [part]
... recipe = minitage.recipe.egg
... eggs=mr.developer
... [a]
... recipe=minitage.recipe.egg
... urls=
...     http://pypi.python.org/packages/source/m/minitage.core/minitage.core-1.0.4.tar.gz#md5=1e30ceabd1b012e33b1d2f327f6609b5
...     http://pypi.python.org/packages/source/m/minitage.paste/minitage.paste-1.1.tar.gz#md5=b9076b78a17f2247f68d232368fcc8f0
... """
>>> touch('buildout.cfg', data=data)
>>> sh('bin/buildout -vvvvvv install a')
b...
Installing a...
minitage.recipe: Downloading http://pypi.python.org/packages/source/m/minitage.core/minitage.core-1.0.4.tar.gz#md5=1e30ceabd1b012e33b1d2f327f6609b5 in /tmp/buildout.test/minitage/eggs/minitage.core-1.0.4.tar.gz_c3e78ea4294cdd0a243fbea6e2aa9757/minitage.core-1.0.4.tar.gz...
minitage.recipe: Downloading http://pypi.python.org/packages/source/m/minitage.paste/minitage.paste-1.1.tar.gz#md5=b9076b78a17f2247f68d232368fcc8f0 in /tmp/buildout.test/minitage/eggs/minitage.paste-1.1.tar.gz_d3403e6128eddb2b99063674ff8105a1/minitage.paste-1.1.tar.gz...
Location : ...
minitage.recipe: All egg dependencies seem to be installed!...

The versions are pinned to use your downloaded stuff

>>> cat('buildout.cfg')
<BLANKLINE>
[versions]
mr.developer=0.15
minitage.core = 1.0.4
minitage.paste = 1.1
[buildout]
versions = versions
download-cache=${buildout:directory}
parts =
    part
[part]
recipe = minitage.recipe.egg
eggs=mr.developer
[a]
recipe=minitage.recipe.egg
urls=
    http://pypi.python.org/packages/source/m/minitage.core/minitage.core-1.0.4.tar.gz#md5=1e30ceabd1b012e33b1d2f327f6609b5
    http://pypi.python.org/packages/source/m/minitage.paste/minitage.paste-1.1.tar.gz#md5=b9076b78a17f2247f68d232368fcc8f0

CHANGELOG

UP

  • ugly bugfix when your egg cache is not on the same partition as the buildout as it make cross device references errors when renaming from sandbox

  • zipped egg bugfix

1.38

  • decorator helper

1.37

  • fix exception mappings when a patch fails

1.36

  • fix tests develop eggs

1.35

  • splitted out from minitage.recipe

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minitage.recipe.egg-1.47.zip (45.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page