At 01:06 AM 12/3/2009 +0100, Andrew Dalke wrote:
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",
      package="my_spam",
      akara_extensions=["spam_extension.py"]
)


To clarify, the development/distribution package looks like:
  $PACKAGE/setup.py
  $PACKAGE/README
  $PACKAGE/spam_extensions.py
  $PACKAGE/my_spam/__init__.py
  $PACKAGE/my_spam/dramatis_personae.py
  $PACKAGE/my_spam/cafe.py

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.

It wouldn't be so much of a change as an addition. You'd just add code like this, either before or after your existing loop over the extensions directory:

     for entry_point in pkg_resources.iter_entry_points('akara'):
         extension_module = entry_point.load()
         # do stuff with extension_module

And then users would declare their extensions for installation like this:

setup(name="Spam services",
      packages=["my_spam"],
      py_modules=["spam_extension"],
entry_points={'akara':'Spam services=spam_extension'} # arbitrary name=module
)

Everything else would be the same as you described above with respect to layout, except:

1. the spam_extension module would be installed in site-packages
2. It wouldn't need to be a top-level module (i.e., it could be a module in the package) 3. You don't need any custom distutils extensions, except what you get via setuptools or Distribute.

_______________________________________________
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to