Search code examples
pythonpackagebuildoutsetup.py

How do I use zc.buildout and setup.py together?


I use zc.buildout to develop my project and download dependencies (use-site-packages is off).

I want to install my project as a package on a target system before running it. For that I make setup.py.

Do I need to repeat the list of dependencies in setup.py again?


Solution

  • zc.buildout relies on your package setup.py, so if your package has dependencies, list those in the setup.py install_requires list.

    Only list those dependencies in your buildout configuration to pin the versions in a versions section.

    So, installing a simple egg foo that depends on bar and baz:

    [buildout]
    parts = foo
    
    [foo]
    recipe = zc.recipe.egg
    eggs = foo
    

    where setup.py for the foo egg has a install_dependencies = ['bar', 'baz'] entry. Buildout will take care of installing bar and baz for you, without those explicitly being listed.

    Pinning version numbers:

    [buildout]
    parts = foo
    versions = versions
    
    [foo]
    recipe = zc.recipe.egg
    eggs = foo
    
    [versions]
    foo = 1.2.1
    bar = 0.2
    baz = 3.0b1