Skip to main content

Buildout Garbage Collector

Introduction

The buildout.gc extensions can be used to ensure your egg directory only contains ‘used’ eggs. The extension can report, move unused eggs to a specified directory or just remove egss.

This package is fork of https://github.com/thepjot/buildout.eggscleaner

Installation

Garbase Collector is a buildout extensions, can add it like so

[buildout]
extensions =
        buildout.gc

Options

old-eggs-directory

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

old-eggs-remove

Remove eggs instead of moving

old-eggs-factor

Remove/move eggs directories when number unused eggs less <total_egss> * <factor>. Some times buildout out can be failed and in this case this extension determinate that ALL packages are not used. This parameter prevent removing ALL eggs in this case.

Example

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

Tested with

zc.buildout: 2.xx python: 2.4.6, 2.6.8, 2.7.12, 3.3, 3.5

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

Moving eggs

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

Reporting

Don't have a 'old-eggs-directory' or 'old-eggs-remove' 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

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...
...

>>> 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...
...

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

>>> write('buildout.cfg',
... '''
... [buildout]
... index = http://pypi.python.org/simple
... extensions = buildout.gc
... 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
Installing foo.
Getting distribution for 'myegg'.
...
Don't have a 'old-eggs-directory' or 'old-eggs-remove' set, only reporting
...

When we only want to report unused eggs we omit the old-eggs-directory and old-eggs-remove options.

>>> write('buildout.cfg',
... '''
... [buildout]
... index = http://pypi.python.org/simple
... extensions = buildout.gc
... 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.
Don't have a 'old-eggs-directory' or 'old-eggs-remove' set, only reporting
Can add it by adding 'old-eggs-directory = ${buildout:directory}/old-eggs' to your [buildout]
Found unused egg: myegg...
<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.gc
... 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.
Moved unused egg: myegg...
<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'

If we want to remove unused eggs, we just add an old-eggs-remove option:

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

>>> print_(system(buildout)) # doctest:+ELLIPSIS
Uninstalling foo.
Installing foo.
Getting distribution for 'myegg'.
Got myegg 1.0.
Moved unused egg: baregg...
<BLANKLINE>

Check that indeed ‘baregg’ has been removed:

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

And ‘myegg’ is still present:

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

Contributors

  • Peter Uittenbroek, Author

  • Anton Tagunov

Change history

1.2.dev

  • Fixed incorrect messages after restarting of buildout.

1.0 (2016-01-21)

  • Created public fork

0.1.5 (2012-08-17)

  • Redid documentation [thepjot]

  • Added doctest [thepjot]

0.1 (internal release)

  • Creation [thepjot]

Metadata

Release files for buildout.gc 1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for buildout.gc 1.2
File Size Uploaded Provenance Actions
buildout.gc-1.2.tar.gz 6.6 kB Without provenance Details for buildout.gc-1.2.tar.gz

Release files / buildout.gc-1.2.tar.gz

Download URL buildout.gc-1.2.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b7003132509c8c164d2902710a2626064c6460c02cf008873f8b8d624805e0d3
BLAKE2b-256 checksum
How to use checksums
a466fec0abd4c2503ec1cef72f97bfa1a9ea044621c283fee390c80d83cee76a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for buildout.gc 1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page