[Distutils] modules in sub-packages

P.J. Eby pje at telecommunity.com
Wed Apr 7 19:55:00 CEST 2010

At 11:00 PM 4/7/2010 +0530, Amit Sethi wrote:
>I am trying to create  a module for the docutils . I wish to install
>it docutils.writer.something

Is that a documented, official way to extend docutils?  If not, and 
docutils.writer is not a namespace package, then you should not be doing that.

>I have docutils installed at
>on my ubuntu machine but when I tried to install it create a seperate
>package called docutils and saves
>the package in that ? How do I tell a package that this particular
>package is a subpackage of a library
>the setup.py of the package looks like :
>  license='Public Domain',
>  packages=['docutils.writers'],
>  package_dir={'docutils.writers':'docbook'},
>  scripts=['rst2docbook.py']

The correct way to do this is to NOT list packages or package_dir; 
just use py_modules = 'docutils.writer.docbook', and have a 
docutils/writer/docbook.py file.  This will install it in a 
distutils-compatible way, but not a distribute-compatible or 
setuptools-compatible way.

Really, this is not a well-supported scenario in any case -- it is to 
be avoided if at all possible.  Installing your code into other 
people's packages is a bad way to extend them.  (Setuptools and 
Distribute offer better ways of providing extensibility, such as 
namespace packages and entry points.)

More information about the Distutils-SIG mailing list