Skip to content

Commit 0b7a67b

Browse files
committed
Merge branch 'bugfix-python27-environ' of https://github.com/npinto/pythonbrew into npinto-bugfix-python27-environ
2 parents 7f7e1d3 + 01af855 commit 0b7a67b

6 files changed

Lines changed: 61 additions & 25 deletions

File tree

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
* 0.7.3
2+
- Improved symlink command.
3+
- support python3
4+
5+
* 0.7.2
6+
- Bug fixed.
7+
18
* 0.7.1
29
- Enable parallel make option (--jobs).
310
- The pythonbrew-install script accept Python-2.7.

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Create/Remove a symbolic link to python::
8585

8686
pythonbrew symlink # Create a symbolic link, like "py2.5.5"
8787
pythonbrew symlink -p 2.5.5
88-
pythonbrew symlink -b pip # Create a symbolic link to the specified script in bin directory
88+
pythonbrew symlink pip # Create a symbolic link to the specified script in bin directory
8989
pythonbrew symlink -r # Remove a symbolic link
9090

9191
Show version::

pythonbrew/define.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
PATH_SCRIPTS_PYTHONBREW_INSTALLER = os.path.join(PATH_SCRIPTS_PYTHONBREW,"installer")
3030
PATH_PATCHES = os.path.join(ROOT,"patches")
3131
PATH_PATCHES_MACOSX = os.path.join(PATH_PATCHES,"macosx")
32+
PATH_PATCHES_MACOSX_PYTHON27 = os.path.join(PATH_PATCHES_MACOSX,"python27")
3233
PATH_PATCHES_MACOSX_PYTHON26 = os.path.join(PATH_PATCHES_MACOSX,"python26")
3334
PATH_PATCHES_MACOSX_PYTHON25 = os.path.join(PATH_PATCHES_MACOSX,"python25")
3435
PATH_PATCHES_MACOSX_PYTHON24 = os.path.join(PATH_PATCHES_MACOSX,"python24")

pythonbrew/installer/pythoninstaller.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import mimetypes
66
from 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
1111
from 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
1515
from pythonbrew.downloader import get_python_version_url, Downloader,\
1616
get_headerinfo_from_url
1717
from pythonbrew.log import logger
@@ -21,7 +21,7 @@
2121
class 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:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--- Modules/posixmodule.c.orig 2011-05-28 16:57:40.000000000 -0400
2+
+++ Modules/posixmodule.c 2011-05-28 16:56:40.000000000 -0400
3+
@@ -455,7 +455,7 @@
4+
#endif
5+
6+
/* Return a dictionary corresponding to the POSIX environment table */
7+
-#ifdef WITH_NEXT_FRAMEWORK
8+
+#ifdef __APPLE__
9+
/* On Darwin/MacOSX a shared library or framework has no access to
10+
** environ directly, we must obtain it with _NSGetEnviron().
11+
*/
12+
@@ -477,7 +477,7 @@
13+
d = PyDict_New();
14+
if (d == NULL)
15+
return NULL;
16+
-#ifdef WITH_NEXT_FRAMEWORK
17+
+#ifdef __APPLE__
18+
if (environ == NULL)
19+
environ = *_NSGetEnviron();
20+
#endif

pythonbrew/util.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ def is_python25(version):
7474
def is_python26(version):
7575
return version >= '2.6' and version < '2.7'
7676

77+
def is_python27(version):
78+
return version >= '2.7' and version < '2.8'
79+
7780
def makedirs(path):
7881
try:
7982
os.makedirs(path)
@@ -293,4 +296,4 @@ def filename(self):
293296
def show_msg(self):
294297
return posixpath.basename(self._url.split('#', 1)[0].split('?', 1)[0])
295298

296-
299+

0 commit comments

Comments
 (0)