[Twisted-Python] How to configure setup.py for a twistd TAP app

Jean-Paul Calderone exarkun at divmod.com
Wed Dec 19 07:21:40 MST 2007


On Thu, 20 Dec 2007 00:15:59 +1100, Chris Miles <miles.chris at gmail.com> wrote:
>I want to deploy my Twisted app as a Twisted Application Plugin for  twistd 
>as per
>http://twistedmatrix.com/projects/core/documentation/howto/tap.html
>
>I want to distribute my app as a tarball, so the user would untar it  and 
>run "python setup.py install".  Then they would run "twistd myapp"  to start 
>it.
>
>How do I configure setup.py so that twisted/plugins/myapp.py is created?
>

Since your app depends on Twisted, the user should already have a directory
named "twisted/plugins" in their install directory (probably their system-
wide site-packages, but not necessary).  Twisted itself creates and installs
this directory.  Your installer needs to do just two things: put myapp.py
into that directory and regenerate the plugin cache.

One way in which to accomplish the first thing is like this:

    Pass a list like ["twisted.plugins"] for the packages keyword argument
    to distutils setup()

    Pass a dict like {'twisted': ['plugins/myapp.py']} for the package_data
    keyword argument to distutils setup()

    Include a line like "graft twisted" in your MANIFEST.in

http://twistedmatrix.com/projects/core/documentation/howto/plugin.html#auto3
gives an example of how to do the second thing.

Jean-Paul




More information about the Twisted-Python mailing list