How do I add an egg dependency?

You are working in your instance or developing your package and then you discover in Zope3PackageGuide that there is a package you may find usefull, let's say ldappas. How do you intall and register this package? You could use easy_install to download and install the package:

    # always activate the virtual environment
    $ cd ~/myenv
    $ source bin/activate

    $ easy_install ldappas

but there is an easyer way. Since anyway you have to declare that your instance or package now depends on ldappas, you can left to buildout the work to fetch the dependencies for you. So, you edit ~/myenv/myinstance/setup.py and add in install_requires the name of the package:

    setup(name='myinstance'
          ...
          install_requires = ['setuptools',
                              ...
                              'ldappas',
                             ],
          ...

Now it is time to rebuild your application:

    $ cd ~/myenv/myinstance
    $ bin/buildout

Finally, remember to register the new package at ~/myenv/myinstance/src/myinstance/configure.zcml:

    <configure xmlns="http://namespaces.zope.org/zope"
      ...
      <include package="ldappas" />
      ...
    </configure>

and restart it.



( 98 subscribers )