[XML-SIG] Disposition of C extensions and packages

A.M. Kuchling akuchlin@mems-exchange.org
Sat, 18 Dec 1999 21:43:19 -0500


[Crossposted to xml-sig, distutils-sig]

I'm working on getting the XML-SIG's CVS tree to install using the
current version of the Distutils.  Right now there are two C
extensions, sgmlop.so and pyexpat.so, and they're installed under
xml/parsers/ .  It's hard to handle this case using the distutils code
as it stands, because it expects to put extensions into a
build/platlib/ directory, from which they'll be installed into
site-packages.  

I can coerce setup.py into installing them into xml/parsers/, by
subclassing the BuildExt command and setting build_dir myself:

    from distutils.command.build_ext import BuildExt
    class XMLBuildExt(BuildExt):
        def set_default_options (self):
            BuildExt.set_default_options( self )
            self.build_dir = 'lib/build/xml/parser' 

    setup (name = "PyXML", cmdclass = {'build_ext':XMLBuildExt}, ...)

You also have to subclass the Install command and set build_dir
there; I've trimmed that code.  It's really clunky.\

Note that this scheme will break once there are C modules that need to
be installed anywhere other than xml/parsers/, because build_dir is
being hardwired without knowledge of what module is being compiled.

Questions:

	1) A general Python question about packaging style: Is mixing
           C extensions and Python modules in one package tree a bad
           idea?  It makes the whole tree platform-dependent, which is
           probably annoying for sites maintaining Python installation
           for different architectures.  

	2) Another general question, this time o: how should this be
           handled?  Should C extensions always be effectively
           top-level, and therefore go into site-packages?  Should
           there be an xml package holding .py files, and an X package
           holding all the C extensions? (X = 'plat_xml',
           'xml_binary', or something like that)

	3) XML-SIG question: should I go ahead and change it (since I
           first changed it to use xml.parsers.sgmlop)?

	4) Distutils question: is this a problem with the Distutils
           code that needs fixing?  I suspect not; if the tools make
           it difficult to do stupid things like mix .py and .so
           files, that's a good thing.

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
The Kappamaki, a whaling research ship, was currently researching the
question: How many whales can you catch in one week?
    -- Terry Pratchett & Neil Gaiman, _Good Omens_