[Pythonmac-SIG] libxml2 on 10.3 (Panther)

Paul Donovan paul at donovansbrain.co.uk
Wed Dec 3 16:49:12 EST 2003


On 3 Dec 2003, at 12:45, Michael Hudson wrote:

> Jack Jansen <Jack.Jansen at cwi.nl> writes:
>>
>> To use an existing C library from Python you need a wrapper module,
>> which takes care of converting data representations from Python to C
>> and vice versa. This wrapper module is then what you import into
>> Python.
>>
>> Creating a wrapper module is not trivial, but there are some tools
>> to help you with it.
>
> For the specific case of libxml2, though, I'm pretty sure someone has
> already done it :-)
>
Well, I did some more searching today, and thought I found the solution  
on the libxml2 project page ;-)

On http://www.xmlsoft.org/python.html it says:

	• 	Otherwise use the libxml2-python module distribution corresponding  
to your installed version of libxml2 and libxslt. Note that to install  
it you will need both libxml2 and libxslt installed and run "python  
setup.py build install" in the module tree.

So I downloaded ftp://xmlsoft.org/python/libxml2-python-2.5.4.tar.gz,  
unpacked it and ran the setup.py program. I got the following output,  
which to my eyes doesn't look _too_ bad:
-------------------
/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/ 
xmllib.py:10: DeprecationWarning: The xmllib module is obsolete.  Use  
xml.sax instead.
   DeprecationWarning)
Found 1138 functions in libxml2-api.xml
Found 45 functions in libxml2-python-api.xml
Generated 706 wrapper functions, 293 failed, 184 skipped

Missing type converters:
xmlXPathFuncLookupFunc:1  xmlRegExecCallbacks:1   
xmlInputMatchCallback:1  xmlLocationSetPtr:6  xmlEnumerationPtr:5   
xmlElementTablePtr:2  const htmlEntityDesc *:2  xmlChar **:14   
xmlRegExecCtxtPtr:2  xmlEntityReferenceFunc:1  xmlTextReaderErrorFunc:1  
  xmlOutputMatchCallback:1  xmlExternalEntityLoader:2   
xmlOutputWriteCallback:1  xmlNsPtr *:1  size_t:1  xmlXPathObjectPtr:22   
xmlAttributeType:1  xmlValidCtxtPtr:23  xmlEnumerationPtr *:2   
xmlBufferAllocationScheme:2  xmlNotationTablePtr:2   
xmlXPathVariableLookupFunc:1  xmlShellCtxtPtr:10  xlinkNodeDetectFunc:2  
  xmlRefTablePtr:1  xmlCharEncodingHandler *:4  xmlElementContentPtr *:1  
  xmlRelaxNGValidityErrorFunc:2  xlinkHandlerPtr:2   
xmlAttributeTablePtr:2  xmlC14NIsVisibleCallback:1   
xmlDeregisterNodeFunc:1  htmlStatus:1  xmlCatalogPrefer:1   
xmlParserNodeInfoSeqPtr:3  xmlShellReadlineFunc:1  htmlElemDesc *:3   
xmlCharEncodingHandlerPtr:7  xmlNodePtr *:1  xmlCharEncodingInputFunc:1  
  xmlAutomataPtr:15  xmlXPathCompExprPtr:4  xmlInputReadCallback:1  char  
**:5  const xmlParserNodeInfo *:1  xmlCharEncoding:12  xmlNodeSetPtr:32  
  xmlParserInputPtr:17  xmlEntitiesTablePtr:3  xmlRegisterNodeFunc:1   
xmlIDTablePtr:1  xmlXPathFunction:4  xmlCatalogAllow:2   
xmlElementContentType:1  xmlElementContent *:1  xmlParserNodeInfoPtr:1   
void *:44  xmlTextReaderErrorFunc *:1  xmlElementContentPtr:4   
xmlNotationPtr:1  const htmlElemDesc *:1  xlinkType:1   
xmlGenericErrorFunc *:1
Found 195 functions in libxslt-api.xml
Found 27 functions in libxslt-python-api.xml
Generated 120 wrapper functions, 99 failed, 3 skipped

Missing type converters:
xsltTopLevelFunction:2  xsltDecimalFormatPtr:2  xmlChar **:1   
xmlXPathCompExprPtr:3  xsltNumberDataPtr:1  xsltElemPreCompPtr:2   
xsltSortFunc:2  xsltSecurityPrefsPtr:11  xsltTemplatePtr:6   
pythonObject *:4  ...:1  xsltPreComputeFunction:2  xmlNodePtr *:3   
xsltExtInitFunction:2  char **:6  xmlXPathObjectPtr *:1   
xmlNodeSetPtr:2  xmlXPathFunction:4  xsltTransformFunction:5   
xsltCompMatchPtr:3  void *:7  xmlOutputBufferPtr:1  xsltDocumentPtr:7   
xsltStylePreCompPtr:18  xsltStackElemPtr:3
failed to find headers for libxslt: update includes_dir
/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/ 
distutils/dist.py:213: UserWarning: 'licence' distribution option is  
deprecated; use 'license'
   warnings.warn(msg)
running build
running build_py
file drv_libxml2.py (for module drv_libxml2) not found
creating build
creating build/lib.darwin-7.0.0-Power_Macintosh-2.3
copying libxml2.py -> build/lib.darwin-7.0.0-Power_Macintosh-2.3
file drv_libxml2.py (for module drv_libxml2) not found
running build_ext
building 'libxml2mod' extension
creating build/temp.darwin-7.0.0-Power_Macintosh-2.3
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp  
-mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Wall  
-Wstrict-prototypes -I/usr/include/libxml2 -I/usr/include  
-I/System/Library/Frameworks/Python.framework/Versions/2.3/include/ 
python2.3 -c libxml2-py.c -o  
build/temp.darwin-7.0.0-Power_Macintosh-2.3/libxml2-py.o
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp  
-mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Wall  
-Wstrict-prototypes -I/usr/include/libxml2 -I/usr/include  
-I/System/Library/Frameworks/Python.framework/Versions/2.3/include/ 
python2.3 -c types.c -o  
build/temp.darwin-7.0.0-Power_Macintosh-2.3/types.o
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp  
-mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Wall  
-Wstrict-prototypes -I/usr/include/libxml2 -I/usr/include  
-I/System/Library/Frameworks/Python.framework/Versions/2.3/include/ 
python2.3 -c libxml.c -o  
build/temp.darwin-7.0.0-Power_Macintosh-2.3/libxml.o
libxml.c: In function `libxml_xmlTextReaderSetErrorHandler':
libxml.c:1554: warning: comparison of distinct pointer types lacks a  
cast
libxml.c:1584: warning: passing arg 2 of `xmlTextReaderSetErrorHandler'  
from incompatible pointer type
libxml.c: In function `libxml_xmlTextReaderGetErrorHandler':
libxml.c:1606: warning: comparison of distinct pointer types lacks a  
cast
libxml.c: In function `libxml_xmlFreeTextReader':
libxml.c:1639: warning: comparison of distinct pointer types lacks a  
cast
gcc -Wl,-F. -Wl,-F. -bundle -framework Python  
build/temp.darwin-7.0.0-Power_Macintosh-2.3/libxml2-py.o  
build/temp.darwin-7.0.0-Power_Macintosh-2.3/libxml.o  
build/temp.darwin-7.0.0-Power_Macintosh-2.3/types.o -L/usr/lib -lxml2  
-lm -lz -o build/lib.darwin-7.0.0-Power_Macintosh-2.3/libxml2mod.so
running install
running install_lib
copying build/lib.darwin-7.0.0-Power_Macintosh-2.3/libxml2.py ->  
/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/ 
site-packages
copying build/lib.darwin-7.0.0-Power_Macintosh-2.3/libxml2mod.so ->  
/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/ 
site-packages
byte-compiling  
/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/ 
site-packages/libxml2.py to libxml2.pyc
----------------

Unfortunately, trying 'import libxml2' in python results in the  
following fatal error:
 >>> import libxml2
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort trap

So my next step is to try Jack's swig suggestion, but that looks  
reasonably tricky. I'm a professional (videogames) programmer, so I can  
hack most stuff, but this is all new to me.

Paul

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2377 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20031203/df81da02/smime.bin


More information about the Pythonmac-SIG mailing list