Skip to content

Commit 7b88393

Browse files
author
ronald.oussoren
committed
Use staticly build copies of zlib and bzip2 to build the OSX installer, that
way the resulting binaries have a better change of running on 10.3. This patch also updates the search logic for sleepycat db3/4, without this patch you cannot use a sleepycat build with a non-standard prefix; with this you can (at least on OSX) if you add the prefix to CPPFLAGS/LDFLAGS at configure-time. This change is needed to build the binary installer for OSX. git-svn-id: http://svn.python.org/projects/python/trunk@47128 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 484ad64 commit 7b88393

2 files changed

Lines changed: 93 additions & 42 deletions

File tree

Mac/BuildScript/build-installer.py

Lines changed: 63 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def getFullVersion():
6767
SDKPATH="/Developer/SDKs/MacOSX10.4u.sdk"
6868
#SDKPATH="/"
6969

70+
ARCHLIST=('i386', 'ppc',)
71+
7072
# Source directory (asume we're in Mac/BuildScript)
7173
SRCDIR=os.path.dirname(
7274
os.path.dirname(
@@ -90,6 +92,26 @@ def getFullVersion():
9092
# Instructions for building libraries that are necessary for building a
9193
# batteries included python.
9294
LIBRARY_RECIPES=[
95+
dict(
96+
name="Bzip2 1.0.3",
97+
url="http://www.bzip.org/1.0.3/bzip2-1.0.3.tar.gz",
98+
configure=None,
99+
install='make install PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
100+
shellQuote(os.path.join(WORKDIR, 'libraries')),
101+
' -arch '.join(ARCHLIST),
102+
SDKPATH,
103+
),
104+
),
105+
dict(
106+
name="ZLib 1.2.3",
107+
url="http://www.gzip.org/zlib/zlib-1.2.3.tar.gz",
108+
configure=None,
109+
install='make install prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
110+
shellQuote(os.path.join(WORKDIR, 'libraries')),
111+
' -arch '.join(ARCHLIST),
112+
SDKPATH,
113+
),
114+
),
93115
dict(
94116
# Note that GNU readline is GPL'd software
95117
name="GNU Readline 5.1.4",
@@ -486,48 +508,49 @@ def buildRecipe(recipe, basedir, archList):
486508
runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1),
487509
shellQuote(fn),))
488510

489-
configure_args = [
490-
"--prefix=/usr/local",
491-
"--enable-static",
492-
"--disable-shared",
493-
#"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),),
494-
]
495-
496-
if 'configure_pre' in recipe:
497-
args = list(recipe['configure_pre'])
498-
if '--disable-static' in args:
499-
configure_args.remove('--enable-static')
500-
if '--enable-shared' in args:
501-
configure_args.remove('--disable-shared')
502-
configure_args.extend(args)
503-
504-
if recipe.get('useLDFlags', 1):
505-
configure_args.extend([
506-
"CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%(
507-
' -arch '.join(archList),
508-
shellQuote(SDKPATH)[1:-1],
509-
shellQuote(basedir)[1:-1],),
510-
"LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%(
511-
shellQuote(SDKPATH)[1:-1],
512-
shellQuote(basedir)[1:-1],
513-
' -arch '.join(archList)),
514-
])
515-
else:
516-
configure_args.extend([
517-
"CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%(
518-
' -arch '.join(archList),
511+
if configure is not None:
512+
configure_args = [
513+
"--prefix=/usr/local",
514+
"--enable-static",
515+
"--disable-shared",
516+
#"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),),
517+
]
518+
519+
if 'configure_pre' in recipe:
520+
args = list(recipe['configure_pre'])
521+
if '--disable-static' in args:
522+
configure_args.remove('--enable-static')
523+
if '--enable-shared' in args:
524+
configure_args.remove('--disable-shared')
525+
configure_args.extend(args)
526+
527+
if recipe.get('useLDFlags', 1):
528+
configure_args.extend([
529+
"CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%(
530+
' -arch '.join(archList),
531+
shellQuote(SDKPATH)[1:-1],
532+
shellQuote(basedir)[1:-1],),
533+
"LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%(
519534
shellQuote(SDKPATH)[1:-1],
520-
shellQuote(basedir)[1:-1],),
521-
])
535+
shellQuote(basedir)[1:-1],
536+
' -arch '.join(archList)),
537+
])
538+
else:
539+
configure_args.extend([
540+
"CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%(
541+
' -arch '.join(archList),
542+
shellQuote(SDKPATH)[1:-1],
543+
shellQuote(basedir)[1:-1],),
544+
])
522545

523-
if 'configure_post' in recipe:
524-
configure_args = configure_args = list(recipe['configure_post'])
546+
if 'configure_post' in recipe:
547+
configure_args = configure_args = list(recipe['configure_post'])
525548

526-
configure_args.insert(0, configure)
527-
configure_args = [ shellQuote(a) for a in configure_args ]
549+
configure_args.insert(0, configure)
550+
configure_args = [ shellQuote(a) for a in configure_args ]
528551

529-
print "Running configure for %s"%(name,)
530-
runCommand(' '.join(configure_args) + ' 2>&1')
552+
print "Running configure for %s"%(name,)
553+
runCommand(' '.join(configure_args) + ' 2>&1')
531554

532555
print "Running install for %s"%(name,)
533556
runCommand('{ ' + install + ' ;} 2>&1')
@@ -550,7 +573,7 @@ def buildLibraries():
550573
os.makedirs(os.path.join(universal, 'usr', 'local', 'include'))
551574

552575
for recipe in LIBRARY_RECIPES:
553-
buildRecipe(recipe, universal, ('i386', 'ppc',))
576+
buildRecipe(recipe, universal, ARCHLIST)
554577

555578

556579

@@ -997,7 +1020,7 @@ def main():
9971020
buildPythonDocs()
9981021
fn = os.path.join(WORKDIR, "_root", "Applications",
9991022
"MacPython %s"%(getVersion(),), "Update Shell Profile.command")
1000-
shutil.copy("scripts/postflight.patch-profile", fn)
1023+
patchFile("scripts/postflight.patch-profile", fn)
10011024
os.chmod(fn, 0755)
10021025

10031026
folder = os.path.join(WORKDIR, "_root", "Applications", "MacPython %s"%(

setup.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,24 @@ def detect_modules(self):
638638
db_inc_paths.append('/pkg/db-3.%d/include' % x)
639639
db_inc_paths.append('/opt/db-3.%d/include' % x)
640640

641+
# Add some common subdirectories for Sleepycat DB to the list,
642+
# based on the standard include directories. This way DB3/4 gets
643+
# picked up when it is installed in a non-standard prefix and
644+
# the user has added that prefix into inc_dirs.
645+
std_variants = []
646+
for dn in inc_dirs:
647+
std_variants.append(os.path.join(dn, 'db3'))
648+
std_variants.append(os.path.join(dn, 'db4'))
649+
for x in (0,1,2,3,4):
650+
std_variants.append(os.path.join(dn, "db4%d"%x))
651+
std_variants.append(os.path.join(dn, "db4.%d"%x))
652+
for x in (2,3):
653+
std_variants.append(os.path.join(dn, "db3%d"%x))
654+
std_variants.append(os.path.join(dn, "db3.%d"%x))
655+
656+
db_inc_paths = std_variants + db_inc_paths
657+
658+
641659
db_ver_inc_map = {}
642660

643661
class db_found(Exception): pass
@@ -940,13 +958,23 @@ class db_found(Exception): pass
940958
break
941959
if version >= version_req:
942960
if (self.compiler.find_library_file(lib_dirs, 'z')):
961+
if sys.platform == "darwin":
962+
zlib_extra_link_args = ('-Wl,-search_paths_first',)
963+
else:
964+
zlib_extra_link_args = ()
943965
exts.append( Extension('zlib', ['zlibmodule.c'],
944-
libraries = ['z']) )
966+
libraries = ['z'],
967+
extra_link_args = zlib_extra_link_args))
945968

946969
# Gustavo Niemeyer's bz2 module.
947970
if (self.compiler.find_library_file(lib_dirs, 'bz2')):
971+
if sys.platform == "darwin":
972+
bz2_extra_link_args = ('-Wl,-search_paths_first',)
973+
else:
974+
bz2_extra_link_args = ()
948975
exts.append( Extension('bz2', ['bz2module.c'],
949-
libraries = ['bz2']) )
976+
libraries = ['bz2'],
977+
extra_link_args = bz2_extra_link_args) )
950978

951979
# Interface to the Expat XML parser
952980
#

0 commit comments

Comments
 (0)