changeset 2949:a9d953a52fe2

separate specs for python2.5 and python2.4
author hanwen <hanwen@lilypond.org>
date Sun, 03 Dec 2006 16:51:54 +0100
parents f6ba638a6ca7
children 84a3bddbb08d
files specs/python.py specs/python25.py
diffstat 2 files changed, 191 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/specs/python.py	Wed Nov 29 00:45:49 2006 +0100
+++ b/specs/python.py	Sun Dec 03 16:51:54 2006 +0100
@@ -11,23 +11,13 @@
 class Python (targetpackage.TargetBuildSpec):
     def __init__ (self, settings):
         targetpackage.TargetBuildSpec.__init__ (self, settings)
-        
-        ## don't import settings from build system.
-	self.BASECFLAGS=''
-        self.with (version='2.5',
+        self.with (version='2.4.2',
                    mirror=download.python,
                    format='bz2')
 
-    def configure_command (self):
-        return 'ac_cv_printf_zd_format=yes ' + targetpackage.TargetBuildSpec.configure_command (self)
+        ## don't import settings from build system.
+	self.BASECFLAGS=''
 
-    def patch (self):
-        self.system ('cd %(srcdir)s && patch -p1 < %(patchdir)s/python-2.5.patch')
-
-        self.file_sub ([(r"'/usr/include'",
-                         r"'%(system_root)s/usr/include'")],
-                       "%(srcdir)s/setup.py", must_succeed=True)
-                        
     def license_file (self):
         return '%(srcdir)s/LICENSE'
 
@@ -42,6 +32,14 @@
                  'devel' : ['libtool', 'python-devel'],
                  'runtime': [], }
 
+    def patch (self):
+        targetpackage.TargetBuildSpec.patch (self)
+        self.system ('cd %(srcdir)s && patch -p1 < %(patchdir)s/python-2.4.2-1.patch')
+        self.system ('cd %(srcdir)s && patch -p0 < %(patchdir)s/python-configure.in-posix.patch')
+        self.system ('cd %(srcdir)s && patch -p0 < %(patchdir)s/python-configure.in-sysname.patch')
+        self.system ('cd %(srcdir)s && patch -p1 < %(patchdir)s/python-2.4.2-configure.in-sysrelease.patch')
+        self.system ('cd %(srcdir)s && patch -p0 < %(patchdir)s/python-2.4.2-setup.py-import.patch')
+
     def configure (self):
         self.system ('''cd %(srcdir)s && autoconf''')
         self.system ('''cd %(srcdir)s && libtoolize --copy --force''')
@@ -78,7 +76,24 @@
     def python_version (self):
         return '.'.join (self.ball_version.split ('.')[0:2])
 
-class Python__mingw (Python):
+class Python__mingw_binary (gub.BinarySpec):
+    def __init__ (self, settings):
+        gub.BinarySpec.__init__ (self, settings)
+        self.with (mirror="http://lilypond.org/~hanwen/python-2.4.2-windows.tar.gz",
+                   version='2.4.2')
+
+    def python_version (self):
+        return '2.4'
+
+    def install (self):
+        gub.BinarySpec.install (self)
+
+        self.system ("cd %(install_root)s/ && mkdir usr && mv Python24/include  usr/ ")
+        self.system ("cd %(install_root)s/ && mkdir -p usr/bin/ && mv Python24/* usr/bin/ ")
+        self.system ("rmdir %(install_root)s/Python24/")
+
+
+class Python__mingw_cross (Python):
     def __init__ (self, settings):
         Python.__init__ (self, settings)
         self.target_gcc_flags = '-DMS_WINDOWS -DPy_WIN_WIDE_FILENAMES -I%(system_root)s/usr/include' % self.settings.__dict__
@@ -87,29 +102,24 @@
     # 2.4.2 and combined in one patch; move to cross-Python?
     def patch (self):
         Python.patch (self)
-        if 0:
-            self.system ('''
+        self.system ('''
 cd %(srcdir)s && patch -p1 < %(patchdir)s/python-2.4.2-winsock2.patch
 ''')
         self.system ('cd %(srcdir)s && patch -p0 < %(patchdir)s/python-2.4.2-setup.py-selectmodule.patch')
-    def compile (self):
-        Python.compile (self)
 
-    def configure (self):
-        Python.configure (self)
-        self.file_sub ([('pwd pwdmodule.c', '')],
-                       '%(builddir)s/Modules/Setup')
-        self.file_sub ([(' Modules/pwdmodule.o ', ' ')],
-                       '%(builddir)s/Makefile')
-        self.system ("cp %(srcdir)s/PC/errmap.h %(builddir)s/")
-        
+        ## to make subprocess.py work.
+        self.file_sub ([
+                ("import fcntl", ""),
+                ], "%(srcdir)s/Lib/subprocess.py",
+               must_succeed=True)
+
     def config_cache_overrides (self, str):
         # Ok, I give up.  The python build system wins.  Once
         # someone manages to get -lwsock32 on the
         # sharedmodules link command line, *after*
         # timesmodule.o, this can go away.
         return re.sub ('ac_cv_func_select=yes', 'ac_cv_func_select=no',
-                       str)
+               str)
 
     def install (self):
         Python.install (self)
@@ -126,11 +136,15 @@
 chmod 755 %(install_root)s/usr/bin/*
 ''')
 
+class Python__mingw (Python__mingw_cross):
+    pass
+
+
 import toolpackage
 class Python__local (toolpackage.ToolBuildSpec, Python):
     def __init__ (self, settings):
         toolpackage.ToolBuildSpec.__init__ (self, settings)
-        self.with (version='2.5',
+        self.with (version='2.4.2',
                    mirror=download.python,
                    format='bz2')
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/specs/python25.py	Sun Dec 03 16:51:54 2006 +0100
@@ -0,0 +1,149 @@
+import re
+import sys
+#
+import download
+import glob
+import gub
+import targetpackage
+
+from context import *
+
+class Python (targetpackage.TargetBuildSpec):
+    def __init__ (self, settings):
+        targetpackage.TargetBuildSpec.__init__ (self, settings)
+        
+        ## don't import settings from build system.
+	self.BASECFLAGS=''
+        self.with (version='2.5',
+                   mirror=download.python,
+                   format='bz2')
+
+    def configure_command (self):
+        return 'ac_cv_printf_zd_format=yes ' + targetpackage.TargetBuildSpec.configure_command (self)
+
+    def patch (self):
+        self.system ('cd %(srcdir)s && patch -p1 < %(patchdir)s/python-2.5.patch')
+
+        self.file_sub ([(r"'/usr/include'",
+                         r"'%(system_root)s/usr/include'")],
+                       "%(srcdir)s/setup.py", must_succeed=True)
+                        
+    def license_file (self):
+        return '%(srcdir)s/LICENSE'
+
+    def get_subpackage_names (self):
+        return ['doc', 'devel', 'runtime', '']
+
+    def get_build_dependencies (self):
+        return ['expat-devel', 'zlib-devel']
+
+    def get_dependency_dict (self):
+        return { '': ['expat', 'python-runtime', 'zlib'],
+                 'devel' : ['libtool', 'python-devel'],
+                 'runtime': [], }
+
+    def configure (self):
+        self.system ('''cd %(srcdir)s && autoconf''')
+        self.system ('''cd %(srcdir)s && libtoolize --copy --force''')
+        targetpackage.TargetBuildSpec.configure (self)
+
+    def compile_command (self):
+        ##
+        ## UGH.: darwin Python vs python (case insensitive FS)
+        c = targetpackage.TargetBuildSpec.compile_command (self)
+        c += ' BUILDPYTHON=python-bin '
+        return c
+
+    def install_command (self):
+        ##
+        ## UGH.: darwin Python vs python (case insensitive FS)
+        c = targetpackage.TargetBuildSpec.install_command (self)
+        c += ' BUILDPYTHON=python-bin '
+        return c
+
+    # FIXME: c&p linux.py:install ()
+    def install (self):
+        targetpackage.TargetBuildSpec.install (self)
+        cfg = open (self.expand ('%(sourcefiledir)s/python-config.py.in')).read ()
+        cfg = re.sub ('@PYTHON_VERSION@', self.expand ('%(version)s'), cfg)
+        cfg = re.sub ('@PREFIX@', self.expand ('%(system_root)s/usr/'), cfg)
+        cfg = re.sub ('@PYTHON_FOR_BUILD@', sys.executable, cfg)
+        self.dump (cfg, '%(install_root)s/usr/cross/bin/python-config',
+                   expand_string=False)
+        self.system ('chmod +x %(install_root)s/usr/cross/bin/python-config')
+
+
+    ### Ugh.
+    @subst_method
+    def python_version (self):
+        return '.'.join (self.ball_version.split ('.')[0:2])
+
+class Python__mingw (Python):
+    def __init__ (self, settings):
+        Python.__init__ (self, settings)
+        self.target_gcc_flags = '-DMS_WINDOWS -DPy_WIN_WIDE_FILENAMES -I%(system_root)s/usr/include' % self.settings.__dict__
+
+    # FIXME: first is cross compile + mingw patch, backported to
+    # 2.4.2 and combined in one patch; move to cross-Python?
+    def patch (self):
+        Python.patch (self)
+        if 0:
+            self.system ('''
+cd %(srcdir)s && patch -p1 < %(patchdir)s/python-2.4.2-winsock2.patch
+''')
+        self.system ('cd %(srcdir)s && patch -p0 < %(patchdir)s/python-2.4.2-setup.py-selectmodule.patch')
+    def compile (self):
+        Python.compile (self)
+
+    def configure (self):
+        Python.configure (self)
+        self.file_sub ([('pwd pwdmodule.c', '')],
+                       '%(builddir)s/Modules/Setup')
+        self.file_sub ([(' Modules/pwdmodule.o ', ' ')],
+                       '%(builddir)s/Makefile')
+        self.system ("cp %(srcdir)s/PC/errmap.h %(builddir)s/")
+        
+    def config_cache_overrides (self, str):
+        # Ok, I give up.  The python build system wins.  Once
+        # someone manages to get -lwsock32 on the
+        # sharedmodules link command line, *after*
+        # timesmodule.o, this can go away.
+        return re.sub ('ac_cv_func_select=yes', 'ac_cv_func_select=no',
+                       str)
+
+    def install (self):
+        Python.install (self)
+        for i in glob.glob ('%(install_root)s/usr/lib/python%(python_version)s/lib-dynload/*.so*' \
+                  % self.get_substitution_dict ()):
+            dll = re.sub ('\.so*', '.dll', i)
+            self.system ('mv %(i)s %(dll)s', locals ())
+
+        ## UGH.
+        self.system ('''
+cp %(install_root)s/usr/lib/python%(python_version)s/lib-dynload/* %(install_root)s/usr/bin
+''')
+        self.system ('''
+chmod 755 %(install_root)s/usr/bin/*
+''')
+
+import toolpackage
+class Python__local (toolpackage.ToolBuildSpec, Python):
+    def __init__ (self, settings):
+        toolpackage.ToolBuildSpec.__init__ (self, settings)
+        self.with (version='2.5',
+                   mirror=download.python,
+                   format='bz2')
+
+    def configure (self):
+        self.system ('''cd %(srcdir)s && autoconf''')
+        self.system ('''cd %(srcdir)s && libtoolize --copy --force''')
+        targetpackage.TargetBuildSpec.configure (self)
+    def install (self):
+        toolpackage.ToolBuildSpec.install (self)
+
+
+    def license_file (self):
+        return '%(srcdir)s/LICENSE'
+
+    def wrap_executables (self):
+        pass