From 92c48adfaca38bf8ccd1254165c5ba56b29153b9 Mon Sep 17 00:00:00 2001 From: Nicolas Pinto Date: Sat, 28 May 2011 17:10:45 -0400 Subject: [PATCH] Add patch to fix _environ symbol missing bug in python27, see http://bugs.python.org/issue1602133 --- pythonbrew/define.py | 1 + pythonbrew/installer/pythoninstaller.py | 53 +++++++++++-------- .../python27/patch-Modules-posixmodule.diff | 13 ++++- pythonbrew/util.py | 5 +- 4 files changed, 46 insertions(+), 26 deletions(-) diff --git a/pythonbrew/define.py b/pythonbrew/define.py index b8fab52..8a51b3f 100644 --- a/pythonbrew/define.py +++ b/pythonbrew/define.py @@ -29,6 +29,7 @@ PATH_SCRIPTS_PYTHONBREW_COMMANDS = os.path.join(PATH_SCRIPTS_PYTHONBREW,"command PATH_SCRIPTS_PYTHONBREW_INSTALLER = os.path.join(PATH_SCRIPTS_PYTHONBREW,"installer") PATH_PATCHES = os.path.join(ROOT,"patches") 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") PATH_PATCHES_MACOSX_PYTHON25 = os.path.join(PATH_PATCHES_MACOSX,"python25") PATH_PATCHES_MACOSX_PYTHON24 = os.path.join(PATH_PATCHES_MACOSX,"python24") diff --git a/pythonbrew/installer/pythoninstaller.py b/pythonbrew/installer/pythoninstaller.py index 48143ab..fe48ef5 100644 --- a/pythonbrew/installer/pythoninstaller.py +++ b/pythonbrew/installer/pythoninstaller.py @@ -5,13 +5,13 @@ import re import mimetypes from pythonbrew.util import makedirs, symlink, Package, is_url, Link,\ unlink, is_html, Subprocess, rm_r,\ - is_python25, is_python24, is_python26,\ + is_python25, is_python24, is_python26, is_python27,\ unpack_downloadfile, is_archive_file, path_to_fileurl, is_file,\ fileurl_to_path 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_PYTHON26, PATH_PATCHES_MACOSX_PYTHON27 from pythonbrew.downloader import get_python_version_url, Downloader,\ get_headerinfo_from_url from pythonbrew.log import logger @@ -21,7 +21,7 @@ from pythonbrew.exceptions import UnknownVersionException,\ class PythonInstaller(object): """Python installer """ - + def __init__(self, arg, options): if is_url(arg): name = arg @@ -31,7 +31,7 @@ class PythonInstaller(object): name = path_to_fileurl(arg) else: name = arg - + if is_url(name): self.download_url = name filename = Link(self.download_url).filename @@ -56,7 +56,7 @@ class PythonInstaller(object): self.options = options self.logfile = os.path.join(PATH_LOG, 'build.log') self.configure_options = '' - + def install(self): if os.path.isdir(self.install_dir): logger.info("You are already installed `%s`" % self.pkg.name) @@ -82,7 +82,7 @@ class PythonInstaller(object): logger.info("Installed %(pkgname)s successfully. Run the following command to switch to %(pkgname)s." % {"pkgname":self.pkg.name}) logger.info(" pythonbrew switch %s" % self.pkg.alias) - + def download_unpack(self): content_type = self.content_type if is_html(content_type): @@ -110,14 +110,14 @@ class PythonInstaller(object): # unpack if not unpack_downloadfile(self.content_type, self.download_file, self.build_dir): sys.exit(1) - + def patch(self): pass - + 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)) - + def make(self): jobs = self.options.jobs make = ((jobs > 0 and 'make -j%s' % jobs) or 'make') @@ -127,14 +127,14 @@ class PythonInstaller(object): else: s.check_call(make) s.check_call("make test") - + def make_install(self): version = self.pkg.version if version == "1.5.2" or version == "1.6.1": makedirs(self.install_dir) s = Subprocess(log=self.logfile, cwd=self.build_dir) s.check_call("make install") - + def symlink(self): install_dir = os.path.realpath(self.install_dir) path_python = os.path.join(install_dir,'bin','python') @@ -145,7 +145,7 @@ class PythonInstaller(object): symlink(path_python3, path_python) elif os.path.isfile(path_python3_0): symlink(path_python3_0, path_python) - + def install_setuptools(self): options = self.options pkgname = self.pkg.name @@ -159,10 +159,10 @@ class PythonInstaller(object): download_url = DISTRIBUTE_SETUP_DLSITE filename = Link(download_url).filename download_file = os.path.join(PATH_DISTS, filename) - + dl = Downloader() dl.download(filename, download_url, download_file) - + install_dir = os.path.join(PATH_PYTHONS, pkgname) path_python = os.path.join(install_dir,"bin","python") try: @@ -195,7 +195,9 @@ class PythonInstallerMacOSX(PythonInstaller): self.configure_options = '--with-universal-archs="intel" MACOSX_DEPLOYMENT_TARGET=10.6 CPPFLAGS="-D_DARWIN_C_SOURCE"' elif is_python26(version): self.configure_options = '--with-universal-archs="intel" --enable-universalsdk=/ MACOSX_DEPLOYMENT_TARGET=10.6' - + elif is_python27(version): + self.configure_options = '--with-universal-archs="intel" --enable-universalsdk=/ MACOSX_DEPLOYMENT_TARGET=10.6' + def patch(self): version = self.pkg.version try: @@ -214,20 +216,20 @@ class PythonInstallerMacOSX(PythonInstaller): 'patch-gestaltmodule.c.diff'] elif is_python25(version): patch_dir = PATH_PATCHES_MACOSX_PYTHON25 - patches = ['patch-Makefile.pre.in.diff', + patches = ['patch-Makefile.pre.in.diff', 'patch-Lib-cgi.py.diff', - 'patch-Lib-distutils-dist.py.diff', + 'patch-Lib-distutils-dist.py.diff', 'patch-setup.py.diff', - 'patch-configure-badcflags.diff', + 'patch-configure-badcflags.diff', 'patch-configure-arch_only.diff', - 'patch-64bit.diff', + 'patch-64bit.diff', 'patch-pyconfig.h.in.diff', 'patch-gestaltmodule.c.diff'] - eds = {'_localemodule.c.ed': 'Modules/_localemodule.c', + 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', + patches = ['patch-Lib-cgi.py.diff', 'patch-Lib-distutils-dist.py.diff', 'patch-Mac-IDLE-Makefile.in.diff', 'patch-Mac-Makefile.in.diff', @@ -236,9 +238,14 @@ class PythonInstallerMacOSX(PythonInstaller): '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', + 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'] + #eds = {'_localemodule.c.ed': 'Modules/_localemodule.c', + #'locale.py.ed': 'Lib/locale.py'} + if patches or eds: logger.info("Patching %s" % self.pkg.name) for patch in patches: diff --git a/pythonbrew/patches/macosx/python27/patch-Modules-posixmodule.diff b/pythonbrew/patches/macosx/python27/patch-Modules-posixmodule.diff index 2f090a5..418071e 100644 --- a/pythonbrew/patches/macosx/python27/patch-Modules-posixmodule.diff +++ b/pythonbrew/patches/macosx/python27/patch-Modules-posixmodule.diff @@ -1,5 +1,14 @@ ---- Modules/posixmodule.c.bak 2011-05-28 14:09:48.000000000 -0400 -+++ Modules/posixmodule.c 2011-05-28 14:10:34.000000000 -0400 +--- Modules/posixmodule.c.orig 2011-05-28 16:57:40.000000000 -0400 ++++ Modules/posixmodule.c 2011-05-28 16:56:40.000000000 -0400 +@@ -455,7 +455,7 @@ + #endif + + /* Return a dictionary corresponding to the POSIX environment table */ +-#ifdef WITH_NEXT_FRAMEWORK ++#ifdef __APPLE__ + /* On Darwin/MacOSX a shared library or framework has no access to + ** environ directly, we must obtain it with _NSGetEnviron(). + */ @@ -477,7 +477,7 @@ d = PyDict_New(); if (d == NULL) diff --git a/pythonbrew/util.py b/pythonbrew/util.py index 32f3fb2..50e7ed3 100644 --- a/pythonbrew/util.py +++ b/pythonbrew/util.py @@ -74,6 +74,9 @@ def is_python25(version): def is_python26(version): return version >= '2.6' and version < '2.7' +def is_python27(version): + return version >= '2.7' and version < '2.8' + def makedirs(path): try: os.makedirs(path) @@ -293,4 +296,4 @@ class Link(object): def show_msg(self): return posixpath.basename(self._url.split('#', 1)[0].split('?', 1)[0]) - \ No newline at end of file +