Mercurial > gub
changeset 6208:08125e83bb42
Python transition: keep toplevel 'python' name after version switch.
author | Jan Nieuwenhuizen <janneke@gnu.org> |
---|---|
date | Tue, 28 Aug 2012 11:52:31 +0200 |
parents | 895c23f49db3 |
children | e8095501db4e |
files | gub/specs/python-2.4.py gub/specs/python-2.6.py gub/specs/python.py gub/specs/xcb-proto.py gub/tools.py |
diffstat | 5 files changed, 255 insertions(+), 243 deletions(-) [+] |
line wrap: on
line diff
--- a/gub/specs/python-2.4.py Tue Aug 28 11:26:57 2012 +0200 +++ b/gub/specs/python-2.4.py Tue Aug 28 11:52:31 2012 +0200 @@ -1,22 +1,215 @@ +import re +# +from gub import build +from gub import context +from gub import misc from gub import target from gub import tools -from gub.specs import python + +class Python_2_4 (target.AutoBuild): + source = 'http://python.org/ftp/python/2.4.5/Python-2.4.5.tar.bz2' + #source = 'http://python.org/ftp/python/2.4.2/Python-2.4.2.tar.bz2' + patches_242 = [ + 'python-2.4.2-1.patch', + 'python-configure.in-posix.patch&strip=0', + 'python-configure.in-sysname.patch&strip=0', + 'python-2.4.2-configure.in-sysrelease.patch', + 'python-2.4.2-setup.py-import.patch&strip=0', + 'python-2.4.2-setup.py-cross_root.patch&strip=0', + 'python-2.4.2-fno-stack-protector.patch', + ] -def get_conflict_dict (self): - return { - '': ['python-2.6', 'python'], - 'doc': ['python-2.6-doc', 'python-doc'], - 'devel': ['python-2.6-devel', 'python-devel'], - 'runtime': ['python-2.6-runtime', 'python-runtime'], - } + patches = [ + 'python-2.4.5-1.patch', + 'python-configure.in-posix.patch&strip=0', + 'python-2.4.5-configure.in-sysname.patch', + 'python-2.4.2-configure.in-sysrelease.patch', + 'python-2.4.2-setup.py-import.patch&strip=0', + 'python-2.4.2-setup.py-cross_root.patch&strip=0', +# 'python-2.4.2-fno-stack-protector.patch', + 'python-2.4.5-python-2.6.patch', + 'python-2.4.5-native.patch', + 'python-2.4.5-db4.7.patch', + 'python-2.4.5-setup-cross.patch', + ] + dependencies = ['db-devel', 'expat-devel', 'zlib-devel', 'tools::python'] + force_autoupdate = True + subpackage_names = ['doc', 'devel', 'runtime', ''] + so_modules = [ + 'itertools', + 'struct', + 'time', + ] + not_supported = [] + make_flags = misc.join_lines (r''' +BLDLIBRARY='%(rpath)s -L. -lpython$(VERSION)' +''') + def get_conflict_dict (self): + return { + '': ['python-2.6', 'python-2.4'], + 'doc': ['python-2.6-doc', 'python-2.4-doc'], + 'devel': ['python-2.6-devel', 'python-2.4-devel'], + 'runtime': ['python-2.6-runtime', 'python-2.4-runtime'], + } + def __init__ (self, settings, source): + target.AutoBuild.__init__ (self, settings, source) + self.CROSS_ROOT = '%(targetdir)s' + if 'stat' in misc.librestrict (): + self.install_command = ('LIBRESTRICT_ALLOW=/usr/lib/python2.4/lib-dynload:${LIBRESTRICT_ALLOW-/foo} ' + + target.AutoBuild.install_command) + def patch (self): + target.AutoBuild.patch (self) + self.file_sub ([('@CC@', '@CC@ -I%(builddir)s')], + '%(srcdir)s/Makefile.pre.in') + def autoupdate (self): + target.AutoBuild.autoupdate (self) + # FIXME: REMOVEME/PROMOTEME to target.py? + if self.settings.build_platform == self.settings.target_platform: + self.file_sub ([('cross_compiling=(maybe|no|yes)', + 'cross_compiling=no')], '%(srcdir)s/configure') + def install (self): + target.AutoBuild.install (self) + misc.dump_python_config (self) + def assert_fine (logger): + dynload_dir = self.expand ('%(install_prefix)s/lib/python%(python_version)s/lib-dynload') + so = self.expand ('%(so_extension)s') + all = [x.replace (dynload_dir + '/', '') for x in misc.find_files (dynload_dir, '.*' + so)] + failed = [x.replace (dynload_dir + '/', '') for x in misc.find_files (dynload_dir, '.*failed' + so)] + for i in self.not_supported: + m = i + '_failed' + so + if m in failed: + failed.remove (m) + if failed: + logger.write_log ('failed python modules:' + ', '.join (failed), 'error') + for module in self.so_modules: + if not module + so in all: + logger.write_log ('all python modules:' + ', '.join (all), 'error') + raise Exception ('Python module failed: ' + module) + self.func (assert_fine) + ### Ugh. + @context.subst_method + def python_version (self): + return '.'.join (self.version ().split ('.')[0:2]) + +class Python_2_4__mingw_binary (build.BinaryBuild): + source = 'http://lilypond.org/~hanwen/python-2.4.2-windows.tar.gz' + + def python_version (self): + return '2.4' + + def install (self): + build.BinaryBuild.install (self) + self.system (''' +cd %(install_root)s && mkdir usr && mv Python24/include usr +cd %(install_root)s && mkdir -p usr/bin/ && mv Python24/* usr/bin +rmdir %(install_root)s/Python24 +''') -class Python_2_4 (python.Python): - get_conflict_dict = get_conflict_dict -class Python_2_4__mingw (python.Python__mingw): - get_conflict_dict = get_conflict_dict -class Python_2_4__mingw_binary (python.Python__mingw_binary): - get_conflict_dict = get_conflict_dict -class Python_2_4__freebsd (python.Python__freebsd): - get_conflict_dict = get_conflict_dict -class Python_2_4__tools (python.Python__tools): - get_conflict_dict = get_conflict_dict +class Python_2_4__freebsd (Python_2_4): + def configure (self): + Python_2_4.configure (self) + self.file_sub ([ + ('^LDSHARED=.*', 'LDSHARED = $(CC) -shared'), + ('BLDSHARED=.*', 'BLDSHARED = $(CC) -shared'), + ], '%(builddir)s/Makefile') + +class Python_2_4__mingw (Python_2_4): + patches = Python_2_4.patches + [ + 'python-2.4.2-winsock2.patch', + 'python-2.4.2-setup.py-selectmodule.patch', + 'python-2.4.5-disable-pwd-mingw.patch', + 'python-2.4.5-mingw-site.patch', + 'python-2.4.5-mingw-socketmodule.patch', + ] + config_cache_overrides = (Python_2_4.config_cache_overrides + #FIXME: promoteme? see Gettext/Python + .replace ('ac_cv_func_select=yes', + 'ac_cv_func_select=no') + + ''' +ac_cv_pthread_system_supported=yes, +ac_cv_sizeof_pthread_t=12 +''') + def __init__ (self, settings, source): + Python_2_4.__init__ (self, settings, source) + self.target_gcc_flags = '-DMS_WINDOWS -DPy_WIN_WIDE_FILENAMES -I%(system_prefix)s/include' % self.settings.__dict__ + dependencies = Python_2_4.dependencies + ['pthreads-w32-devel'] + # 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_2_4.patch (self) + self.file_sub ([ + ('(== "win32")', r'in ("win32", "mingw32")'), + ], "%(srcdir)s/Lib/subprocess.py", + must_succeed=True) + def configure (self): + Python_2_4.configure (self) + self.dump (''' +_subprocess ../PC/_subprocess.c +msvcrt ../PC/msvcrtmodule.c +''', + '%(builddir)s/Modules/Setup', + mode='a') + def compile (self): + self.system (''' +cd %(builddir)s && rm -f python.exe +''') + Python_2_4.compile (self) + self.system (''' +cd %(builddir)s && mv python.exe python-console.exe +cd %(builddir)s && make LINKFORSHARED='-mwindows' +cd %(builddir)s && mv python.exe python-windows.exe +cd %(builddir)s && cp -p python-console.exe python.exe +''') + def install (self): + Python_2_4.install (self) + self.system (''' +cd %(builddir)s && cp -p python-windows.exe python-console.exe %(install_prefix)s/bin +''') + self.file_sub ([('extra = ""', 'extra = "-L%(system_prefix)s/bin -L%(system_prefix)s/lib -lpython2.4 -lpthread"')], + '%(install_prefix)s%(cross_dir)s/bin/python-config') + + def rename_so (logger, fname): + dll = re.sub ('\.so*', '.dll', fname) + loggedos.rename (logger, fname, dll) + + self.map_locate (rename_so, + self.expand ('%(install_prefix)s/lib/python%(python_version)s/lib-dynload'), + '*.so*') + ## UGH. + self.system (''' +cp %(install_prefix)s/lib/python%(python_version)s/lib-dynload/* %(install_prefix)s/bin +''') + self.system (''' +chmod 755 %(install_prefix)s/bin/* +''') + # This builds and runs in wine, but produces DLLs that + # do not load in Windows Vista + if 0: + self.generate_dll_a_and_la ('python2.4', '-lpthread') + +class Python_2_4__tools (tools.AutoBuild, Python_2_4): + patches = [ +# 'python-2.4.2-fno-stack-protector.patch', + 'python-2.4.5-readline.patch', # Stop python from reading ~/.inputrc + 'python-2.4.5-db4.7.patch', + 'python-2.4.5-regen.patch', + 'python-2.4.5-setup-cross.patch', + ] + dependencies = [ + 'autoconf', + 'db', # _bsddb + 'libtool', + ] + force_autoupdate = True + parallel_build_broken = True + not_supported = ['nis', 'crypt'] + make_flags = Python_2_4.make_flags + def get_conflict_dict (self): + return { + '': ['python-2.6', 'python-2.4'], + 'doc': ['python-2.6-doc', 'python-2.4-doc'], + 'devel': ['python-2.6-devel', 'python-2.4-devel'], + 'runtime': ['python-2.6-runtime', 'python-2.4-runtime'], + } + def patch (self): + Python_2_4.patch (self)
--- a/gub/specs/python-2.6.py Tue Aug 28 11:26:57 2012 +0200 +++ b/gub/specs/python-2.6.py Tue Aug 28 11:52:31 2012 +0200 @@ -1,6 +1,7 @@ +from gub import misc from gub import target from gub import tools -from gub.specs import python +python = misc.load_spec ('python-2.4') def get_conflict_dict (self): return { @@ -10,7 +11,7 @@ 'runtime': ['python-2.4-runtime', 'python-runtime'], } -class Python_2_6 (python.Python): +class Python_2_6 (python.Python_2_4): source = 'http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tar.bz2' dependencies = [ 'db-devel', @@ -33,7 +34,7 @@ 'python-2.6.4-include-pc.patch', 'python-2.6.4-setup-cross.patch', ] - config_cache_overrides = python.Python.config_cache_overrides + ''' + config_cache_overrides = python.Python_2_4.config_cache_overrides + ''' ac_cv_have_chflags=no ac_cv_have_lchflags=no ac_cv_py_format_size_t=no @@ -46,7 +47,7 @@ ] get_conflict_dict = get_conflict_dict -class Python_2_6__mingw (python.Python__mingw): +class Python_2_6__mingw (python.Python_2_4__mingw): source = Python_2_6.source patches = Python_2_6.patches + [ 'python-2.4.2-winsock2.patch', @@ -59,9 +60,9 @@ 'db-devel', 'expat-devel', 'zlib-devel', - 'tools::python-2-6', + 'tools::python', ] - config_cache_overrides = python.Python__mingw.config_cache_overrides + ''' + config_cache_overrides = python.Python_2_4__mingw.config_cache_overrides + ''' ac_cv_have_chflags=no ac_cv_have_lchflags=no ac_cv_py_format_size_t=no @@ -69,17 +70,17 @@ so_modules = Python_2_6.so_modules get_conflict_dict = get_conflict_dict def patch (self): - python.Python__mingw.patch (self) + python.Python_2_4__mingw.patch (self) self.system ('cd %(srcdir)s && cp -pv PC/dl_nt.c Python/fileblocks.c') def generate_dll_a_and_la (self, libname, depend=''): target.AutoBuild.generate_dll_a_and_la (self, 'python2.6', depend) -class Python_2_4__mingw_binary (python.Python__mingw_binary): +class Python_2_6__mingw_binary (python.Python_2_4__mingw_binary): get_conflict_dict = get_conflict_dict -class Python_2_4__freebsd (python.Python__freebsd): +class Python_2_6__freebsd (python.Python_2_4__freebsd): get_conflict_dict = get_conflict_dict -class Python_2_6__tools (python.Python__tools): +class Python_2_6__tools (python.Python_2_4__tools): source = Python_2_6.source patches = [ 'python-2.6.4-readline.patch', @@ -87,7 +88,7 @@ ] dependencies = ['autoconf', 'libtool'] force_autoupdate = True - make_flags = python.Python__tools.make_flags + make_flags = python.Python_2_4__tools.make_flags so_modules = Python_2_6.so_modules get_conflict_dict = get_conflict_dict def patch (self):
--- a/gub/specs/python.py Tue Aug 28 11:26:57 2012 +0200 +++ b/gub/specs/python.py Tue Aug 28 11:52:31 2012 +0200 @@ -1,215 +1,37 @@ -import re -# -from gub import build -from gub import context from gub import misc -from gub import target from gub import tools -class Python (target.AutoBuild): - source = 'http://python.org/ftp/python/2.4.5/Python-2.4.5.tar.bz2' - #source = 'http://python.org/ftp/python/2.4.2/Python-2.4.2.tar.bz2' - patches_242 = [ - 'python-2.4.2-1.patch', - 'python-configure.in-posix.patch&strip=0', - 'python-configure.in-sysname.patch&strip=0', - 'python-2.4.2-configure.in-sysrelease.patch', - 'python-2.4.2-setup.py-import.patch&strip=0', - 'python-2.4.2-setup.py-cross_root.patch&strip=0', - 'python-2.4.2-fno-stack-protector.patch', - ] +python = misc.load_spec ('python-' + tools.python_version) - patches = [ - 'python-2.4.5-1.patch', - 'python-configure.in-posix.patch&strip=0', - 'python-2.4.5-configure.in-sysname.patch', - 'python-2.4.2-configure.in-sysrelease.patch', - 'python-2.4.2-setup.py-import.patch&strip=0', - 'python-2.4.2-setup.py-cross_root.patch&strip=0', -# 'python-2.4.2-fno-stack-protector.patch', - 'python-2.4.5-python-2.6.patch', - 'python-2.4.5-native.patch', - 'python-2.4.5-db4.7.patch', - 'python-2.4.5-setup-cross.patch', - ] - dependencies = ['db-devel', 'expat-devel', 'zlib-devel', 'tools::python'] - force_autoupdate = True - subpackage_names = ['doc', 'devel', 'runtime', ''] - so_modules = [ - 'itertools', - 'struct', - 'time', - ] - not_supported = [] - make_flags = misc.join_lines (r''' -BLDLIBRARY='%(rpath)s -L. -lpython$(VERSION)' -''') - def get_conflict_dict (self): - return { - '': ['python-2.6', 'python-2.4'], - 'doc': ['python-2.6-doc', 'python-2.4-doc'], - 'devel': ['python-2.6-devel', 'python-2.4-devel'], - 'runtime': ['python-2.6-runtime', 'python-2.4-runtime'], - } - def __init__ (self, settings, source): - target.AutoBuild.__init__ (self, settings, source) - self.CROSS_ROOT = '%(targetdir)s' - if 'stat' in misc.librestrict (): - self.install_command = ('LIBRESTRICT_ALLOW=/usr/lib/python2.4/lib-dynload:${LIBRESTRICT_ALLOW-/foo} ' - + target.AutoBuild.install_command) - def patch (self): - target.AutoBuild.patch (self) - self.file_sub ([('@CC@', '@CC@ -I%(builddir)s')], - '%(srcdir)s/Makefile.pre.in') - def autoupdate (self): - target.AutoBuild.autoupdate (self) - # FIXME: REMOVEME/PROMOTEME to target.py? - if self.settings.build_platform == self.settings.target_platform: - self.file_sub ([('cross_compiling=(maybe|no|yes)', - 'cross_compiling=no')], '%(srcdir)s/configure') - def install (self): - target.AutoBuild.install (self) - misc.dump_python_config (self) - def assert_fine (logger): - dynload_dir = self.expand ('%(install_prefix)s/lib/python%(python_version)s/lib-dynload') - so = self.expand ('%(so_extension)s') - all = [x.replace (dynload_dir + '/', '') for x in misc.find_files (dynload_dir, '.*' + so)] - failed = [x.replace (dynload_dir + '/', '') for x in misc.find_files (dynload_dir, '.*failed' + so)] - for i in self.not_supported: - m = i + '_failed' + so - if m in failed: - failed.remove (m) - if failed: - logger.write_log ('failed python modules:' + ', '.join (failed), 'error') - for module in self.so_modules: - if not module + so in all: - logger.write_log ('all python modules:' + ', '.join (all), 'error') - raise Exception ('Python module failed: ' + module) - self.func (assert_fine) - ### Ugh. - @context.subst_method - def python_version (self): - return '.'.join (self.version ().split ('.')[0:2]) - -class Python__mingw_binary (build.BinaryBuild): - source = 'http://lilypond.org/~hanwen/python-2.4.2-windows.tar.gz' - - def python_version (self): - return '2.4' - - def install (self): - build.BinaryBuild.install (self) - self.system (''' -cd %(install_root)s && mkdir usr && mv Python24/include usr -cd %(install_root)s && mkdir -p usr/bin/ && mv Python24/* usr/bin -rmdir %(install_root)s/Python24 -''') +def get_conflict_dict (self): + return { + '': ['python-2.6', 'python-2.4'], + 'doc': ['python-2.6-doc', 'python-2.4-doc'], + 'devel': ['python-2.6-devel', 'python-2.4-devel'], + 'runtime': ['python-2.6-runtime', 'python-2.4-runtime'], + } -class Python__freebsd (Python): - def configure (self): - Python.configure (self) - self.file_sub ([ - ('^LDSHARED=.*', 'LDSHARED = $(CC) -shared'), - ('BLDSHARED=.*', 'BLDSHARED = $(CC) -shared'), - ], '%(builddir)s/Makefile') - -class Python__mingw (Python): - patches = Python.patches + [ - 'python-2.4.2-winsock2.patch', - 'python-2.4.2-setup.py-selectmodule.patch', - 'python-2.4.5-disable-pwd-mingw.patch', - 'python-2.4.5-mingw-site.patch', - 'python-2.4.5-mingw-socketmodule.patch', - ] - config_cache_overrides = (Python.config_cache_overrides - #FIXME: promoteme? see Gettext/Python - .replace ('ac_cv_func_select=yes', - 'ac_cv_func_select=no') - + ''' -ac_cv_pthread_system_supported=yes, -ac_cv_sizeof_pthread_t=12 -''') - def __init__ (self, settings, source): - Python.__init__ (self, settings, source) - self.target_gcc_flags = '-DMS_WINDOWS -DPy_WIN_WIDE_FILENAMES -I%(system_prefix)s/include' % self.settings.__dict__ - dependencies = Python.dependencies + ['pthreads-w32-devel'] - # 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) - self.file_sub ([ - ('(== "win32")', r'in ("win32", "mingw32")'), - ], "%(srcdir)s/Lib/subprocess.py", - must_succeed=True) - def configure (self): - Python.configure (self) - self.dump (''' -_subprocess ../PC/_subprocess.c -msvcrt ../PC/msvcrtmodule.c -''', - '%(builddir)s/Modules/Setup', - mode='a') - def compile (self): - self.system (''' -cd %(builddir)s && rm -f python.exe -''') - Python.compile (self) - self.system (''' -cd %(builddir)s && mv python.exe python-console.exe -cd %(builddir)s && make LINKFORSHARED='-mwindows' -cd %(builddir)s && mv python.exe python-windows.exe -cd %(builddir)s && cp -p python-console.exe python.exe -''') - def install (self): - Python.install (self) - self.system (''' -cd %(builddir)s && cp -p python-windows.exe python-console.exe %(install_prefix)s/bin -''') - self.file_sub ([('extra = ""', 'extra = "-L%(system_prefix)s/bin -L%(system_prefix)s/lib -lpython2.4 -lpthread"')], - '%(install_prefix)s%(cross_dir)s/bin/python-config') - - def rename_so (logger, fname): - dll = re.sub ('\.so*', '.dll', fname) - loggedos.rename (logger, fname, dll) - - self.map_locate (rename_so, - self.expand ('%(install_prefix)s/lib/python%(python_version)s/lib-dynload'), - '*.so*') - ## UGH. - self.system (''' -cp %(install_prefix)s/lib/python%(python_version)s/lib-dynload/* %(install_prefix)s/bin -''') - self.system (''' -chmod 755 %(install_prefix)s/bin/* -''') - # This builds and runs in wine, but produces DLLs that - # do not load in Windows Vista - if 0: - self.generate_dll_a_and_la ('python2.4', '-lpthread') - -class Python__tools (tools.AutoBuild, Python): - patches = [ -# 'python-2.4.2-fno-stack-protector.patch', - 'python-2.4.5-readline.patch', # Stop python from reading ~/.inputrc - 'python-2.4.5-db4.7.patch', - 'python-2.4.5-regen.patch', - 'python-2.4.5-setup-cross.patch', - ] - dependencies = [ - 'autoconf', - 'db', # _bsddb - 'libtool', - ] - force_autoupdate = True - parallel_build_broken = True - not_supported = ['nis', 'crypt'] - make_flags = Python.make_flags - def get_conflict_dict (self): - return { - '': ['python-2.6', 'python-2.4'], - 'doc': ['python-2.6-doc', 'python-2.4-doc'], - 'devel': ['python-2.6-devel', 'python-2.4-devel'], - 'runtime': ['python-2.6-runtime', 'python-2.4-runtime'], - } - def patch (self): - Python.patch (self) +if tools.python_version == '2.4': + class Python (python.Python_2_4): + get_conflict_dict = get_conflict_dict + class Python__mingw (python.Python_2_4__mingw): + get_conflict_dict = get_conflict_dict + class Python__mingw_binary (python.Python_2_4__mingw_binary): + get_conflict_dict = get_conflict_dict + class Python__freebsd (python.Python_2_4__freebsd): + get_conflict_dict = get_conflict_dict + class Python__tools (python.Python_2_4__tools): + get_conflict_dict = get_conflict_dict +elif tools.python_version == '2.6': + class Python (python.Python_2_6): + get_conflict_dict = get_conflict_dict + class Python__mingw (python.Python_2_6__mingw): + get_conflict_dict = get_conflict_dict + class Python__mingw_binary (python.Python_2_6__mingw_binary): + get_conflict_dict = get_conflict_dict + class Python__freebsd (python.Python_2_6__freebsd): + get_conflict_dict = get_conflict_dict + class Python__tools (python.Python_2_6__tools): + get_conflict_dict = get_conflict_dict +else: + raise Exception ('No such Python version:' + tools.python_version)
--- a/gub/specs/xcb-proto.py Tue Aug 28 11:26:57 2012 +0200 +++ b/gub/specs/xcb-proto.py Tue Aug 28 11:52:31 2012 +0200 @@ -4,7 +4,6 @@ source = 'http://xcb.freedesktop.org/dist/xcb-proto-1.3.tar.gz' dependencies = [ 'tools::libtool', -# 'tools::python-2-6', 'tools::python', ] def patch (self):
--- a/gub/tools.py Tue Aug 28 11:26:57 2012 +0200 +++ b/gub/tools.py Tue Aug 28 11:52:31 2012 +0200 @@ -33,9 +33,6 @@ if (not package.get_dependency_dict ().get ('', None) and not package.get_dependency_dict ().get ('devel', None)): def get_build_dependencies (foo): - if python_version: - package.dependencies = [re.sub ('python$', 'python-' + python_version, name) - for name in package.dependencies] # If a package depends on tools::libtool, ie not on # libltdl, we still also need <target-arch>::libtool, # because of our update_libtool (). We fix this here,