[lxml-dev] lxml Mac installation idea

Guntsche Michael mike at it-loops.com
Fri Nov 14 01:27:24 CET 2008


Ok,

A new patch. We always create an universal binary if we are running on  
Macosx > 10.3. Furthermore the environment variables are removed  
before we compile lxml itself.
Going to bed now will test this on my Tiger PPC machine tomorrow  
afternoon.

Gnite,
Mike

Index: buildlibxml.py
===================================================================
--- buildlibxml.py	(revision 59905)
+++ buildlibxml.py	(working copy)
@@ -165,7 +165,19 @@
      prefix = os.path.join(os.path.abspath(build_dir), 'libxml2')
      safe_mkdir(prefix)

-    configure_cmd = ['./configure', '--without-python',
+
+    # We compile Universal if we are on a machine > 10.4.0
+    major_version = int(os.uname()[2].split('.')[0])
+
+    if major_version > 7:
+        os.environ['CFLAGS'] = "-arch ppc -arch i386 -isysroot / 
Developer/SDKs/MacOSX10.4u.sdk -O2"
+        os.environ['LDFLAGS'] = "-arch ppc -arch i386 -isysroot / 
Developer/SDKs/MacOSX10.4u.sdk"
+        os.environ['MACOSX_DEPLOYMENT_TARGET'] = "10.3"
+
+    # We are loosing the link to iconv add it again
+    static_binaries.append('-liconv')
+
+    configure_cmd = ['./configure', '--without-python' ,
                       '--disable-dependency-tracking',
                       '--disable-shared', '--prefix=%s' % prefix]
      call_subprocess(configure_cmd, cwd=libxml2_dir)
@@ -174,7 +186,7 @@
      call_subprocess(
          ['make', 'install'], cwd=libxml2_dir)

-    libxslt_configure_cmd = configure_cmd + ['--with-libxml-prefix= 
%s' % prefix]
+    libxslt_configure_cmd = configure_cmd + ['--with-libxml-prefix= 
%s' % prefix, '--without-crypto']
      call_subprocess(libxslt_configure_cmd, cwd=libxslt_dir)
      call_subprocess(
          ['make'], cwd=libxslt_dir)
@@ -191,10 +203,9 @@
              os.path.join(prefix, 'include', 'libexslt')])
      static_library_dirs.append(lib_dir)

-    unisdk_dir = sysconfig.get_config_var('UNIVERSALSDK')
-    if unisdk_dir:
-        static_cflags.extend(['-isysroot', unisdk_dir,
-                              '-arch', '-i386', '-arch', 'ppc'])
+    if major_version > 7:
+        for env in ('CFLAGS', 'LDFLAGS', 'MACOSX_DEPLOYMENT_TARGET'):
+            os.environ.pop(env)

      for filename in os.listdir(lib_dir):
          if [l for l in ['libxml2', 'libxslt', 'libexslt'] if l in  
filename]:



More information about the lxml-dev mailing list