Tryag File Manager
Home
-
Turbo Force
Current Path :
/
proc
/
self
/
root
/
usr
/
share
/
doc
/
python-lxml-2.0.11
/
doc
/
html
/
Upload File :
New :
File
Dir
//proc/self/root/usr/share/doc/python-lxml-2.0.11/doc/html/build.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="generator" content="Docutils 0.4.1: http://docutils.sourceforge.net/" /> <title>How to build lxml from source</title> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div class="document" id="how-to-build-lxml-from-source"> <div class="sidemenu"><ul id="lxml"><li><span class="section title">lxml</span><ul class="menu foreign" id="index"><li class="menu title"><a href="index.html">lxml</a><ul class="submenu"><li class="menu item"><a href="index.html#introduction">Introduction</a></li><li class="menu item"><a href="index.html#documentation">Documentation</a></li><li class="menu item"><a href="index.html#download">Download</a></li><li class="menu item"><a href="index.html#mailing-list">Mailing list</a></li><li class="menu item"><a href="index.html#bug-tracker">Bug tracker</a></li><li class="menu item"><a href="index.html#license">License</a></li><li class="menu item"><a href="index.html#old-versions">Old Versions</a></li></ul></li></ul><ul class="menu foreign" id="intro"><li class="menu title"><a href="intro.html">Why lxml?</a><ul class="submenu"><li class="menu item"><a href="intro.html#motto">Motto</a></li><li class="menu item"><a href="intro.html#aims">Aims</a></li></ul></li></ul><ul class="menu foreign" id="installation"><li class="menu title"><a href="installation.html">Installing lxml</a><ul class="submenu"><li class="menu item"><a href="installation.html#requirements">Requirements</a></li><li class="menu item"><a href="installation.html#installation">Installation</a></li><li class="menu item"><a href="installation.html#building-lxml-from-sources">Building lxml from sources</a></li><li class="menu item"><a href="installation.html#ms-windows">MS Windows</a></li><li class="menu item"><a href="installation.html#macos-x">MacOS-X</a></li></ul></li></ul><ul class="menu foreign" id="lxml2"><li class="menu title"><a href="lxml2.html">What's new in lxml 2.0?</a><ul class="submenu"><li class="menu item"><a href="lxml2.html#changes-in-etree-and-objectify">Changes in etree and objectify</a></li><li class="menu item"><a href="lxml2.html#new-modules">New modules</a></li></ul></li></ul><ul class="menu foreign" id="performance"><li class="menu title"><a href="performance.html">Benchmarks and Speed</a><ul class="submenu"><li class="menu item"><a href="performance.html#general-notes">General notes</a></li><li class="menu item"><a href="performance.html#how-to-read-the-timings">How to read the timings</a></li><li class="menu item"><a href="performance.html#parsing-and-serialising">Parsing and Serialising</a></li><li class="menu item"><a href="performance.html#the-elementtree-api">The ElementTree API</a></li><li class="menu item"><a href="performance.html#xpath">XPath</a></li><li class="menu item"><a href="performance.html#a-longer-example">A longer example</a></li><li class="menu item"><a href="performance.html#lxml-objectify">lxml.objectify</a></li></ul></li></ul><ul class="menu foreign" id="compatibility"><li class="menu title"><a href="compatibility.html">ElementTree compatibility of lxml.etree</a></li></ul><ul class="menu foreign" id="FAQ"><li class="menu title"><a href="FAQ.html">lxml FAQ - Frequently Asked Questions</a><ul class="submenu"><li class="menu item"><a href="FAQ.html#general-questions">General Questions</a></li><li class="menu item"><a href="FAQ.html#installation">Installation</a></li><li class="menu item"><a href="FAQ.html#contributing">Contributing</a></li><li class="menu item"><a href="FAQ.html#bugs">Bugs</a></li><li class="menu item"><a href="FAQ.html#threading">Threading</a></li><li class="menu item"><a href="FAQ.html#parsing-and-serialisation">Parsing and Serialisation</a></li><li class="menu item"><a href="FAQ.html#xpath-and-document-traversal">XPath and Document Traversal</a></li></ul></li></ul></li></ul><ul id="Developing with lxml"><li><span class="section title">Developing with lxml</span><ul class="menu foreign" id="tutorial"><li class="menu title"><a href="tutorial.html">The lxml.etree Tutorial</a><ul class="submenu"><li class="menu item"><a href="tutorial.html#the-element-class">The Element class</a></li><li class="menu item"><a href="tutorial.html#the-elementtree-class">The ElementTree class</a></li><li class="menu item"><a href="tutorial.html#parsing-from-strings-and-files">Parsing from strings and files</a></li><li class="menu item"><a href="tutorial.html#namespaces">Namespaces</a></li><li class="menu item"><a href="tutorial.html#the-e-factory">The E-factory</a></li><li class="menu item"><a href="tutorial.html#elementpath">ElementPath</a></li></ul></li></ul><ul class="menu foreign" id="api index"><li class="menu title"><a href="api/index.html">API reference</a></li></ul><ul class="menu foreign" id="api"><li class="menu title"><a href="api.html">APIs specific to lxml.etree</a><ul class="submenu"><li class="menu item"><a href="api.html#lxml-etree">lxml.etree</a></li><li class="menu item"><a href="api.html#other-element-apis">Other Element APIs</a></li><li class="menu item"><a href="api.html#trees-and-documents">Trees and Documents</a></li><li class="menu item"><a href="api.html#iteration">Iteration</a></li><li class="menu item"><a href="api.html#error-handling-on-exceptions">Error handling on exceptions</a></li><li class="menu item"><a href="api.html#error-logging">Error logging</a></li><li class="menu item"><a href="api.html#serialisation">Serialisation</a></li><li class="menu item"><a href="api.html#xinclude-and-elementinclude">XInclude and ElementInclude</a></li><li class="menu item"><a href="api.html#write-c14n-on-elementtree">write_c14n on ElementTree</a></li></ul></li></ul><ul class="menu foreign" id="parsing"><li class="menu title"><a href="parsing.html">Parsing XML and HTML with lxml</a><ul class="submenu"><li class="menu item"><a href="parsing.html#parsers">Parsers</a></li><li class="menu item"><a href="parsing.html#the-target-parser-interface">The target parser interface</a></li><li class="menu item"><a href="parsing.html#the-feed-parser-interface">The feed parser interface</a></li><li class="menu item"><a href="parsing.html#iterparse-and-iterwalk">iterparse and iterwalk</a></li><li class="menu item"><a href="parsing.html#python-unicode-strings">Python unicode strings</a></li></ul></li></ul><ul class="menu foreign" id="validation"><li class="menu title"><a href="validation.html">Validation with lxml</a><ul class="submenu"><li class="menu item"><a href="validation.html#validation-at-parse-time">Validation at parse time</a></li><li class="menu item"><a href="validation.html#dtd">DTD</a></li><li class="menu item"><a href="validation.html#relaxng">RelaxNG</a></li><li class="menu item"><a href="validation.html#xmlschema">XMLSchema</a></li><li class="menu item"><a href="validation.html#schematron">Schematron</a></li></ul></li></ul><ul class="menu foreign" id="xpathxslt"><li class="menu title"><a href="xpathxslt.html">XPath and XSLT with lxml</a><ul class="submenu"><li class="menu item"><a href="xpathxslt.html#xpath">XPath</a></li><li class="menu item"><a href="xpathxslt.html#xslt">XSLT</a></li></ul></li></ul><ul class="menu foreign" id="objectify"><li class="menu title"><a href="objectify.html">lxml.objectify</a><ul class="submenu"><li class="menu item"><a href="objectify.html#the-lxml-objectify-api">The lxml.objectify API</a></li><li class="menu item"><a href="objectify.html#asserting-a-schema">Asserting a Schema</a></li><li class="menu item"><a href="objectify.html#objectpath">ObjectPath</a></li><li class="menu item"><a href="objectify.html#python-data-types">Python data types</a></li><li class="menu item"><a href="objectify.html#how-data-types-are-matched">How data types are matched</a></li><li class="menu item"><a href="objectify.html#what-is-different-from-lxml-etree?">What is different from lxml.etree?</a></li></ul></li></ul><ul class="menu foreign" id="lxmlhtml"><li class="menu title"><a href="lxmlhtml.html">lxml.html</a><ul class="submenu"><li class="menu item"><a href="lxmlhtml.html#parsing-html">Parsing HTML</a></li><li class="menu item"><a href="lxmlhtml.html#html-element-methods">HTML Element Methods</a></li><li class="menu item"><a href="lxmlhtml.html#running-html-doctests">Running HTML doctests</a></li><li class="menu item"><a href="lxmlhtml.html#creating-html-with-the-e-factory">Creating HTML with the E-factory</a></li><li class="menu item"><a href="lxmlhtml.html#working-with-links">Working with links</a></li><li class="menu item"><a href="lxmlhtml.html#forms">Forms</a></li><li class="menu item"><a href="lxmlhtml.html#cleaning-up-html">Cleaning up HTML</a></li><li class="menu item"><a href="lxmlhtml.html#html-diff">HTML Diff</a></li><li class="menu item"><a href="lxmlhtml.html#examples">Examples</a></li></ul></li></ul><ul class="menu foreign" id="cssselect"><li class="menu title"><a href="cssselect.html">lxml.cssselect</a><ul class="submenu"><li class="menu item"><a href="cssselect.html#the-cssselector-class">The CSSSelector class</a></li><li class="menu item"><a href="cssselect.html#css-selectors">CSS Selectors</a></li><li class="menu item"><a href="cssselect.html#limitations">Limitations</a></li></ul></li></ul><ul class="menu foreign" id="elementsoup"><li class="menu title"><a href="elementsoup.html">BeautifulSoup Parser</a><ul class="submenu"><li class="menu item"><a href="elementsoup.html#entity-handling">Entity handling</a></li><li class="menu item"><a href="elementsoup.html#using-soupparser-as-a-fallback">Using soupparser as a fallback</a></li></ul></li></ul></li></ul><ul id="Extending lxml"><li><span class="section title">Extending lxml</span><ul class="menu foreign" id="resolvers"><li class="menu title"><a href="resolvers.html">Document loading and URL resolving</a><ul class="submenu"><li class="menu item"><a href="resolvers.html#resolvers">Resolvers</a></li><li class="menu item"><a href="resolvers.html#document-loading-in-context">Document loading in context</a></li><li class="menu item"><a href="resolvers.html#i-o-access-control-in-xslt">I/O access control in XSLT</a></li></ul></li></ul><ul class="menu foreign" id="extensions"><li class="menu title"><a href="extensions.html">Extension functions for XPath and XSLT</a><ul class="submenu"><li class="menu item"><a href="extensions.html#the-functionnamespace">The FunctionNamespace</a></li><li class="menu item"><a href="extensions.html#global-prefix-assignment">Global prefix assignment</a></li><li class="menu item"><a href="extensions.html#the-xpath-context">The XPath context</a></li><li class="menu item"><a href="extensions.html#evaluators-and-xslt">Evaluators and XSLT</a></li><li class="menu item"><a href="extensions.html#evaluator-local-extensions">Evaluator-local extensions</a></li><li class="menu item"><a href="extensions.html#what-to-return-from-a-function">What to return from a function</a></li></ul></li></ul><ul class="menu foreign" id="element classes"><li class="menu title"><a href="element_classes.html">Using custom Element classes in lxml</a><ul class="submenu"><li class="menu item"><a href="element_classes.html#element-initialization">Element initialization</a></li><li class="menu item"><a href="element_classes.html#setting-up-a-class-lookup-scheme">Setting up a class lookup scheme</a></li><li class="menu item"><a href="element_classes.html#implementing-namespaces">Implementing namespaces</a></li></ul></li></ul><ul class="menu foreign" id="sax"><li class="menu title"><a href="sax.html">Sax support</a><ul class="submenu"><li class="menu item"><a href="sax.html#building-a-tree-from-sax-events">Building a tree from SAX events</a></li><li class="menu item"><a href="sax.html#producing-sax-events-from-an-elementtree-or-element">Producing SAX events from an ElementTree or Element</a></li><li class="menu item"><a href="sax.html#interfacing-with-pulldom-minidom">Interfacing with pulldom/minidom</a></li></ul></li></ul><ul class="menu foreign" id="capi"><li class="menu title"><a href="capi.html">The public C-API of lxml.etree</a><ul class="submenu"><li class="menu item"><a href="capi.html#writing-external-modules-in-cython">Writing external modules in Cython</a></li><li class="menu item"><a href="capi.html#writing-external-modules-in-c">Writing external modules in C</a></li></ul></li></ul></li></ul><ul id="Developing lxml"><li><span class="section title">Developing lxml</span><ul class="menu current" id="build"><li class="menu title"><a href="build.html">How to build lxml from source</a><ul class="submenu"><li class="menu item"><a href="build.html#cython">Cython</a></li><li class="menu item"><a href="build.html#subversion">Subversion</a></li><li class="menu item"><a href="build.html#setuptools">Setuptools</a></li><li class="menu item"><a href="build.html#running-the-tests-and-reporting-errors">Running the tests and reporting errors</a></li><li class="menu item"><a href="build.html#contributing-an-egg">Contributing an egg</a></li><li class="menu item"><a href="build.html#providing-newer-library-versions-on-mac-os-x">Providing newer library versions on Mac-OS X</a></li><li class="menu item"><a href="build.html#static-linking-on-windows">Static linking on Windows</a></li><li class="menu item"><a href="build.html#building-debian-packages-from-svn-sources">Building Debian packages from SVN sources</a></li></ul></li></ul><ul class="menu foreign" id="lxml source howto"><li class="menu title"><a href="lxml-source-howto.html">How to read the source of lxml</a><ul class="submenu"><li class="menu item"><a href="lxml-source-howto.html#what-is-cython?">What is Cython?</a></li><li class="menu item"><a href="lxml-source-howto.html#where-to-start?">Where to start?</a></li><li class="menu item"><a href="lxml-source-howto.html#lxml-etree">lxml.etree</a></li><li class="menu item"><a href="lxml-source-howto.html#python-modules">Python modules</a></li><li class="menu item"><a href="lxml-source-howto.html#lxml-objectify">lxml.objectify</a></li><li class="menu item"><a href="lxml-source-howto.html#lxml-pyclasslookup">lxml.pyclasslookup</a></li><li class="menu item"><a href="lxml-source-howto.html#lxml-html">lxml.html</a></li></ul></li></ul><ul class="menu foreign" id="changes 2 0 11"><li class="menu title"><a href="changes-2.0.11.html">Release Changelog</a></li></ul><ul class="menu foreign" id="credits"><li class="menu title"><a href="credits.html">Credits</a><ul class="submenu"><li class="menu item"><a href="credits.html#special-thanks-goes-to:">Special thanks goes to:</a></li></ul></li></ul></li></ul></div><h1 class="title">How to build lxml from source</h1> <p>To build lxml from source, you need libxml2 and libxslt properly installed, <em>including the header files</em>. These are likely shipped in separate <tt class="docutils literal"><span class="pre">-dev</span></tt> or <tt class="docutils literal"><span class="pre">-devel</span></tt> packages like <tt class="docutils literal"><span class="pre">libxml2-dev</span></tt>, which you need to install. The build process also requires <a class="reference" href="http://peak.telecommunity.com/DevCenter/setuptools">setuptools</a>. The lxml source distribution comes with a script called <tt class="docutils literal"><span class="pre">ez_setup.py</span></tt> that can be used to install them.</p> <div class="contents topic"> <p class="topic-title first"><a id="contents" name="contents">Contents</a></p> <ul class="simple"> <li><a class="reference" href="#cython" id="id3" name="id3">Cython</a></li> <li><a class="reference" href="#subversion" id="id4" name="id4">Subversion</a></li> <li><a class="reference" href="#id2" id="id5" name="id5">Setuptools</a></li> <li><a class="reference" href="#running-the-tests-and-reporting-errors" id="id6" name="id6">Running the tests and reporting errors</a></li> <li><a class="reference" href="#contributing-an-egg" id="id7" name="id7">Contributing an egg</a></li> <li><a class="reference" href="#providing-newer-library-versions-on-mac-os-x" id="id8" name="id8">Providing newer library versions on Mac-OS X</a></li> <li><a class="reference" href="#static-linking-on-windows" id="id9" name="id9">Static linking on Windows</a></li> <li><a class="reference" href="#building-debian-packages-from-svn-sources" id="id10" name="id10">Building Debian packages from SVN sources</a></li> </ul> </div> <div class="section"> <h1><a id="cython" name="cython">Cython</a></h1> <p>The lxml.etree and lxml.objectify modules are written in <a class="reference" href="http://www.cython.org">Cython</a>. Since we distribute the Cython-generated .c files with lxml releases, however, you do not need Cython to build lxml from the normal release sources. We even encourage you to <em>not install Cython</em> for a normal release build, as the generated C code can vary quite heavily between Cython versions, which may or may not generate correct code for lxml. The pre-generated release sources were tested and therefore are known to work.</p> <p>So, if you want a reliable build of lxml, we suggest to a) use a source release of lxml and b) disable or uninstall Cython for the build.</p> <p><em>Only</em> if you are interested in building lxml from a Subversion checkout (e.g. to test a bug fix that has not been release yet) or if want to be an lxml developer, then you do need a working Cython installation. You can use <a class="reference" href="http://peak.telecommunity.com/DevCenter/EasyInstall">EasyInstall</a> to install it:</p> <pre class="literal-block"> easy_install Cython==0.9.6.12 </pre> <p>lxml currently requires Cython 0.9.6.11b or 0.9.6.12, later versions were not tested.</p> </div> <div class="section"> <h1><a id="subversion" name="subversion">Subversion</a></h1> <p>The lxml package is developed in a Subversion repository. You can retrieve the current developer version by calling:</p> <pre class="literal-block"> svn co http://codespeak.net/svn/lxml/trunk lxml </pre> <p>This will create a directory <tt class="docutils literal"><span class="pre">lxml</span></tt> and download the source into it. You can also <a class="reference" href="http://codespeak.net/svn/lxml">browse the repository through the web</a> or use your favourite SVN client to access it.</p> </div> <div class="section"> <h1><a id="id2" name="id2">Setuptools</a></h1> <p>Usually, building lxml is done through setuptools. Do a Subversion checkout (or download the source tar-ball and unpack it) and then type:</p> <pre class="literal-block"> python setup.py build </pre> <p>or:</p> <pre class="literal-block"> python setup.py bdist_egg </pre> <p>If you want to test lxml from the source directory, it is better to build it in-place like this:</p> <pre class="literal-block"> python setup.py build_ext -i </pre> <p>or, in Unix-like environments:</p> <pre class="literal-block"> make </pre> <p>If you get errors about missing header files (e.g. <tt class="docutils literal"><span class="pre">libxml/xmlversion.h</span></tt>) then you need to make sure the development packages of both libxml2 and libxslt are properly installed. Try passing the following option to setup.py to make sure the right config is found:</p> <pre class="literal-block"> python setup.py build --with-xslt-config=/path/to/xslt-config </pre> <p>If this doesn't help, you may have to add the location of the header files to the include path like:</p> <pre class="literal-block"> python setup.py build_ext -i -I /usr/include/libxml2 </pre> <p>where the file is in <tt class="docutils literal"><span class="pre">/usr/include/libxml2/libxml/xmlversion.h</span></tt></p> <p>To use lxml.etree in-place, you can place lxml's <tt class="docutils literal"><span class="pre">src</span></tt> directory on your Python module search path (PYTHONPATH) and then import <tt class="docutils literal"><span class="pre">lxml.etree</span></tt> to play with it:</p> <pre class="literal-block"> # cd lxml # PYTHONPATH=src python Python 2.5.1 Type "help", "copyright", "credits" or "license" for more information. >>> from lxml import etree >>> </pre> <p>To recompile after changes, note that you may have to run <tt class="docutils literal"><span class="pre">make</span> <span class="pre">clean</span></tt> or delete the file <tt class="docutils literal"><span class="pre">src/lxml/etree.c</span></tt>. Distutils do not automatically pick up changes that affect files other than the main file <tt class="docutils literal"><span class="pre">src/lxml/etree.pyx</span></tt>.</p> </div> <div class="section"> <h1><a id="running-the-tests-and-reporting-errors" name="running-the-tests-and-reporting-errors">Running the tests and reporting errors</a></h1> <p>The source distribution (tgz) and the Subversion repository contain a test suite for lxml. You can run it from the top-level directory:</p> <pre class="literal-block"> python test.py </pre> <p>Note that the test script only tests the in-place build (see distutils building above), as it searches the <tt class="docutils literal"><span class="pre">src</span></tt> directory. You can use the following one-step command to trigger an in-place build and test it:</p> <pre class="literal-block"> make test </pre> <p>This also runs the ElementTree and cElementTree compatibility tests. To call them separately, make sure you have lxml on your PYTHONPATH first, then run:</p> <pre class="literal-block"> python selftest.py </pre> <p>and:</p> <pre class="literal-block"> python selftest2.py </pre> <p>If the tests give failures, errors, or worse, segmentation faults, we'd really like to know. Please contact us on the <a class="reference" href="http://codespeak.net/mailman/listinfo/lxml-dev">mailing list</a>, and please specify the version of lxml, libxml2, libxslt and Python you were using, as well as your operating system type (Linux, Windows, MacOs, ...).</p> </div> <div class="section"> <h1><a id="contributing-an-egg" name="contributing-an-egg">Contributing an egg</a></h1> <p>This is the procedure to make an lxml egg for your platform:</p> <ul class="simple"> <li>Download the lxml-x.y.tar.gz release. This contains the pregenerated C so that you can be sure you build exactly from the release sources. Unpack them and cd into the resulting directory.</li> <li>python setup.py build</li> <li>If you're on a unixy platform, cd into <tt class="docutils literal"><span class="pre">build/lib.your.platform</span></tt> and strip any <tt class="docutils literal"><span class="pre">.so</span></tt> file you find there. This reduces the size of the egg considerably.</li> <li><tt class="docutils literal"><span class="pre">python</span> <span class="pre">setup.py</span> <span class="pre">bdist_egg</span> <span class="pre">upload</span></tt></li> </ul> <p>The last 'upload' step only works if you have access to the lxml cheeseshop entry. If not, you can just make an egg with <tt class="docutils literal"><span class="pre">bdist_egg</span></tt> and mail it to the lxml maintainer.</p> </div> <div class="section"> <h1><a id="providing-newer-library-versions-on-mac-os-x" name="providing-newer-library-versions-on-mac-os-x">Providing newer library versions on Mac-OS X</a></h1> <p>The Unix environment in Mac-OS X makes it relatively easy to install Unix/Linux style package management tools and new software. However, it seems to be hard to get libraries set up for exclusive usage that Mac-OS X ships in an older version. The result can be segfaults on this platform that are hard to track down.</p> <p>To make sure the newer libxml2 and libxslt versions (e.g. those provided by fink or macports) are used at <em>build time</em>, you must take care that the script <tt class="docutils literal"><span class="pre">xslt-config</span></tt> is found from the newly installed version when running the build setup. The system libraries also provide this script, but the new one must come first in the PATH. The best way to make sure the right version is used is by passing the path to the script as an option to setup.py:</p> <pre class="literal-block"> python setup.py build --with-xslt-config=/path/to/xslt-config \ --with-xml2-config=/path/to/xml2-config </pre> <p>To make sure the newer libxml2 and libxslt versions are used at <em>runtime</em>, you should add <em>all</em> directories where the newer libraries are installed (i.e. libxml2, libxslt and libexslt) to the <tt class="docutils literal"><span class="pre">DYLD_LIBRARY_PATH</span></tt> environment variable when you use lxml (i.e. not only at build time). This seems to fix a lot of problems for users.</p> <p>Please read this thread about <a class="reference" href="http://thread.gmane.org/gmane.comp.python.lxml.devel/3290/focus=3290">experiences with MacOS-X</a> if you encounter problems. It also has a <a class="reference" href="http://thread.gmane.org/gmane.comp.python.lxml.devel/3290/focus=3297">buildout for lxml</a> that you can use.</p> </div> <div class="section"> <h1><a id="static-linking-on-windows" name="static-linking-on-windows">Static linking on Windows</a></h1> <p>Most operating systems have proper package management that makes installing current versions of libxml2 and libxslt easy. The most famous exception is Microsoft Windows, which entirely lacks these capabilities. It can therefore be interesting to statically link the external libraries into lxml.etree to avoid having to install them separately.</p> <p>Download lxml and all required libraries to the same directory. The iconv, libxml2, libxslt, and zlib libraries are all available from the ftp site <a class="reference" href="ftp://ftp.zlatkovic.com/pub/libxml/">ftp://ftp.zlatkovic.com/pub/libxml/</a>.</p> <p>Your directory should now have the following files in it (although most likely different versions):</p> <pre class="literal-block"> iconv-1.9.1.win32.zip libxml2-2.6.23.win32.zip libxslt-1.1.15.win32.zip lxml-1.0.0.tgz zlib-1.2.3.win32.zip </pre> <p>Now extract each of those files in the <em>same</em> directory. This should give you something like this:</p> <pre class="literal-block"> iconv-1.9.1.win32/ iconv-1.9.1.win32.zip libxml2-2.6.23.win32/ libxml2-2.6.23.win32.zip libxslt-1.1.15.win32/ libxslt-1.1.15.win32.zip lxml-1.0.0/ lxml-1.0.0.tgz zlib-1.2.3.win32/ zlib-1.2.3.win32.zip </pre> <p>Go to the lxml directory and edit the file <tt class="docutils literal"><span class="pre">setup.py</span></tt>. There should be a section near the top that looks like this:</p> <pre class="literal-block"> STATIC_INCLUDE_DIRS = [] STATIC_LIBRARY_DIRS = [] STATIC_CFLAGS = [] </pre> <p>Change this section to something like this, but take care to use the correct version numbers:</p> <pre class="literal-block"> STATIC_INCLUDE_DIRS = [ "..\\libxml2-2.6.23.win32\\include", "..\\libxslt-1.1.15.win32\\include", "..\\zlib-1.2.3.win32\\include", "..\\iconv-1.9.1.win32\\include" ] STATIC_LIBRARY_DIRS = [ "..\\libxml2-2.6.23.win32\\lib", "..\\libxslt-1.1.15.win32\\lib", "..\\zlib-1.2.3.win32\\lib", "..\\iconv-1.9.1.win32\\lib" ] STATIC_CFLAGS = [] </pre> <p>Add any CFLAGS you might consider useful to the third list. As <a class="reference" href="http://codespeak.net/pipermail/lxml-dev/2006-September/001893.html">Ashish Kulkarni</a> notes, you might have to add the standard Windows library <tt class="docutils literal"><span class="pre">wsock32.dll</span></tt> to the list of libraries to make <tt class="docutils literal"><span class="pre">lxml.objectify</span></tt> compile.</p> <p>Now you should be able to pass the <tt class="docutils literal"><span class="pre">--static</span></tt> option to setup.py and everything should work well. Try calling:</p> <pre class="literal-block"> python setup.py bdist_wininst --static </pre> <p>This will create a windows installer in the <tt class="docutils literal"><span class="pre">pkg</span></tt> directory.</p> </div> <div class="section"> <h1><a id="building-debian-packages-from-svn-sources" name="building-debian-packages-from-svn-sources">Building Debian packages from SVN sources</a></h1> <p><a class="reference" href="http://codespeak.net/pipermail/lxml-dev/2006-May/001254.html">Andreas Pakulat</a> proposed the following approach.</p> <ul class="simple"> <li><tt class="docutils literal"><span class="pre">apt-get</span> <span class="pre">source</span> <span class="pre">lxml</span></tt></li> <li>remove the unpacked directory</li> <li>tar.gz the lxml SVN version and replace the orig.tar.gz that lies in the directory</li> <li>check md5sum of created tar.gz file and place new sum and size in dsc file</li> <li>do <tt class="docutils literal"><span class="pre">dpkg-source</span> <span class="pre">-x</span> <span class="pre">lxml-[VERSION].dsc</span></tt> and cd into the newly created directory</li> <li>run <tt class="docutils literal"><span class="pre">dch</span> <span class="pre">-i</span></tt> and add a comment like "use trunk version", this will increase the debian version number so apt/dpkg won't get confused</li> <li>run <tt class="docutils literal"><span class="pre">dpkg-buildpackage</span> <span class="pre">-rfakeroot</span> <span class="pre">-us</span> <span class="pre">-uc</span></tt> to build the package</li> </ul> <p>In case <tt class="docutils literal"><span class="pre">dpkg-buildpackage</span></tt> tells you that some dependecies are missing, you can either install them manually or run <tt class="docutils literal"><span class="pre">apt-get</span> <span class="pre">build-dep</span> <span class="pre">lxml</span></tt>.</p> <p>That will give you .deb packages in the parent directory which can be installed using <tt class="docutils literal"><span class="pre">dpkg</span> <span class="pre">-i</span></tt>.</p> </div> </div> <div class="footer"> <hr class="footer" /> Generated on: 2008-12-12. </div> </body> </html>