Opened 8 years ago

Closed 7 years ago

#2048 closed task (fixed)

configure check for pyexpat

Reported by: jreed Owned by: UnAssigned
Priority: low Milestone: Non-Development-2012Q3
Component: build system Version:
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: N/A
Sub-Project: Core Feature Depending on Ticket:
Estimated Difficulty: 2 Add Hours to Ticket: 0
Total Hours: 0 Internal?: no

Description

Have a configure.ac check for pyexpat. This is used by b10-stats-httpd.

(Also what other dependencies aren't checked in configure?)

Subtickets

Change History (9)

comment:1 Changed 8 years ago by shane

  • Estimated Difficulty changed from 0 to 2

comment:2 Changed 8 years ago by naokikambe

The current b10-stats-httpd explicitly uses xml.etree.ElementTree, not pyexpat including xml.parsers.expat. I don't know exactly whether ElementTree uses pyexpat or not. The python document doesn't seem to be described so: http://docs.python.org/py3k/library/xml.etree.elementtree.html

comment:3 Changed 8 years ago by naokikambe

ElementTree uses expat. That's described in the code ElementTree.py:

# Element structure builder for XML source data, based on the
# <b>expat</b> parser.

Thanks.

comment:4 Changed 8 years ago by jreed

 File "/usr/pkg/lib/python3.1/xml/etree/ElementTree.py", line 1106, in __init__     "No module named expat; use SimpleXMLTreeBuilder instead"

Can we use the alternative? It doesn't matter to me; I am just curious.

The problem hit me on a different system. I quickly fixed by installing py31-expat package.

comment:5 Changed 8 years ago by naokikambe

I think we can't. There isn't SimpleXMLTreeBuilder in the python standard library. For using it, we should additionally install elementtree: http://effbot.org/downloads/#elementtree. But it seems to use xmllib, xmllib seems to removed from python3: http://www.python.org/getit/releases/3.0.1/NEWS.txt.

Anyway that pyexpat would be used only in the stats-httpd unittest, not in runtime. Nevertheless I think checking for pyexpat in configure.ac would be better.

Thanks,

comment:6 Changed 8 years ago by jreed

I confirmed not used at run-time. I had documented that wrong.

comment:7 Changed 8 years ago by naokikambe

Thank you for the confirmation. As another workaround, I made a quick patch for b10-stats-httpd_test.py to skip the tests using expat if it's unavailable:

  • src/bin/stats/tests/b10-stats-httpd_test.py

    diff --git a/src/bin/stats/tests/b10-stats-httpd_test.py b/src/bin/stats/tests/b10-stats-httpd_test.py
    index 57abed9..65206ab 100644
    a b def is_ipv6_enabled(address='::1', port=8001): 
    109109
    110110class TestHttpHandler(unittest.TestCase):
    111111    """Tests for HttpHandler class"""
     112
     113    # This test suite uses xml.etree.ElementTree.XMLParser via
     114    # xml.etree.ElementTree.parse. On the platform where expat isn't
     115    # installed, ImportError is raised and it's failed. Check expat is
     116    # available before the test invocation. Skip this test if it's
     117    # unavailable.
     118    xml_parser = None
     119    try:
     120        # ImportError raised if xpat is unavailable
     121        xml_parser = xml.etree.ElementTree.XMLParser()
     122    except ImportError:
     123        pass
     124
    112125    def setUp(self):
    113126        # set the signal handler for deadlock
    114127        self.sig_handler = SignalHandler(self.fail)
    class TestHttpHandler(unittest.TestCase): 
    132145        # reset the signal handler
    133146        self.sig_handler.reset()
    134147
     148    @unittest.skipUnless(xml_parser, "skipping the test using XMLParser")
    135149    def test_do_GET(self):
    136150        self.assertTrue(type(self.stats_httpd.httpd) is list)
    137151        self.assertEqual(len(self.stats_httpd.httpd), 1)
Last edited 8 years ago by naokikambe (previous) (diff)

comment:8 Changed 8 years ago by shane

  • Milestone changed from New Tasks to Non-Development-2012Q3

comment:9 Changed 7 years ago by naokikambe

  • Resolution set to fixed
  • Status changed from new to closed

I applied the above patch on #2268(f5caa308b4534eb70cd5996c2e809a36ac36ee6d). So I'm closing.
But I don't think checking for pyexpat is added to configure.ac. Please reopen if it's also required.

Last edited 7 years ago by naokikambe (previous) (diff)
Note: See TracTickets for help on using tickets.