[lxml-dev] install lxml 2.0.5 on Mac OS X Leopard - why is it so hard?

Kumar McMillan kumar.mcmillan at gmail.com
Fri May 16 04:47:11 CEST 2008


On Thu, May 15, 2008 at 6:03 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
>> if sys.platform in ('darwin',):
>>     result.append('-flat_namespace')
>
> That's cool, thanks. I added it to the trunk and to the 2.0 branch.

excellent

> Let's see
> if Mac users get along with 2.0.6 then...
>
> Thanks for the effort!

sure, no problem.

I researched this a bit more.  It seems that people generally consider
-flat_namespace a bad "hack," something to keep in mind.  However,
this seems to be because a few libraries take advantage of
-twolevel_namespace (the default gcc behavior as of OS X 10.3 or
something) so your binaries may cause other linked libs to behave
wrong.  The only specific example I could find of one that uses two
level namespaces was OpenGL, but maybe there are others.

Anyway, for lxml's purposes *I think* it is OK to use -flat_namespace
since there aren't many other libs involved.  Let's roll with it.
This is what etree links to :

$ otool -l path/to/lxml/etree.so

[snip]

Load command 7
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/local/lib/libxslt.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 18:00:02 1969
      current version 3.23.0
compatibility version 3.0.0
Load command 8
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/local/lib/libexslt.0.dylib (offset 24)
   time stamp 2 Wed Dec 31 18:00:02 1969
      current version 9.13.0
compatibility version 9.0.0
Load command 9
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/local/lib/libxml2.2.dylib (offset 24)
   time stamp 2 Wed Dec 31 18:00:02 1969
      current version 9.32.0
compatibility version 9.0.0
Load command 10
          cmd LC_LOAD_DYLIB
      cmdsize 52
         name /opt/local/lib/libz.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 18:00:02 1969
      current version 1.2.3
compatibility version 1.0.0
Load command 11
          cmd LC_LOAD_DYLIB
      cmdsize 52
         name /usr/lib/libSystem.B.dylib (offset 24)
   time stamp 2 Wed Dec 31 18:00:02 1969
      current version 88.3.6
compatibility version 1.0.0


... so unless libSystem.B.dylib somehow would be tripped up by
-flat_namespace I think all should be good.


BTW, when I add those two lines all tests pass for me (they passed
before but, hey, still a good sign) :

Index: setupinfo.py
===================================================================
--- setupinfo.py        (revision 54771)
+++ setupinfo.py        (working copy)
@@ -136,6 +136,8 @@
     for possible_cflag in possible_cflags:
         if not possible_cflag.startswith('-I'):
             result.append(possible_cflag)
+    if sys.platform in ('darwin',):
+        result.append('-flat_namespace')
     return result

 def define_macros():


-Kumar


More information about the lxml-dev mailing list