pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: {pkgsrc-users} Re: Proposed patch for python 2.[56] to enable elementtree



On 9-Sep-2009, at 4:41 PM, Joerg Sonnenberger wrote:
On Wed, Sep 09, 2009 at 01:04:58PM -0400, Brian de Alwis wrote:
Attached is a patch to simply install the _elementtree module Pythons
2.5 and 2.6 and deprecate the textproc/py-elementtree package.

The patch seems very incomplete :) Are you sure that it doesn't use
expat? I seem to remember that it contains references to that at the
very least...


No, I'm not sure, but I'm fairly certain it's more complete than the current situation :-) My attempt at deprecating py-elementtree may be bogus and require more work (more below). And see the note about expat further below.

Basically, this patch attempts to correct the broken xml.etree.cElementTree left by the lang/python2[56] packages. These packages essentially do a full install *except* for the shared libraries corresponding to some major modules. The Python source code for to those modules *is* installed by the python2[56] packages. Their shared libraries are actually built and installed by corresponding py-* packages instead.

So for example, if you install python26, you'll find the ElementTree and cElementTree code installed.

    $ pkg_info -qL python26 | grep -i xml.etree
    /usr/pkg/lib/python2.6/test/test_xml_etree.py
    /usr/pkg/lib/python2.6/test/test_xml_etree.pyc
    /usr/pkg/lib/python2.6/test/test_xml_etree.pyo
    /usr/pkg/lib/python2.6/test/test_xml_etree_c.py
    /usr/pkg/lib/python2.6/test/test_xml_etree_c.pyc
    /usr/pkg/lib/python2.6/test/test_xml_etree_c.pyo
    /usr/pkg/lib/python2.6/xml/etree/ElementInclude.py
    /usr/pkg/lib/python2.6/xml/etree/ElementInclude.pyc
    /usr/pkg/lib/python2.6/xml/etree/ElementInclude.pyo
    /usr/pkg/lib/python2.6/xml/etree/ElementPath.py
    /usr/pkg/lib/python2.6/xml/etree/ElementPath.pyc
    /usr/pkg/lib/python2.6/xml/etree/ElementPath.pyo
    /usr/pkg/lib/python2.6/xml/etree/ElementTree.py
    /usr/pkg/lib/python2.6/xml/etree/ElementTree.pyc
    /usr/pkg/lib/python2.6/xml/etree/ElementTree.pyo
    /usr/pkg/lib/python2.6/xml/etree/__init__.py
    /usr/pkg/lib/python2.6/xml/etree/__init__.pyc
    /usr/pkg/lib/python2.6/xml/etree/__init__.pyo
    /usr/pkg/lib/python2.6/xml/etree/cElementTree.py
    /usr/pkg/lib/python2.6/xml/etree/cElementTree.pyc
    /usr/pkg/lib/python2.6/xml/etree/cElementTree.pyo

And attempting to use the ElementTree code will succeed, even without the py-elementtree package installed. But trying to use xml.etree.cElementTree will fail though as the _elementtree module isn't installed:

    $ python2.6
    Python 2.6.2 (r262:71600, Sep 10 2009, 14:33:58)
    [GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
    >>> import xml.etree.ElementTree
    >>> import xml.etree.cElementTree
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
File "/usr/pkg/lib/python2.6/xml/etree/cElementTree.py", line 3, in <module>
        from _elementtree import *
    ImportError: No module named _elementtree
    >>>

Note that it is attempting to load the _elementtree module. This module is *not* installed by the py-elementtree package because it installs the external ElementTree packages. So pkgsrc's python2[56] leave a broken xml.etree.cElementTree. My patch causes the _elementtree shared library to be installed by default; it changes little else.

My patch's attempt at deprecating py-elementtree may be unnecessary since the in-tree versions have been prefixed with xml.etree; they should be able to co-exist.

My motivation for this is that I use devel/bzr, which thrives when able to use cElementTree. Bzr first looks for the in-tree xml.etree.c? ElementTree, and then falls back to the external c?ElementTree. But bzr does support Python 2.4, and thus should require the textproc/py- elementtree package (I've only ever tried it with Python 2.5 though, so it wasn't a concern).

Re: expat: the ElementTree code does seem to try to load expat for its XMLTreeBuilder class, but does provides a fallback SimpleXMLTreeBuilder that works without expat. Anyways, it seems we can use the expat module even without the py-expat package installed!

Brian.

--
"Amusement to an observing mind is study." - Benjamin Disraeli



Home | Main Index | Thread Index | Old Index