Developing a new project using zc.buildout (wip)
I'm starting a new project for which I'm using zc.buildout as a build tool so I thought I'd share my setup.
Eclipse setup
I'm gonna use Eclipse with Pydev and Subclipse to develop this project, let's call it Demo Project. I'll probably develop many modules that will share a common namespace, so this would be the way to handle these modules in relation with Eclipse best:
First, create a new Pydev project, named demo.site-trunk. Inside the src folder, create a new python package named demo. This will be my main namespace, I'm gonna have packages named demo.site, demo.layer, demo.form, etc. The __init__.py file should contain the necessary code to declare it as a namespace package.
__import__('pkg_resources').declare_namespace(__name__)
Then create another python package inside the 'demo' package, named, let's say, 'site', to have a demo.site package.
Next I'm gonna share this project and import the entire project it into a new svn trunk, using the Team > Share Project function, to a location similar to: http://svn.mysite.com/svn/demo.portal/trunk/
All the other modules will be created and shared similarly, so that you'll end up with a structure similar to the one for the projects on the svn.zope.org repository. Inside Eclipse the projects can be marked as related, so you can have them open each other and even get autocompletition and autoimport of python resources.
setuptools configuration file
To be able to have these packages available as eggs, a setuptools setup file is needed, something along these lines:#!/usr/bin/env python
from setuptools import setup, find_packages
setup(
name='demo.site',
version='0.1dev',
description = "Demo Project",
license = "ZPL",
keywords = "zope3",
url='',
zip_safe=False,
packages=find_packages('src'),
include_package_data=True,
package_dir = {'':'src'},
namespace_packages=['demo', ],
install_requires = ['setuptools', ],
dependency_links = ['http://download.zope.org/distribution'],
)
It is important to declare the location of the packages and the new namespace, using find_packages and namespace_packages.
Buildout configuration file
[buildout]
develop = .
parts = zope3 data instance
[zope3]
recipe = zc.recipe.zope3checkout
url = svn://svn.zope.org/repos/main/Zope3/trunk
[data]
recipe = zc.recipe.filestorage
[instance]
recipe = zc.recipe.zope3instance
database = data
user = admin:test
eggs = demo.site#egg=demo.site-0.1
setuptools
zcml = demo.site
Bootstrapping the buildout
To complete the buildout you'll need to get the bootstrap.py file from svn.zope.org and run it. This will generate the buildout folder structure. Next, run the buildout with bin/buildout.
TODO: explain how to place eggs from download.zope.org/distribution. How to package an egg (setup bdist_egg), the buildout.cfg file above, links to documentation