55import mimetypes
66from pythonbrew .util import makedirs , symlink , Package , is_url , Link ,\
77 unlink , is_html , Subprocess , rm_r ,\
8- is_python25 , is_python24 , is_python26 ,\
8+ is_python25 , is_python24 , is_python26 , is_python27 , \
99 unpack_downloadfile , is_archive_file , path_to_fileurl , is_file ,\
1010 fileurl_to_path
1111from pythonbrew .define import PATH_BUILD , PATH_DISTS , PATH_PYTHONS ,\
1212 ROOT , PATH_LOG , DISTRIBUTE_SETUP_DLSITE ,\
1313 PATH_PATCHES_MACOSX_PYTHON25 , PATH_PATCHES_MACOSX_PYTHON24 ,\
14- PATH_PATCHES_MACOSX_PYTHON26
14+ PATH_PATCHES_MACOSX_PYTHON26 , PATH_PATCHES_MACOSX_PYTHON27
1515from pythonbrew .downloader import get_python_version_url , Downloader ,\
1616 get_headerinfo_from_url
1717from pythonbrew .log import logger
2121class PythonInstaller (object ):
2222 """Python installer
2323 """
24-
24+
2525 def __init__ (self , arg , options ):
2626 if is_url (arg ):
2727 name = arg
@@ -31,7 +31,7 @@ def __init__(self, arg, options):
3131 name = path_to_fileurl (arg )
3232 else :
3333 name = arg
34-
34+
3535 if is_url (name ):
3636 self .download_url = name
3737 filename = Link (self .download_url ).filename
@@ -56,7 +56,7 @@ def __init__(self, arg, options):
5656 self .options = options
5757 self .logfile = os .path .join (PATH_LOG , 'build.log' )
5858 self .configure_options = ''
59-
59+
6060 def install (self ):
6161 if os .path .isdir (self .install_dir ):
6262 logger .info ("You are already installed `%s`" % self .pkg .name )
@@ -82,7 +82,7 @@ def install(self):
8282 logger .info ("Installed %(pkgname)s successfully. Run the following command to switch to %(pkgname)s."
8383 % {"pkgname" :self .pkg .name })
8484 logger .info (" pythonbrew switch %s" % self .pkg .alias )
85-
85+
8686 def download_unpack (self ):
8787 content_type = self .content_type
8888 if is_html (content_type ):
@@ -110,14 +110,14 @@ def download_unpack(self):
110110 # unpack
111111 if not unpack_downloadfile (self .content_type , self .download_file , self .build_dir ):
112112 sys .exit (1 )
113-
113+
114114 def patch (self ):
115115 pass
116-
116+
117117 def configure (self ):
118118 s = Subprocess (log = self .logfile , cwd = self .build_dir )
119119 s .check_call ("./configure --prefix=%s %s %s" % (self .install_dir , self .options .configure , self .configure_options ))
120-
120+
121121 def make (self ):
122122 jobs = self .options .jobs
123123 make = ((jobs > 0 and 'make -j%s' % jobs ) or 'make' )
@@ -127,14 +127,14 @@ def make(self):
127127 else :
128128 s .check_call (make )
129129 s .check_call ("make test" )
130-
130+
131131 def make_install (self ):
132132 version = self .pkg .version
133133 if version == "1.5.2" or version == "1.6.1" :
134134 makedirs (self .install_dir )
135135 s = Subprocess (log = self .logfile , cwd = self .build_dir )
136136 s .check_call ("make install" )
137-
137+
138138 def symlink (self ):
139139 install_dir = os .path .realpath (self .install_dir )
140140 path_python = os .path .join (install_dir ,'bin' ,'python' )
@@ -145,7 +145,7 @@ def symlink(self):
145145 symlink (path_python3 , path_python )
146146 elif os .path .isfile (path_python3_0 ):
147147 symlink (path_python3_0 , path_python )
148-
148+
149149 def install_setuptools (self ):
150150 options = self .options
151151 pkgname = self .pkg .name
@@ -159,10 +159,10 @@ def install_setuptools(self):
159159 download_url = DISTRIBUTE_SETUP_DLSITE
160160 filename = Link (download_url ).filename
161161 download_file = os .path .join (PATH_DISTS , filename )
162-
162+
163163 dl = Downloader ()
164164 dl .download (filename , download_url , download_file )
165-
165+
166166 install_dir = os .path .join (PATH_PYTHONS , pkgname )
167167 path_python = os .path .join (install_dir ,"bin" ,"python" )
168168 try :
@@ -195,7 +195,9 @@ def __init__(self, arg, options):
195195 self .configure_options = '--with-universal-archs="intel" MACOSX_DEPLOYMENT_TARGET=10.6 CPPFLAGS="-D_DARWIN_C_SOURCE"'
196196 elif is_python26 (version ):
197197 self .configure_options = '--with-universal-archs="intel" --enable-universalsdk=/ MACOSX_DEPLOYMENT_TARGET=10.6'
198-
198+ elif is_python27 (version ):
199+ self .configure_options = '--with-universal-archs="intel" --enable-universalsdk=/ MACOSX_DEPLOYMENT_TARGET=10.6'
200+
199201 def patch (self ):
200202 version = self .pkg .version
201203 try :
@@ -214,20 +216,20 @@ def patch(self):
214216 'patch-gestaltmodule.c.diff' ]
215217 elif is_python25 (version ):
216218 patch_dir = PATH_PATCHES_MACOSX_PYTHON25
217- patches = ['patch-Makefile.pre.in.diff' ,
219+ patches = ['patch-Makefile.pre.in.diff' ,
218220 'patch-Lib-cgi.py.diff' ,
219- 'patch-Lib-distutils-dist.py.diff' ,
221+ 'patch-Lib-distutils-dist.py.diff' ,
220222 'patch-setup.py.diff' ,
221- 'patch-configure-badcflags.diff' ,
223+ 'patch-configure-badcflags.diff' ,
222224 'patch-configure-arch_only.diff' ,
223- 'patch-64bit.diff' ,
225+ 'patch-64bit.diff' ,
224226 'patch-pyconfig.h.in.diff' ,
225227 'patch-gestaltmodule.c.diff' ]
226- eds = {'_localemodule.c.ed' : 'Modules/_localemodule.c' ,
228+ eds = {'_localemodule.c.ed' : 'Modules/_localemodule.c' ,
227229 'locale.py.ed' : 'Lib/locale.py' }
228230 elif is_python26 (version ):
229231 patch_dir = PATH_PATCHES_MACOSX_PYTHON26
230- patches = ['patch-Lib-cgi.py.diff' ,
232+ patches = ['patch-Lib-cgi.py.diff' ,
231233 'patch-Lib-distutils-dist.py.diff' ,
232234 'patch-Mac-IDLE-Makefile.in.diff' ,
233235 'patch-Mac-Makefile.in.diff' ,
@@ -236,9 +238,12 @@ def patch(self):
236238 'patch-setup.py-db46.diff' ,
237239 'patch-Lib-ctypes-macholib-dyld.py.diff' ,
238240 'patch-setup_no_tkinter.py.diff' ]
239- eds = {'_localemodule.c.ed' : 'Modules/_localemodule.c' ,
241+ eds = {'_localemodule.c.ed' : 'Modules/_localemodule.c' ,
240242 'locale.py.ed' : 'Lib/locale.py' }
241-
243+ elif is_python27 (version ):
244+ patch_dir = PATH_PATCHES_MACOSX_PYTHON27
245+ patches = ['patch-Modules-posixmodule.diff' ]
246+
242247 if patches or eds :
243248 logger .info ("Patching %s" % self .pkg .name )
244249 for patch in patches :
0 commit comments