[lxml-dev] Test question on Win32 build
After building the latest lxml download, I trying to run the test code, (python test.py in the source directory), and I'm getting a confusing error. I get : Traceback (most recent call last): File "test.py", line 591, in ? exitcode = main(sys.argv) File "test.py", line 554, in main test_cases = get_test_cases(test_files, cfg, tracer=tracer) File "test.py", line 254, in get_test_cases module = import_module(file, cfg, tracer=tracer) File "test.py", line 197, in import_module mod = __import__(modname) File "C:\Documents and Settings\All Users\Download\LibXML2libXSLT\lxml\src\lxml\tests\test_etree.py", line 1332, in ? from lxml import etree ImportError: cannot import name etree However, when type 'from lxml import etree' at the python prompt, it imports fine. Anyone have the same problem and know how to fix it? I would to verify that I have a good install and build. And another, should the following be the contents of the /Libs/site-packages/lxml after a successful build of lxml? I had to copy the dll's from the various libxml2/libxslt directories to avoid dll dependency errors when importing the package. /lxml iconv.dll libexslt.dll libxml2.dll libxslt.dll zlib1.dll etree.pyd elementpath.py _elementpath.pyc __init__.py __init__.pyc tests/ test.xml test_broken.xml test_etree.py test_etree.pyc test_unicode.py test_unicode.pyc test_xpathevaluator.py test_xpathevaluator.pyc __init__.py __init__.pyc Thanks in advance...jeff
Jeff_Gayle@sil.org wrote:
After building the latest lxml download,
Whoah, on Windows? That's just what we need! I'm very happy you're making this effort.
I trying to run the test code, (python test.py in the source directory), and I'm getting a confusing error. I get :
Traceback (most recent call last): File "test.py", line 591, in ? exitcode = main(sys.argv) File "test.py", line 554, in main test_cases = get_test_cases(test_files, cfg, tracer=tracer) File "test.py", line 254, in get_test_cases module = import_module(file, cfg, tracer=tracer) File "test.py", line 197, in import_module mod = __import__(modname) File "C:\Documents and Settings\All Users\Download\LibXML2libXSLT\lxml\src\lxml\tests\test_etree.py", line 1332, in ? from lxml import etree ImportError: cannot import name etree
However, when type 'from lxml import etree' at the python prompt, it imports fine.
Hm, this is mysterious. The test runner I think puts the 'src' directory on the python path directory, but if the etree shared library is not there after compilation but installed elsewhere, this may have something to do with it. Then again, you'd expect the tests to be able to import lxml from there, especially since you can on the prompt. Do simple examples work on the prompt? Oh, wait, is it possible that the test runner putting the src directory on the PYTHONPATH in fact explains the problem? By doing so, it might be that it finds the the directory you compiled from first as the lxml package, and this then *doesn't* contain the dlls to import (as they're in site-packages), and tries to import that first? That would explain why you can find 'lxml' but *not* etree. You could try adding a simple test that displays lxml.__file__ to see where it is coming from.
Anyone have the same problem and know how to fix it? I would to verify that I have a good install and build.
Yes, that would be a good thing.
And another, should the following be the contents of the /Libs/site-packages/lxml after a successful build of lxml? I had to copy the dll's from the various libxml2/libxslt directories to avoid dll dependency errors when importing the package.
Hm, I don't know enough about how Windows finds dlls to judge this one. Looking in my linux /usr/lib directory now..
/lxml iconv.dll
I can't find this one, though I know libxml2 uses it somewhere, so perhaps it's linked into one of the others.
libexslt.dll libxml2.dll libxslt.dll
I got these. I also have an libxsltbreakpoint, I have no idea what it does.
zlib1.dll
I got a libz, which I think is the same.
etree.pyd elementpath.py
Unless you forgot a _, this one I think is coming from somewhere else; possibly ElementTree? lxml just uses _elementpath.py.
_elementpath.pyc
I only see the .pyc there, which should work, but I'd expect a .py version too, unless you indeed dropped the _.
__init__.py __init__.pyc tests/ test.xml test_broken.xml test_etree.py test_etree.pyc test_unicode.py test_unicode.pyc test_xpathevaluator.py test_xpathevaluator.pyc __init__.py __init__.pyc
This looks like the contents of my tests directory. I'm not sure why the tests are installed into site-packages; I should look into that. Regards, Martijn
Martijn,
Do simple examples work on the prompt?
Yes I ran them and they seem to work fine.
Oh, wait, is it possible that the test runner putting the src directory on the PYTHONPATH in fact explains the problem? By doing so, it might be that it finds the the directory you compiled from first as the lxml package, and this then *doesn't* contain the dlls to import (as they're in site-packages), and tries to import that first? That would explain why you can find 'lxml' but *not* etree.
You could try adding a simple test that displays lxml.__file__ to see where it is coming from.
I did this and it confirms your theory. I then moved the python24/Lib/site-packages/lxml directory to the /src/lxml directory and renamed the original. I then moved four files 'test?.txt' and 'test?.rng' from the old /src/lxml/tests directory. These were missing in the python24/Lib/site-packages/lxml/tests directory. I then attempted to run the test.py file again and it WORKED! Yeah!. However I did have two errors from the test. I suspect they might be platform dependent but I'm not very knowledgeable about NAN things. Below is the test output. ====================================================================== FAIL: test_xpath_number (lxml.tests.test_xpathevaluator.ETreeXPathTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Python24\lib\unittest.py", line 260, in run testMethod() File "C:\Python24\Lib\site-packages\lxml\tests\test_xpathevaluator.py", line 20, in test_xpath_number self.assertEquals('nan', str(tree.xpath('number(/a)'))) File "C:\Python24\lib\unittest.py", line 332, in failUnlessEqual raise self.failureException, \ AssertionError: 'nan' != '1.#QNAN' ====================================================================== FAIL: test_xpath_number (lxmldel.tests.test_xpathevaluator.ETreeXPathTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Python24\lib\unittest.py", line 260, in run testMethod() File "C:\Documents and Settings\All Users\Download\LibXML2libXSLT\lxml\src\lxmldel\tests\test_xpathevaluator.py", line 20, in test_xpath_number self.assertEquals('nan', str(tree.xpath('number(/a)'))) File "C:\Python24\lib\unittest.py", line 332, in failUnlessEqual raise self.failureException, \ AssertionError: 'nan' != '1.#QNAN' ---------------------------------------------------------------------- Ran 436 tests in 0.811s FAILED (failures=2)
etree.pyd elementpath.py
Unless you forgot a _, this one I think is coming from somewhere else; possibly ElementTree? lxml just uses _elementpath.py.
_elementpath.pyc
I only see the .pyc there, which should work, but I'd expect a .py version too, unless you indeed dropped the _.
Yes, I hit the delete key one too many times. There is indeed a _elementpath.py? file not elementpath.py? Sorry! So, in summary, I was able to install libxml2, libxslt, and other required dlls as binary dowloads, PyRex, build lxml with support for Python 2.4 on windows XP with above file moves. Is there anything else I can do to help document or test the windows install? I have another question, a dumb one actually, but I will write a new email for that one. ...jeff Martijn Faassen <faassen@infrae.com> 04/26/2005 02:21 PM To Jeff_Gayle@sil.org cc lxml-dev@codespeak.net Subject Re: [lxml-dev] Test question on Win32 build Jeff_Gayle@sil.org wrote:
After building the latest lxml download,
Whoah, on Windows? That's just what we need! I'm very happy you're making this effort.
I trying to run the test code, (python test.py in the source directory), and I'm getting a confusing error. I get :
Traceback (most recent call last): File "test.py", line 591, in ? exitcode = main(sys.argv) File "test.py", line 554, in main test_cases = get_test_cases(test_files, cfg, tracer=tracer) File "test.py", line 254, in get_test_cases module = import_module(file, cfg, tracer=tracer) File "test.py", line 197, in import_module mod = __import__(modname) File "C:\Documents and Settings\All Users\Download\LibXML2libXSLT\lxml\src\lxml\tests\test_etree.py", line 1332, in ? from lxml import etree ImportError: cannot import name etree
However, when type 'from lxml import etree' at the python prompt, it imports fine.
Hm, this is mysterious. The test runner I think puts the 'src' directory on the python path directory, but if the etree shared library is not there after compilation but installed elsewhere, this may have something to do with it. Then again, you'd expect the tests to be able to import lxml from there, especially since you can on the prompt. Do simple examples work on the prompt? Oh, wait, is it possible that the test runner putting the src directory on the PYTHONPATH in fact explains the problem? By doing so, it might be that it finds the the directory you compiled from first as the lxml package, and this then *doesn't* contain the dlls to import (as they're in site-packages), and tries to import that first? That would explain why you can find 'lxml' but *not* etree. You could try adding a simple test that displays lxml.__file__ to see where it is coming from.
Anyone have the same problem and know how to fix it? I would to verify that I have a good install and build.
Yes, that would be a good thing.
And another, should the following be the contents of the /Libs/site-packages/lxml after a successful build of lxml? I had to copy
the dll's from the various libxml2/libxslt directories to avoid dll dependency errors when importing the package.
Hm, I don't know enough about how Windows finds dlls to judge this one. Looking in my linux /usr/lib directory now..
/lxml iconv.dll
I can't find this one, though I know libxml2 uses it somewhere, so perhaps it's linked into one of the others.
libexslt.dll libxml2.dll libxslt.dll
I got these. I also have an libxsltbreakpoint, I have no idea what it does.
zlib1.dll
I got a libz, which I think is the same.
etree.pyd elementpath.py
Unless you forgot a _, this one I think is coming from somewhere else; possibly ElementTree? lxml just uses _elementpath.py.
_elementpath.pyc
I only see the .pyc there, which should work, but I'd expect a .py version too, unless you indeed dropped the _.
__init__.py __init__.pyc tests/ test.xml test_broken.xml test_etree.py test_etree.pyc test_unicode.py test_unicode.pyc test_xpathevaluator.py test_xpathevaluator.pyc __init__.py __init__.pyc
This looks like the contents of my tests directory. I'm not sure why the tests are installed into site-packages; I should look into that. Regards, Martijn
Hey, Jeff_Gayle@sil.org wrote:
Do simple examples work on the prompt?
Yes I ran them and they seem to work fine.
Good to hear. [my theory about packages being imported from the wrong place by the test runner].
I did this and it confirms your theory.
Great!
I then moved the python24/Lib/site-packages/lxml directory to the /src/lxml directory and renamed the original. I then moved four files 'test?.txt' and 'test?.rng' from the old /src/lxml/tests directory. These were missing in the python24/Lib/site-packages/lxml/tests directory.
I guess setup.py needs some improvements in all this (though we shouldn't be installing the tests at all, really).
I then attempted to run the test.py file again and it WORKED! Yeah!.
Awesome, it's really good news to hear the whole thing works on Windows!
However I did have two errors from the test. I suspect they might be platform dependent but I'm not very knowledgeable about NAN things. Below is the test output.
Yes, there are definite platform differences there. I know this not because I know anything about NAN things, but because I've read the occasional Tim Peters posting about the complexity underlying this. :) I think we're dealing with just one failure here, as I suspect you're also picking up the test cases from the lxml you moved away (lxmldel):
FAIL: test_xpath_number (lxml.tests.test_xpathevaluator.ETreeXPathTestCase)
FAIL: test_xpath_number (lxmldel.tests.test_xpathevaluator.ETreeXPathTestCase)
I think we'd be fairly safe just disabling this test, or perhaps hardcoding the windows output and check for that too... It's not a really common occurrence in real code, I suspect. [snip]
So, in summary, I was able to install libxml2, libxslt, and other required dlls as binary dowloads, PyRex, build lxml with support for Python 2.4 on windows XP with above file moves.
Again, I'm really happy to hear this news. Thanks for going through the effort.
Is there anything else I can do to help document or test the windows install?
I'd appreciate it very much if you could make available binaries for download, along with a few installation instructions (an installer would be great but that is perhaps too much to ask). If you mail them to me, I can upload them to the codespeak site. On the medium term I'd like to improve our setup.py so that it can do the whole windows stuff more automatically. I really need help on this, so your help would be enormously appreciated. I believe setup.py can also be instructed to build a Windows installer for Python packages, so if you could help in getting that going that'd be great. Regards, Martijn
participants (2)
-
Jeff_Gayle@sil.org
-
Martijn Faassen