#21 support ubuntu 11.04(Natty)

This commit is contained in:
utahta
2011-07-07 19:37:30 +09:00
parent 7371bde921
commit 87d0d7b52f
4 changed files with 170 additions and 58 deletions
+1
View File
@@ -28,6 +28,7 @@ PATH_SCRIPTS_PYTHONBREW = os.path.join(PATH_SCRIPTS,"pythonbrew")
PATH_SCRIPTS_PYTHONBREW_COMMANDS = os.path.join(PATH_SCRIPTS_PYTHONBREW,"commands")
PATH_SCRIPTS_PYTHONBREW_INSTALLER = os.path.join(PATH_SCRIPTS_PYTHONBREW,"installer")
PATH_PATCHES = os.path.join(ROOT,"patches")
PATH_PATCHES_ALL = os.path.join(PATH_PATCHES,"all")
PATH_PATCHES_MACOSX = os.path.join(PATH_PATCHES,"macosx")
PATH_PATCHES_MACOSX_PYTHON27 = os.path.join(PATH_PATCHES_MACOSX,"python27")
PATH_PATCHES_MACOSX_PYTHON26 = os.path.join(PATH_PATCHES_MACOSX,"python26")
+77 -58
View File
@@ -10,7 +10,7 @@ from pythonbrew.util import makedirs, symlink, Package, is_url, Link,\
from pythonbrew.define import PATH_BUILD, PATH_DISTS, PATH_PYTHONS,\
ROOT, PATH_LOG, DISTRIBUTE_SETUP_DLSITE,\
PATH_PATCHES_MACOSX_PYTHON25, PATH_PATCHES_MACOSX_PYTHON24,\
PATH_PATCHES_MACOSX_PYTHON26, PATH_PATCHES_MACOSX_PYTHON27
PATH_PATCHES_MACOSX_PYTHON26, PATH_PATCHES_MACOSX_PYTHON27, PATH_PATCHES_ALL
from pythonbrew.downloader import get_python_version_url, Downloader,\
get_headerinfo_from_url
from pythonbrew.log import logger
@@ -55,6 +55,7 @@ class PythonInstaller(object):
self.options = options
self.logfile = os.path.join(PATH_LOG, 'build.log')
self.configure_options = ''
self.patches = []
def install(self):
if os.path.isdir(self.install_dir):
@@ -111,8 +112,40 @@ class PythonInstaller(object):
sys.exit(1)
def patch(self):
pass
version = self.pkg.version
if is_python25(version):
patch_dir = os.path.join(PATH_PATCHES_ALL, "python25")
self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
else:
patch_dir = os.path.join(PATH_PATCHES_ALL, "common")
self._add_patches_to_list(patch_dir, ['patch-setup.py.diff'])
self._do_patch()
def _do_patch(self):
try:
s = Subprocess(log=self.logfile, cwd=self.build_dir)
if self.patches:
logger.info("Patching %s" % self.pkg.name)
for patch in self.patches:
if type(patch) is dict:
for (ed, source) in patch.items():
s.check_call('ed - %s < %s' % (source, ed))
else:
s.check_call("patch -p0 < %s" % patch)
except:
logger.error("Failed to patch `%s`" % self.build_dir)
sys.exit(1)
def _add_patches_to_list(self, patch_dir, patch_files):
for patch in patch_files:
if type(patch) is dict:
for key in patch.keys():
patch[os.path.join(patch_dir, key)] = patch[key]
del patch[key]
self.patches.append(patch)
else:
self.patches.append(os.path.join(patch_dir, patch))
def configure(self):
s = Subprocess(log=self.logfile, cwd=self.build_dir)
s.check_call("./configure --prefix=%s %s %s" % (self.install_dir, self.options.configure, self.configure_options))
@@ -197,58 +230,44 @@ class PythonInstallerMacOSX(PythonInstaller):
def patch(self):
version = self.pkg.version
try:
s = Subprocess(log=self.logfile, cwd=self.build_dir)
patches = []
eds = {}
if is_python24(version):
patch_dir = PATH_PATCHES_MACOSX_PYTHON24
patches = ['patch-configure', 'patch-Makefile.pre.in',
'patch-Lib-cgi.py.diff', 'patch-Lib-site.py.diff',
'patch-setup.py.diff', 'patch-Include-pyport.h',
'patch-Mac-OSX-Makefile.in', 'patch-Mac-OSX-IDLE-Makefile.in',
'patch-Mac-OSX-PythonLauncher-Makefile.in', 'patch-configure-badcflags.diff',
'patch-configure-arch_only.diff', 'patch-macosmodule.diff',
'patch-mactoolboxglue.diff', 'patch-pymactoolbox.diff',
'patch-gestaltmodule.c.diff']
elif is_python25(version):
patch_dir = PATH_PATCHES_MACOSX_PYTHON25
patches = ['patch-Makefile.pre.in.diff',
'patch-Lib-cgi.py.diff',
'patch-Lib-distutils-dist.py.diff',
'patch-setup.py.diff',
'patch-configure-badcflags.diff',
'patch-configure-arch_only.diff',
'patch-64bit.diff',
'patch-pyconfig.h.in.diff',
'patch-gestaltmodule.c.diff']
eds = {'_localemodule.c.ed': 'Modules/_localemodule.c',
'locale.py.ed': 'Lib/locale.py'}
elif is_python26(version):
patch_dir = PATH_PATCHES_MACOSX_PYTHON26
patches = ['patch-Lib-cgi.py.diff',
'patch-Lib-distutils-dist.py.diff',
'patch-Mac-IDLE-Makefile.in.diff',
'patch-Mac-Makefile.in.diff',
'patch-Mac-PythonLauncher-Makefile.in.diff',
'patch-Mac-Tools-Doc-setup.py.diff',
'patch-setup.py-db46.diff',
'patch-Lib-ctypes-macholib-dyld.py.diff',
'patch-setup_no_tkinter.py.diff']
eds = {'_localemodule.c.ed': 'Modules/_localemodule.c',
'locale.py.ed': 'Lib/locale.py'}
elif is_python27(version):
patch_dir = PATH_PATCHES_MACOSX_PYTHON27
patches = ['patch-Modules-posixmodule.diff']
if patches or eds:
logger.info("Patching %s" % self.pkg.name)
for patch in patches:
s.check_call("patch -p0 < %s" % os.path.join(patch_dir, patch))
for (ed, source) in eds.items():
ed = os.path.join(patch_dir, ed)
s.check_call('ed - %s < %s' % (source, ed))
except:
logger.error("Failed to patch `%s`" % self.build_dir)
sys.exit(1)
if is_python24(version):
patch_dir = PATH_PATCHES_MACOSX_PYTHON24
self._add_patches_to_list(patch_dir, ['patch-configure', 'patch-Makefile.pre.in',
'patch-Lib-cgi.py.diff', 'patch-Lib-site.py.diff',
'patch-setup.py.diff', 'patch-Include-pyport.h',
'patch-Mac-OSX-Makefile.in', 'patch-Mac-OSX-IDLE-Makefile.in',
'patch-Mac-OSX-PythonLauncher-Makefile.in', 'patch-configure-badcflags.diff',
'patch-configure-arch_only.diff', 'patch-macosmodule.diff',
'patch-mactoolboxglue.diff', 'patch-pymactoolbox.diff',
'patch-gestaltmodule.c.diff'])
elif is_python25(version):
patch_dir = PATH_PATCHES_MACOSX_PYTHON25
self._add_patches_to_list(patch_dir, ['patch-Makefile.pre.in.diff',
'patch-Lib-cgi.py.diff',
'patch-Lib-distutils-dist.py.diff',
'patch-setup.py.diff',
'patch-configure-badcflags.diff',
'patch-configure-arch_only.diff',
'patch-64bit.diff',
'patch-pyconfig.h.in.diff',
'patch-gestaltmodule.c.diff',
{'_localemodule.c.ed': 'Modules/_localemodule.c'},
{'locale.py.ed': 'Lib/locale.py'}])
elif is_python26(version):
patch_dir = PATH_PATCHES_MACOSX_PYTHON26
self._add_patches_to_list(patch_dir, ['patch-Lib-cgi.py.diff',
'patch-Lib-distutils-dist.py.diff',
'patch-Mac-IDLE-Makefile.in.diff',
'patch-Mac-Makefile.in.diff',
'patch-Mac-PythonLauncher-Makefile.in.diff',
'patch-Mac-Tools-Doc-setup.py.diff',
'patch-setup.py-db46.diff',
'patch-Lib-ctypes-macholib-dyld.py.diff',
'patch-setup_no_tkinter.py.diff',
{'_localemodule.c.ed': 'Modules/_localemodule.c'},
{'locale.py.ed': 'Lib/locale.py'}])
elif is_python27(version):
patch_dir = PATH_PATCHES_MACOSX_PYTHON27
self._add_patches_to_list(patch_dir, ['patch-Modules-posixmodule.diff'])
self._do_patch()
@@ -0,0 +1,47 @@
# HG changeset patch
# User Barry Warsaw <barry@python.org>
# Date 1302190091 14400
# Node ID bd0f73a9538e05f526feaf05821e68bdcff498fa
# Parent 2e4cdaffe493e879fb5367a4aa454491de451137
Backport for Python 2.7 of issue 11715 support for building Python on
multiarch Debian/Ubuntu.
diff --git a/setup.py b/setup.py
--- setup.py.orig
+++ setup.py
@@ -345,10 +345,33 @@ class PyBuildExt(build_ext):
return platform
return sys.platform
+ def add_multiarch_paths(self):
+ # Debian/Ubuntu multiarch support.
+ # https://wiki.ubuntu.com/MultiarchSpec
+ if not find_executable('dpkg-architecture'):
+ return
+ tmpfile = os.path.join(self.build_temp, 'multiarch')
+ if not os.path.exists(self.build_temp):
+ os.makedirs(self.build_temp)
+ ret = os.system(
+ 'dpkg-architecture -qDEB_HOST_MULTIARCH > %s 2> /dev/null' %
+ tmpfile)
+ try:
+ if ret >> 8 == 0:
+ with open(tmpfile) as fp:
+ multiarch_path_component = fp.readline().strip()
+ add_dir_to_list(self.compiler.library_dirs,
+ '/usr/lib/' + multiarch_path_component)
+ add_dir_to_list(self.compiler.include_dirs,
+ '/usr/include/' + multiarch_path_component)
+ finally:
+ os.unlink(tmpfile)
+
def detect_modules(self):
# Ensure that /usr/local is always used
add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+ self.add_multiarch_paths()
# Add paths specified in the environment variables LDFLAGS and
# CPPFLAGS for header and library files.
@@ -0,0 +1,45 @@
--- setup.py.orig 2011-07-07 19:19:43.800122463 +0900
+++ setup.py 2011-07-07 19:25:04.548416377 +0900
@@ -13,6 +13,7 @@
from distutils.command.build_ext import build_ext
from distutils.command.install import install
from distutils.command.install_lib import install_lib
+from distutils.spawn import find_executable
# This global variable is used to hold the list of modules to be disabled.
disabled_module_list = []
@@ -242,10 +243,34 @@
return platform
return sys.platform
+ def add_multiarch_paths(self):
+ # Debian/Ubuntu multiarch support.
+ # https://wiki.ubuntu.com/MultiarchSpec
+ if not find_executable('dpkg-architecture'):
+ return
+ tmpfile = os.path.join(self.build_temp, 'multiarch')
+ if not os.path.exists(self.build_temp):
+ os.makedirs(self.build_temp)
+ ret = os.system(
+ 'dpkg-architecture -qDEB_HOST_MULTIARCH > %s 2> /dev/null' %
+ tmpfile)
+ try:
+ if ret >> 8 == 0:
+ fp = open(tmpfile)
+ multiarch_path_component = fp.readline().strip()
+ fp.close()
+ add_dir_to_list(self.compiler.library_dirs,
+ '/usr/lib/' + multiarch_path_component)
+ add_dir_to_list(self.compiler.include_dirs,
+ '/usr/include/' + multiarch_path_component)
+ finally:
+ os.unlink(tmpfile)
+
def detect_modules(self):
# Ensure that /usr/local is always used
add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+ self.add_multiarch_paths()
# Add paths specified in the environment variables LDFLAGS and
# CPPFLAGS for header and library files.