Skip to main content

A buildout extension to move non-used eggs to a specified directory

Project description

Buildout Eggscleaner

Introduction

The buildout.eggscleaner extensions can be used to ensure your egg directory only contains ‘used’ eggs. The extension can report, but also move unused eggs to a specified directory.

Installation

Eggscleaner is a buildout extensions, can add it like so

[buildout]
extensions =
        buildout.eggscleaner

Options

old-eggs-directory

The directory you want buildout.eggscleaner to move your unused eggs to. Should an excact egg already exist, we remove the one in the ‘’used’’ eggs directory

Example

[buildout]
extensions =
        buildout.eggscleaner
old-eggs-directory = ${buildout:directory}/old-eggs/

Tested with

zc.buildout: 1.4.3, 1.5.1, 1.5.2, 1.6.0, 2.2.1 python: 2.4.6, 2.6.8

Working with other extensions

I looked at how buildout.dumppickedversions works and made this extension work in a similar manner. This extension will run alongside that one perfectly well.

Example outputs

Nothing do

*************** BUILDOUT EGGSCLEANER ****************
No unused eggs in eggs directory
*************** /BUILDOUT EGGSCLEANER ****************

Moving eggs

*************** BUILDOUT EGGSCLEANER ****************
Moved unused egg: webcouturier.dropdownmenu-2.3-py2.6.egg
Moved unused egg: collective.uploadify-1.0-py2.6.egg
Moved unused egg: collective.simplesocial-1.6-py2.6.egg
Moved unused egg: collective.autopermission-1.0b2-py2.6.egg
*************** /BUILDOUT EGGSCLEANER ****************

Reporting

*************** BUILDOUT EGGSCLEANER ****************
Don't have a 'old-eggs-directory' set, only reporting
Can add it by adding 'old-eggs-directory = ${buildout:directory}/old-eggs' to your [buildout]
Found unused egg: webcouturier.dropdownmenu-2.3-py2.6.egg
Found unused egg: plone.recipe.command-1.1-py2.6.egg
Found unused egg: collective.uploadify-1.0-py2.6.egg
Found unused egg: Products.DocFinderTab-1.0.5-py2.6.egg
Found unused egg: collective.simplesocial-1.6-py2.6.egg
Found unused egg: collective.autopermission-1.0b2-py2.6.egg
Found unused egg: Products.Clouseau-1.0-py2.6.egg
*************** /BUILDOUT EGGSCLEANER ****************

Detailed Documentation

Let’s create an egg to use it in our tests:

>>> mkdir('myegg')
>>> write('myegg', 'setup.py',
... '''
... from setuptools import setup
... setup(name='myegg', version='1.0',)
... ''')
>>> write('myegg', 'README', '')
>>> print system(buildout+' setup myegg bdist_egg'), # doctest: +ELLIPSIS
Running setup script 'myegg/setup.py'.
...

>>> mkdir('baregg')
>>> write('baregg', 'setup.py',
... '''
... from setuptools import setup
... setup(name='baregg', version='1.0',)
... ''')
>>> write('baregg', 'README', '')
>>> print system(buildout+' setup baregg bdist_egg'), # doctest: +ELLIPSIS
Running setup script 'baregg/setup.py'.
...

Now let’s create a buildout to install the egg and to use buildout.eggscleaner:

>>> write('buildout.cfg',
... '''
... [buildout]
... index = http://pypi.python.org/simple
... extensions = buildout.eggscleaner
... eggs-directory = ${buildout:directory}/eggs
... parts = foo
... find-links += %s
... [foo]
... recipe = zc.recipe.egg
... eggs = myegg
... ''' % join('myegg', 'dist'))

Running the buildout will print information about unused eggs:

>>> print system(buildout), # doctest: +ELLIPSIS
Getting distribution for 'buildout.eggscleaner'.
...

When we only want to report unused eggs we omit the ‘’’old-eggs-directory’’’ option.

>>> write('buildout.cfg',
... '''
... [buildout]
... index = http://pypi.python.org/simple
... extensions = buildout.eggscleaner
... eggs-directory = ${buildout:directory}/eggs
... parts = foo
... find-links += %s
... [foo]
... recipe = zc.recipe.egg
... eggs = baregg
... ''' % join('baregg', 'dist'))
>>> print system(buildout) # doctest:+ELLIPSIS
Uninstalling foo.
Installing foo.
Getting distribution for 'baregg'.
Got baregg 1.0.
*************** BUILDOUT EGGSCLEANER ****************
Don't have a 'old-eggs-directory' set, only reporting
Can add it by adding 'old-eggs-directory = ${buildout:directory}/old-eggs' to your [buildout]
...
Found unused egg: myegg...
*************** /BUILDOUT EGGSCLEANER ****************
<BLANKLINE>

Check that indeed nothing has been moved nor deleted:

>>> assert 'myegg' in  ''.join(os.listdir('eggs'))

If we want to move unused eggs, we just add an old-eggs-directory option and give a directory target:

>>> write('buildout.cfg',
... '''
... [buildout]
... index = http://pypi.python.org/simple
... extensions = buildout.eggscleaner
... eggs-directory = ${buildout:directory}/eggs
... old-eggs-directory = ${buildout:directory}/old-eggs
... parts = foo
... find-links += %s
... [foo]
... recipe = zc.recipe.egg
... eggs = baregg
... ''' % join('baregg', 'dist'))

>>> print system(buildout) # doctest:+ELLIPSIS
Updating foo.
*************** BUILDOUT EGGSCLEANER ****************
...
Moved unused egg: myegg...
*************** /BUILDOUT EGGSCLEANER ****************
<BLANKLINE>

Check that indeed ‘myegg’ has been moved:

>>> assert 'myegg' not in  ''.join(os.listdir('eggs')), 'myegg has not been moved out of egg dir'
>>> assert 'myegg' in  ''.join(os.listdir('old-eggs')), 'myegg has not been moved to old-egg dir'

And baregg is still present:

>>> assert 'baregg' in  ''.join(os.listdir('eggs')), 'baregg is not present in egg dir'

Contributors

  • Peter Uittenbroek, Author

Change history

0.1.7 (2014-07-18)

  • Bump version to fix previous release mess

0.1.6 (unreleased by mistake)

  • Make eggscleaner run under windows [anton-tagunov]

  • Make eggscleaner work with latests buildout (2.2.1) [anton-tagunov]

  • Only run eggscleaner when eggs-directory is local [thepjot]

0.1.5 (2012-08-17)

  • Redid documentation [thepjot]

  • Added doctest [thepjot]

0.1 (internal release)

  • Creation [thepjot]

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

buildout.eggscleaner-0.1.7.zip (15.8 kB view details)

Uploaded Source

File details

Details for the file buildout.eggscleaner-0.1.7.zip.

File metadata

File hashes

Hashes for buildout.eggscleaner-0.1.7.zip
Algorithm Hash digest
SHA256 e88a5929afd22d7b8b6ae932f12bfbe3c23294431c18cd7015e5c6200aef024d
MD5 09faef8c498742bdeacac9d83f887e75
BLAKE2b-256 1b4a82df40613c58d939d8bf7c3e25aefc6ca5b8ce9c6fa87f5b771c29af5d6d

See more details on using hashes here.

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