[Distutils] installing .py plugins to an alternate directory

Andrew Dalke dalke at dalkescientific.com
Thu Dec 3 01:06:51 CET 2009

Hi all,

  I'm working with the Akara project. It contains a web server. The server loads extensions from a special directory (let's say "$AKARA" for now). An extension can register handlers for URLs. An example extension might look like:

installs to $AKARA/spam_extension.py
(note: only .py files are supported; not even .pyc files)
from akara.services import simple_service

import my_spam # This is part of the distribution, and gets put in site-packages

@simple_service("GET", "http://vikings.protocol.id/")
def vikings(say=my_spam.DEFAULT_TEXT):
    return my_spam.vikings(say)

We want people to be able to distribute Akara plugins and install via setup.py. Ideally I would like to say:

from distutils.core import setup
from akara.distutils ... I'm not sure what here ...

setup(name="Spam services",

To clarify, the development/distribution package looks like:

and $PACKAGE/spam_extensions.py goes to $AKARA/spam_extensions.py while $PACKAGE/my_spam is copied to site-packages.

The installation does not need to byte-compile spam_extension.py.

It should also include spam_extension.py in any distribution that it makes.

I looked through the documentation and searched for existing examples, but found nothing which does this. The plugins I found used entry_points, and that's an architecture change which I don't think is appropriate for us.


I had hoped that I could add my own cmdclasses like "build_akara" and "install_akara" which would get called during the correct stages of the build process, but that seems to be a dead end. I might be able to hack the "install_data" cmdclass to make it work, but that would prevent anyone from using it in their own setup.py distributions.

				dalke at dalkescientific.com

More information about the Distutils-SIG mailing list