e9c5eab9e8
coping the Mac OS X sdk filename handling. Thank to Matthias Rampke in PR#45581 for catching this.
384 lines
16 KiB
Text
384 lines
16 KiB
Text
$NetBSD: patch-am,v 1.19 2011/11/08 07:30:08 sbd Exp $
|
|
|
|
Disabled modules for normal build:
|
|
bsddb
|
|
curses
|
|
curses_panel
|
|
elementtree
|
|
sqlite3
|
|
tkinter
|
|
gdbm
|
|
pyexpat
|
|
readline
|
|
{linux,oss,sun}audiodev
|
|
spwd
|
|
Those have separate packages where needed.
|
|
|
|
Only check the BUILDLINK_DIR for libraries etc, do not pick up random
|
|
headers and libraries from the system.
|
|
|
|
Build the 1.85 compat module all the time against the BDB version of choice.
|
|
|
|
Add in Debian multiarch support (retrofitted from Python 2.7.2) to
|
|
support building the "nis" and "crypt" modules.
|
|
|
|
--- setup.py 2010-07-18 00:31:09.000000000 +1200
|
|
+++ setup.py 2011-09-23 01:51:17.757519638 +1200
|
|
@@ -18,7 +18,7 @@
|
|
from distutils.spawn import find_executable
|
|
|
|
# This global variable is used to hold the list of modules to be disabled.
|
|
-disabled_module_list = []
|
|
+disabled_module_list = ["_bsddb", "_curses", "_curses_panel", "_elementtree", "_sqlite3", "_tkinter", "gdbm", "pyexpat", "readline", "linuxaudiodev", "ossaudiodev", "spwd", "sunaudiodev"]
|
|
|
|
def add_dir_to_list(dirlist, dir):
|
|
"""Add the directory 'dir' to the list 'dirlist' (at the front) if
|
|
@@ -354,10 +354,40 @@
|
|
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')
|
|
+ # Add the buildlink directories for pkgsrc
|
|
+ if os.environ.has_key('BUILDLINK_DIR'):
|
|
+ dir = os.environ['BUILDLINK_DIR']
|
|
+ libdir = dir + '/lib'
|
|
+ incdir = dir + '/include'
|
|
+ if libdir not in self.compiler.library_dirs:
|
|
+ self.compiler.library_dirs.insert(0, libdir)
|
|
+ if incdir not in self.compiler.include_dirs:
|
|
+ self.compiler.include_dirs.insert(0, incdir)
|
|
+
|
|
+ self.add_multiarch_paths()
|
|
|
|
# Add paths specified in the environment variables LDFLAGS and
|
|
# CPPFLAGS for header and library files.
|
|
@@ -703,9 +733,7 @@
|
|
if krb5_h:
|
|
ssl_incs += krb5_h
|
|
ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
|
|
- ['/usr/local/ssl/lib',
|
|
- '/usr/contrib/ssl/lib/'
|
|
- ] )
|
|
+ [] )
|
|
|
|
if (ssl_incs is not None and
|
|
ssl_libs is not None):
|
|
@@ -815,172 +843,6 @@
|
|
else:
|
|
raise ValueError("unknown major BerkeleyDB version", major)
|
|
|
|
- # construct a list of paths to look for the header file in on
|
|
- # top of the normal inc_dirs.
|
|
- db_inc_paths = [
|
|
- '/usr/include/db4',
|
|
- '/usr/local/include/db4',
|
|
- '/opt/sfw/include/db4',
|
|
- '/usr/include/db3',
|
|
- '/usr/local/include/db3',
|
|
- '/opt/sfw/include/db3',
|
|
- # Fink defaults (http://fink.sourceforge.net/)
|
|
- '/sw/include/db4',
|
|
- '/sw/include/db3',
|
|
- ]
|
|
- # 4.x minor number specific paths
|
|
- for x in gen_db_minor_ver_nums(4):
|
|
- db_inc_paths.append('/usr/include/db4%d' % x)
|
|
- db_inc_paths.append('/usr/include/db4.%d' % x)
|
|
- db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x)
|
|
- db_inc_paths.append('/usr/local/include/db4%d' % x)
|
|
- db_inc_paths.append('/pkg/db-4.%d/include' % x)
|
|
- db_inc_paths.append('/opt/db-4.%d/include' % x)
|
|
- # MacPorts default (http://www.macports.org/)
|
|
- db_inc_paths.append('/opt/local/include/db4%d' % x)
|
|
- # 3.x minor number specific paths
|
|
- for x in gen_db_minor_ver_nums(3):
|
|
- db_inc_paths.append('/usr/include/db3%d' % x)
|
|
- db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x)
|
|
- db_inc_paths.append('/usr/local/include/db3%d' % x)
|
|
- db_inc_paths.append('/pkg/db-3.%d/include' % x)
|
|
- db_inc_paths.append('/opt/db-3.%d/include' % x)
|
|
-
|
|
- # Add some common subdirectories for Sleepycat DB to the list,
|
|
- # based on the standard include directories. This way DB3/4 gets
|
|
- # picked up when it is installed in a non-standard prefix and
|
|
- # the user has added that prefix into inc_dirs.
|
|
- std_variants = []
|
|
- for dn in inc_dirs:
|
|
- std_variants.append(os.path.join(dn, 'db3'))
|
|
- std_variants.append(os.path.join(dn, 'db4'))
|
|
- for x in gen_db_minor_ver_nums(4):
|
|
- std_variants.append(os.path.join(dn, "db4%d"%x))
|
|
- std_variants.append(os.path.join(dn, "db4.%d"%x))
|
|
- for x in gen_db_minor_ver_nums(3):
|
|
- std_variants.append(os.path.join(dn, "db3%d"%x))
|
|
- std_variants.append(os.path.join(dn, "db3.%d"%x))
|
|
-
|
|
- db_inc_paths = std_variants + db_inc_paths
|
|
- db_inc_paths = [p for p in db_inc_paths if os.path.exists(p)]
|
|
-
|
|
- db_ver_inc_map = {}
|
|
-
|
|
- if sys.platform == 'darwin':
|
|
- sysroot = macosx_sdk_root()
|
|
-
|
|
- class db_found(Exception): pass
|
|
- try:
|
|
- # See whether there is a Sleepycat header in the standard
|
|
- # search path.
|
|
- for d in inc_dirs + db_inc_paths:
|
|
- f = os.path.join(d, "db.h")
|
|
-
|
|
- if sys.platform == 'darwin' and is_macosx_sdk_path(d):
|
|
- f = os.path.join(sysroot, d[1:], "db.h")
|
|
-
|
|
- if db_setup_debug: print "db: looking for db.h in", f
|
|
- if os.path.exists(f):
|
|
- f = open(f).read()
|
|
- m = re.search(r"#define\WDB_VERSION_MAJOR\W(\d+)", f)
|
|
- if m:
|
|
- db_major = int(m.group(1))
|
|
- m = re.search(r"#define\WDB_VERSION_MINOR\W(\d+)", f)
|
|
- db_minor = int(m.group(1))
|
|
- db_ver = (db_major, db_minor)
|
|
-
|
|
- # Avoid 4.6 prior to 4.6.21 due to a BerkeleyDB bug
|
|
- if db_ver == (4, 6):
|
|
- m = re.search(r"#define\WDB_VERSION_PATCH\W(\d+)", f)
|
|
- db_patch = int(m.group(1))
|
|
- if db_patch < 21:
|
|
- print "db.h:", db_ver, "patch", db_patch,
|
|
- print "being ignored (4.6.x must be >= 4.6.21)"
|
|
- continue
|
|
-
|
|
- if ( (db_ver not in db_ver_inc_map) and
|
|
- allow_db_ver(db_ver) ):
|
|
- # save the include directory with the db.h version
|
|
- # (first occurrence only)
|
|
- db_ver_inc_map[db_ver] = d
|
|
- if db_setup_debug:
|
|
- print "db.h: found", db_ver, "in", d
|
|
- else:
|
|
- # we already found a header for this library version
|
|
- if db_setup_debug: print "db.h: ignoring", d
|
|
- else:
|
|
- # ignore this header, it didn't contain a version number
|
|
- if db_setup_debug:
|
|
- print "db.h: no version number version in", d
|
|
-
|
|
- db_found_vers = db_ver_inc_map.keys()
|
|
- db_found_vers.sort()
|
|
-
|
|
- while db_found_vers:
|
|
- db_ver = db_found_vers.pop()
|
|
- db_incdir = db_ver_inc_map[db_ver]
|
|
-
|
|
- # check lib directories parallel to the location of the header
|
|
- db_dirs_to_check = [
|
|
- db_incdir.replace("include", 'lib64'),
|
|
- db_incdir.replace("include", 'lib'),
|
|
- ]
|
|
-
|
|
- if sys.platform != 'darwin':
|
|
- db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check)
|
|
-
|
|
- else:
|
|
- # Same as other branch, but takes OSX SDK into account
|
|
- tmp = []
|
|
- for dn in db_dirs_to_check:
|
|
- if is_macosx_sdk_path(dn):
|
|
- if os.path.isdir(os.path.join(sysroot, dn[1:])):
|
|
- tmp.append(dn)
|
|
- else:
|
|
- if os.path.isdir(dn):
|
|
- tmp.append(dn)
|
|
- db_dirs_to_check = tmp
|
|
-
|
|
- # Look for a version specific db-X.Y before an ambiguoius dbX
|
|
- # XXX should we -ever- look for a dbX name? Do any
|
|
- # systems really not name their library by version and
|
|
- # symlink to more general names?
|
|
- for dblib in (('db-%d.%d' % db_ver),
|
|
- ('db%d%d' % db_ver),
|
|
- ('db%d' % db_ver[0])):
|
|
- dblib_file = self.compiler.find_library_file(
|
|
- db_dirs_to_check + lib_dirs, dblib )
|
|
- if dblib_file:
|
|
- dblib_dir = [ os.path.abspath(os.path.dirname(dblib_file)) ]
|
|
- raise db_found
|
|
- else:
|
|
- if db_setup_debug: print "db lib: ", dblib, "not found"
|
|
-
|
|
- except db_found:
|
|
- if db_setup_debug:
|
|
- print "bsddb using BerkeleyDB lib:", db_ver, dblib
|
|
- print "bsddb lib dir:", dblib_dir, " inc dir:", db_incdir
|
|
- db_incs = [db_incdir]
|
|
- dblibs = [dblib]
|
|
- # We add the runtime_library_dirs argument because the
|
|
- # BerkeleyDB lib we're linking against often isn't in the
|
|
- # system dynamic library search path. This is usually
|
|
- # correct and most trouble free, but may cause problems in
|
|
- # some unusual system configurations (e.g. the directory
|
|
- # is on an NFS server that goes away).
|
|
- exts.append(Extension('_bsddb', ['_bsddb.c'],
|
|
- depends = ['bsddb.h'],
|
|
- library_dirs=dblib_dir,
|
|
- runtime_library_dirs=dblib_dir,
|
|
- include_dirs=db_incs,
|
|
- libraries=dblibs))
|
|
- else:
|
|
- if db_setup_debug: print "db: no appropriate library found"
|
|
- db_incs = None
|
|
- dblibs = []
|
|
- dblib_dir = None
|
|
- missing.append('_bsddb')
|
|
-
|
|
# The sqlite interface
|
|
sqlite_setup_debug = False # verbose debug prints from this script?
|
|
|
|
@@ -1094,35 +956,40 @@
|
|
# we do not build this one. Otherwise this build will pick up
|
|
# the more recent berkeleydb's db.h file first in the include path
|
|
# when attempting to compile and it will fail.
|
|
- f = "/usr/include/db.h"
|
|
-
|
|
- if sys.platform == 'darwin':
|
|
- if is_macosx_sdk_path(f):
|
|
- sysroot = macosx_sdk_root()
|
|
- f = os.path.join(sysroot, f[1:])
|
|
-
|
|
- if os.path.exists(f) and not db_incs:
|
|
- data = open(f).read()
|
|
- m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
|
|
- if m is not None:
|
|
- # bingo - old version used hash file format version 2
|
|
- ### XXX this should be fixed to not be platform-dependent
|
|
- ### but I don't have direct access to an osf1 platform and
|
|
- ### seemed to be muffing the search somehow
|
|
- libraries = platform == "osf1" and ['db'] or None
|
|
- if libraries is not None:
|
|
- exts.append(Extension('bsddb185', ['bsddbmodule.c'],
|
|
- libraries=libraries))
|
|
- else:
|
|
- exts.append(Extension('bsddb185', ['bsddbmodule.c']))
|
|
- else:
|
|
- missing.append('bsddb185')
|
|
+ libraries = os.getenv("PY_BDB_TYPE", "")
|
|
+ if libraries:
|
|
+ exts.append(Extension('bsddb185', ['bsddbmodule.c'],
|
|
+ libraries=["db"]))
|
|
else:
|
|
- missing.append('bsddb185')
|
|
+ exts.append(Extension('bsddb185', ['bsddbmodule.c']))
|
|
|
|
# The standard Unix dbm module:
|
|
if platform not in ['cygwin']:
|
|
- if find_file("ndbm.h", inc_dirs, []) is not None:
|
|
+
|
|
+ ## Top half based on find_file
|
|
+ def find_ndbm_h(dirs):
|
|
+ ret = None
|
|
+ if sys.platform == 'darwin':
|
|
+ sysroot = macosx_sdk_root()
|
|
+ for dir in dirs:
|
|
+ f = os.path.join(dir, 'ndbm.h')
|
|
+ if sys.platform == 'darwin' and is_macosx_sdk_path(dir):
|
|
+ f = os.path.join(sysroot, dir[1:], 'ndbm.h')
|
|
+ if not os.path.exists(f): continue
|
|
+
|
|
+ ret = 'True'
|
|
+ input = text_file.TextFile(f)
|
|
+ while 1:
|
|
+ line = input.readline()
|
|
+ if not line: break
|
|
+ if re.search('This file is part of GDBM', line):
|
|
+ ret = None
|
|
+ break
|
|
+ input.close()
|
|
+ break
|
|
+ return ret
|
|
+
|
|
+ if find_ndbm_h(inc_dirs) is not None:
|
|
# Some systems have -lndbm, others don't
|
|
if self.compiler.find_library_file(lib_dirs, 'ndbm'):
|
|
ndbm_libs = ['ndbm']
|
|
@@ -1131,7 +998,7 @@
|
|
exts.append( Extension('dbm', ['dbmmodule.c'],
|
|
define_macros=[('HAVE_NDBM_H',None)],
|
|
libraries = ndbm_libs ) )
|
|
- elif self.compiler.find_library_file(lib_dirs, 'gdbm'):
|
|
+ elif 1==0 and self.compiler.find_library_file(lib_dirs, 'gdbm'):
|
|
gdbm_libs = ['gdbm']
|
|
if self.compiler.find_library_file(lib_dirs, 'gdbm_compat'):
|
|
gdbm_libs.append('gdbm_compat')
|
|
@@ -1147,14 +1014,12 @@
|
|
libraries = gdbm_libs ) )
|
|
else:
|
|
missing.append('dbm')
|
|
- elif db_incs is not None:
|
|
+
|
|
+ if not module_enabled(exts, 'dbm'):
|
|
exts.append( Extension('dbm', ['dbmmodule.c'],
|
|
- library_dirs=dblib_dir,
|
|
- runtime_library_dirs=dblib_dir,
|
|
- include_dirs=db_incs,
|
|
define_macros=[('HAVE_BERKDB_H',None),
|
|
('DB_DBM_HSEARCH',None)],
|
|
- libraries=dblibs))
|
|
+ libraries=["db"]))
|
|
else:
|
|
missing.append('dbm')
|
|
|
|
@@ -1408,6 +1273,14 @@
|
|
)
|
|
libraries = []
|
|
|
|
+ elif platform.startswith('dragonfly'):
|
|
+ macros = dict(
|
|
+ HAVE_SEM_OPEN=0,
|
|
+ HAVE_SEM_TIMEDWAIT=0,
|
|
+ HAVE_FD_TRANSFER=1,
|
|
+ )
|
|
+ libraries = []
|
|
+
|
|
else: # Linux and other unices
|
|
macros = dict(
|
|
HAVE_SEM_OPEN=1,
|
|
@@ -2026,9 +1899,9 @@
|
|
ext_modules=[Extension('_struct', ['_struct.c'])],
|
|
|
|
# Scripts to install
|
|
- scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle',
|
|
- 'Tools/scripts/2to3',
|
|
- 'Lib/smtpd.py']
|
|
+ scripts = ['Tools/scripts/pydoc2.6',
|
|
+ 'Tools/scripts/2to3-2.6',
|
|
+ 'Lib/smtpd2.6.py']
|
|
)
|
|
|
|
# --install-platlib
|