Annotation of pkgsrc/lang/python27/patches/patch-setup.py, revision 1.1

1.1     ! adam        1: $NetBSD$
        !             2: 
        !             3: Disable certain modules, so they can be built as separate packages.
        !             4: Only check the BUILDLINK_DIR for libraries etc, do not pick up random
        !             5: headers and libraries from the system.
        !             6: 
        !             7: Do not look for ncursesw.
        !             8: Assume panel_library is correct; this is a fix for ncurses' gnupanel
        !             9:   which will get transformed to panel in buildlink.
        !            10: 
        !            11: Build the _ssl module with pkgsrc choiced OpenSSL.
        !            12: 
        !            13: cygwin 2.7.3-no-libm.patch
        !            14: 
        !            15: --- setup.py.orig      2018-04-29 22:47:33.000000000 +0000
        !            16: +++ setup.py
        !            17: @@ -33,7 +33,7 @@ host_platform = get_platform()
        !            18:  COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
        !            19:  
        !            20:  # This global variable is used to hold the list of modules to be disabled.
        !            21: -disabled_module_list = []
        !            22: +disabled_module_list = ["_bsddb", "bsddb185", "_curses", "_curses_panel", "_elementtree", "gdbm", "pyexpat", "readline", "_sqlite3", "_tkinter", "linuxaudiodev", "ossaudiodev", "sunaudiodev"]
        !            23:  
        !            24:  def add_dir_to_list(dirlist, dir):
        !            25:      """Add the directory 'dir' to the list 'dirlist' (at the front) if
        !            26: @@ -454,10 +454,15 @@ class PyBuildExt(build_ext):
        !            27:              os.unlink(tmpfile)
        !            28:  
        !            29:      def detect_modules(self):
        !            30: -        # Ensure that /usr/local is always used
        !            31: -        if not cross_compiling:
        !            32: -            add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
        !            33: -            add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
        !            34: +        # Add the buildlink directories for pkgsrc
        !            35: +        if os.environ.has_key('BUILDLINK_DIR'):
        !            36: +            dir = os.environ['BUILDLINK_DIR']
        !            37: +            libdir = dir + '/lib'
        !            38: +            incdir = dir + '/include'
        !            39: +            if libdir not in self.compiler.library_dirs:
        !            40: +                self.compiler.library_dirs.insert(0, libdir)
        !            41: +            if incdir not in self.compiler.include_dirs:
        !            42: +                self.compiler.include_dirs.insert(0, incdir)
        !            43:          if cross_compiling:
        !            44:              self.add_gcc_paths()
        !            45:          self.add_multiarch_paths()
        !            46: @@ -569,7 +574,7 @@ class PyBuildExt(build_ext):
        !            47:  
        !            48:          # Check for MacOS X, which doesn't need libm.a at all
        !            49:          math_libs = ['m']
        !            50: -        if host_platform in ['darwin', 'beos']:
        !            51: +        if host_platform in ['darwin', 'beos', 'cygwin']:
        !            52:              math_libs = []
        !            53:  
        !            54:          # XXX Omitted modules: gl, pure, dl, SGI-specific modules
        !            55: @@ -745,8 +750,6 @@ class PyBuildExt(build_ext):
        !            56:          # use the same library for the readline and curses modules.
        !            57:          if 'curses' in readline_termcap_library:
        !            58:              curses_library = readline_termcap_library
        !            59: -        elif self.compiler.find_library_file(lib_dirs, 'ncursesw'):
        !            60: -            curses_library = 'ncursesw'
        !            61:          elif self.compiler.find_library_file(lib_dirs, 'ncurses'):
        !            62:              curses_library = 'ncurses'
        !            63:          elif self.compiler.find_library_file(lib_dirs, 'curses'):
        !            64: @@ -809,11 +812,10 @@ class PyBuildExt(build_ext):
        !            65:                                 libraries=math_libs) )
        !            66:          # Detect SSL support for the socket module (via _ssl)
        !            67:          search_for_ssl_incs_in = [
        !            68: -                              '/usr/local/ssl/include',
        !            69: -                              '/usr/contrib/ssl/include/'
        !            70: +                              '@SSLBASE@/include'
        !            71:                               ]
        !            72: -        ssl_incs = find_file('openssl/ssl.h', inc_dirs,
        !            73: -                             search_for_ssl_incs_in
        !            74: +        ssl_incs = find_file('openssl/ssl.h', [],
        !            75: +                             search_for_ssl_incs_in + inc_dirs
        !            76:                               )
        !            77:          if ssl_incs is not None:
        !            78:              krb5_h = find_file('krb5.h', inc_dirs,
        !            79: @@ -821,9 +823,7 @@ class PyBuildExt(build_ext):
        !            80:              if krb5_h:
        !            81:                  ssl_incs += krb5_h
        !            82:          ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
        !            83: -                                     ['/usr/local/ssl/lib',
        !            84: -                                      '/usr/contrib/ssl/lib/'
        !            85: -                                     ] )
        !            86: +                                     [] )
        !            87:  
        !            88:          if (ssl_incs is not None and
        !            89:              ssl_libs is not None):
        !            90: @@ -842,7 +842,7 @@ class PyBuildExt(build_ext):
        !            91:  
        !            92:          # look for the openssl version header on the compiler search path.
        !            93:          opensslv_h = find_file('openssl/opensslv.h', [],
        !            94: -                inc_dirs + search_for_ssl_incs_in)
        !            95: +                search_for_ssl_incs_in + inc_dirs)
        !            96:          if opensslv_h:
        !            97:              name = os.path.join(opensslv_h[0], 'openssl/opensslv.h')
        !            98:              if host_platform == 'darwin' and is_macosx_sdk_path(name):
        !            99: @@ -942,175 +942,6 @@ class PyBuildExt(build_ext):
        !           100:              else:
        !           101:                  raise ValueError("unknown major BerkeleyDB version", major)
        !           102:  
        !           103: -        # construct a list of paths to look for the header file in on
        !           104: -        # top of the normal inc_dirs.
        !           105: -        db_inc_paths = [
        !           106: -            '/usr/include/db4',
        !           107: -            '/usr/local/include/db4',
        !           108: -            '/opt/sfw/include/db4',
        !           109: -            '/usr/include/db3',
        !           110: -            '/usr/local/include/db3',
        !           111: -            '/opt/sfw/include/db3',
        !           112: -            # Fink defaults (http://fink.sourceforge.net/)
        !           113: -            '/sw/include/db4',
        !           114: -            '/sw/include/db3',
        !           115: -        ]
        !           116: -        # 4.x minor number specific paths
        !           117: -        for x in gen_db_minor_ver_nums(4):
        !           118: -            db_inc_paths.append('/usr/include/db4%d' % x)
        !           119: -            db_inc_paths.append('/usr/include/db4.%d' % x)
        !           120: -            db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x)
        !           121: -            db_inc_paths.append('/usr/local/include/db4%d' % x)
        !           122: -            db_inc_paths.append('/pkg/db-4.%d/include' % x)
        !           123: -            db_inc_paths.append('/opt/db-4.%d/include' % x)
        !           124: -            # MacPorts default (http://www.macports.org/)
        !           125: -            db_inc_paths.append('/opt/local/include/db4%d' % x)
        !           126: -        # 3.x minor number specific paths
        !           127: -        for x in gen_db_minor_ver_nums(3):
        !           128: -            db_inc_paths.append('/usr/include/db3%d' % x)
        !           129: -            db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x)
        !           130: -            db_inc_paths.append('/usr/local/include/db3%d' % x)
        !           131: -            db_inc_paths.append('/pkg/db-3.%d/include' % x)
        !           132: -            db_inc_paths.append('/opt/db-3.%d/include' % x)
        !           133: -
        !           134: -        if cross_compiling:
        !           135: -            db_inc_paths = []
        !           136: -
        !           137: -        # Add some common subdirectories for Sleepycat DB to the list,
        !           138: -        # based on the standard include directories. This way DB3/4 gets
        !           139: -        # picked up when it is installed in a non-standard prefix and
        !           140: -        # the user has added that prefix into inc_dirs.
        !           141: -        std_variants = []
        !           142: -        for dn in inc_dirs:
        !           143: -            std_variants.append(os.path.join(dn, 'db3'))
        !           144: -            std_variants.append(os.path.join(dn, 'db4'))
        !           145: -            for x in gen_db_minor_ver_nums(4):
        !           146: -                std_variants.append(os.path.join(dn, "db4%d"%x))
        !           147: -                std_variants.append(os.path.join(dn, "db4.%d"%x))
        !           148: -            for x in gen_db_minor_ver_nums(3):
        !           149: -                std_variants.append(os.path.join(dn, "db3%d"%x))
        !           150: -                std_variants.append(os.path.join(dn, "db3.%d"%x))
        !           151: -
        !           152: -        db_inc_paths = std_variants + db_inc_paths
        !           153: -        db_inc_paths = [p for p in db_inc_paths if os.path.exists(p)]
        !           154: -
        !           155: -        db_ver_inc_map = {}
        !           156: -
        !           157: -        if host_platform == 'darwin':
        !           158: -            sysroot = macosx_sdk_root()
        !           159: -
        !           160: -        class db_found(Exception): pass
        !           161: -        try:
        !           162: -            # See whether there is a Sleepycat header in the standard
        !           163: -            # search path.
        !           164: -            for d in inc_dirs + db_inc_paths:
        !           165: -                f = os.path.join(d, "db.h")
        !           166: -
        !           167: -                if host_platform == 'darwin' and is_macosx_sdk_path(d):
        !           168: -                    f = os.path.join(sysroot, d[1:], "db.h")
        !           169: -
        !           170: -                if db_setup_debug: print "db: looking for db.h in", f
        !           171: -                if os.path.exists(f):
        !           172: -                    f = open(f).read()
        !           173: -                    m = re.search(r"#define\WDB_VERSION_MAJOR\W(\d+)", f)
        !           174: -                    if m:
        !           175: -                        db_major = int(m.group(1))
        !           176: -                        m = re.search(r"#define\WDB_VERSION_MINOR\W(\d+)", f)
        !           177: -                        db_minor = int(m.group(1))
        !           178: -                        db_ver = (db_major, db_minor)
        !           179: -
        !           180: -                        # Avoid 4.6 prior to 4.6.21 due to a BerkeleyDB bug
        !           181: -                        if db_ver == (4, 6):
        !           182: -                            m = re.search(r"#define\WDB_VERSION_PATCH\W(\d+)", f)
        !           183: -                            db_patch = int(m.group(1))
        !           184: -                            if db_patch < 21:
        !           185: -                                print "db.h:", db_ver, "patch", db_patch,
        !           186: -                                print "being ignored (4.6.x must be >= 4.6.21)"
        !           187: -                                continue
        !           188: -
        !           189: -                        if ( (db_ver not in db_ver_inc_map) and
        !           190: -                            allow_db_ver(db_ver) ):
        !           191: -                            # save the include directory with the db.h version
        !           192: -                            # (first occurrence only)
        !           193: -                            db_ver_inc_map[db_ver] = d
        !           194: -                            if db_setup_debug:
        !           195: -                                print "db.h: found", db_ver, "in", d
        !           196: -                        else:
        !           197: -                            # we already found a header for this library version
        !           198: -                            if db_setup_debug: print "db.h: ignoring", d
        !           199: -                    else:
        !           200: -                        # ignore this header, it didn't contain a version number
        !           201: -                        if db_setup_debug:
        !           202: -                            print "db.h: no version number version in", d
        !           203: -
        !           204: -            db_found_vers = db_ver_inc_map.keys()
        !           205: -            db_found_vers.sort()
        !           206: -
        !           207: -            while db_found_vers:
        !           208: -                db_ver = db_found_vers.pop()
        !           209: -                db_incdir = db_ver_inc_map[db_ver]
        !           210: -
        !           211: -                # check lib directories parallel to the location of the header
        !           212: -                db_dirs_to_check = [
        !           213: -                    db_incdir.replace("include", 'lib64'),
        !           214: -                    db_incdir.replace("include", 'lib'),
        !           215: -                ]
        !           216: -
        !           217: -                if host_platform != 'darwin':
        !           218: -                    db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check)
        !           219: -
        !           220: -                else:
        !           221: -                    # Same as other branch, but takes OSX SDK into account
        !           222: -                    tmp = []
        !           223: -                    for dn in db_dirs_to_check:
        !           224: -                        if is_macosx_sdk_path(dn):
        !           225: -                            if os.path.isdir(os.path.join(sysroot, dn[1:])):
        !           226: -                                tmp.append(dn)
        !           227: -                        else:
        !           228: -                            if os.path.isdir(dn):
        !           229: -                                tmp.append(dn)
        !           230: -                    db_dirs_to_check = tmp
        !           231: -
        !           232: -                # Look for a version specific db-X.Y before an ambiguous dbX
        !           233: -                # XXX should we -ever- look for a dbX name?  Do any
        !           234: -                # systems really not name their library by version and
        !           235: -                # symlink to more general names?
        !           236: -                for dblib in (('db-%d.%d' % db_ver),
        !           237: -                              ('db%d%d' % db_ver),
        !           238: -                              ('db%d' % db_ver[0])):
        !           239: -                    dblib_file = self.compiler.find_library_file(
        !           240: -                                    db_dirs_to_check + lib_dirs, dblib )
        !           241: -                    if dblib_file:
        !           242: -                        dblib_dir = [ os.path.abspath(os.path.dirname(dblib_file)) ]
        !           243: -                        raise db_found
        !           244: -                    else:
        !           245: -                        if db_setup_debug: print "db lib: ", dblib, "not found"
        !           246: -
        !           247: -        except db_found:
        !           248: -            if db_setup_debug:
        !           249: -                print "bsddb using BerkeleyDB lib:", db_ver, dblib
        !           250: -                print "bsddb lib dir:", dblib_dir, " inc dir:", db_incdir
        !           251: -            db_incs = [db_incdir]
        !           252: -            dblibs = [dblib]
        !           253: -            # We add the runtime_library_dirs argument because the
        !           254: -            # BerkeleyDB lib we're linking against often isn't in the
        !           255: -            # system dynamic library search path.  This is usually
        !           256: -            # correct and most trouble free, but may cause problems in
        !           257: -            # some unusual system configurations (e.g. the directory
        !           258: -            # is on an NFS server that goes away).
        !           259: -            exts.append(Extension('_bsddb', ['_bsddb.c'],
        !           260: -                                  depends = ['bsddb.h'],
        !           261: -                                  library_dirs=dblib_dir,
        !           262: -                                  runtime_library_dirs=dblib_dir,
        !           263: -                                  include_dirs=db_incs,
        !           264: -                                  libraries=dblibs))
        !           265: -        else:
        !           266: -            if db_setup_debug: print "db: no appropriate library found"
        !           267: -            db_incs = None
        !           268: -            dblibs = []
        !           269: -            dblib_dir = None
        !           270: -            missing.append('_bsddb')
        !           271: -
        !           272:          # The sqlite interface
        !           273:          sqlite_setup_debug = False   # verbose debug prints from this script?
        !           274:  
        !           275: @@ -1216,46 +1047,32 @@ class PyBuildExt(build_ext):
        !           276:          else:
        !           277:              missing.append('_sqlite3')
        !           278:  
        !           279: -        # Look for Berkeley db 1.85.   Note that it is built as a different
        !           280: -        # module name so it can be included even when later versions are
        !           281: -        # available.  A very restrictive search is performed to avoid
        !           282: -        # accidentally building this module with a later version of the
        !           283: -        # underlying db library.  May BSD-ish Unixes incorporate db 1.85
        !           284: -        # symbols into libc and place the include file in /usr/include.
        !           285: -        #
        !           286: -        # If the better bsddb library can be built (db_incs is defined)
        !           287: -        # we do not build this one.  Otherwise this build will pick up
        !           288: -        # the more recent berkeleydb's db.h file first in the include path
        !           289: -        # when attempting to compile and it will fail.
        !           290: -        f = "/usr/include/db.h"
        !           291: -
        !           292: -        if host_platform == 'darwin':
        !           293: -            if is_macosx_sdk_path(f):
        !           294: -                sysroot = macosx_sdk_root()
        !           295: -                f = os.path.join(sysroot, f[1:])
        !           296: -
        !           297: -        if os.path.exists(f) and not db_incs:
        !           298: -            data = open(f).read()
        !           299: -            m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
        !           300: -            if m is not None:
        !           301: -                # bingo - old version used hash file format version 2
        !           302: -                ### XXX this should be fixed to not be platform-dependent
        !           303: -                ### but I don't have direct access to an osf1 platform and
        !           304: -                ### seemed to be muffing the search somehow
        !           305: -                libraries = host_platform == "osf1" and ['db'] or None
        !           306: -                if libraries is not None:
        !           307: -                    exts.append(Extension('bsddb185', ['bsddbmodule.c'],
        !           308: -                                          libraries=libraries))
        !           309: -                else:
        !           310: -                    exts.append(Extension('bsddb185', ['bsddbmodule.c']))
        !           311: -            else:
        !           312: -                missing.append('bsddb185')
        !           313: -        else:
        !           314: -            missing.append('bsddb185')
        !           315: -
        !           316:          dbm_order = ['gdbm']
        !           317:          # The standard Unix dbm module:
        !           318:          if host_platform not in ['cygwin']:
        !           319: +            ## Top half based on find_file
        !           320: +            def find_ndbm_h(dirs):
        !           321: +                ret = None
        !           322: +                if sys.platform == 'darwin':
        !           323: +                    sysroot = macosx_sdk_root()
        !           324: +                for dir in dirs:
        !           325: +                    f = os.path.join(dir, 'ndbm.h')
        !           326: +                    if sys.platform == 'darwin' and is_macosx_sdk_path(dir):
        !           327: +                        f = os.path.join(sysroot, dir[1:], 'ndbm.h')
        !           328: +                    if not os.path.exists(f): continue
        !           329: +
        !           330: +                    ret = 'True'
        !           331: +                    input = text_file.TextFile(f)
        !           332: +                    while 1:
        !           333: +                        line = input.readline()
        !           334: +                        if not line: break
        !           335: +                        if re.search('This file is part of GDBM', line):
        !           336: +                            ret = None
        !           337: +                            break
        !           338: +                    input.close()
        !           339: +                    break
        !           340: +                return ret
        !           341: +
        !           342:              config_args = [arg.strip("'")
        !           343:                             for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
        !           344:              dbm_args = [arg for arg in config_args
        !           345: @@ -1267,7 +1084,7 @@ class PyBuildExt(build_ext):
        !           346:              dbmext = None
        !           347:              for cand in dbm_order:
        !           348:                  if cand == "ndbm":
        !           349: -                    if find_file("ndbm.h", inc_dirs, []) is not None:
        !           350: +                    if find_ndbm_h(inc_dirs) is not None:
        !           351:                          # Some systems have -lndbm, others have -lgdbm_compat,
        !           352:                          # others don't have either
        !           353:                          if self.compiler.find_library_file(lib_dirs,
        !           354: @@ -1311,18 +1128,14 @@ class PyBuildExt(build_ext):
        !           355:                                  libraries = gdbm_libs)
        !           356:                              break
        !           357:                  elif cand == "bdb":
        !           358: -                    if db_incs is not None:
        !           359: -                        print "building dbm using bdb"
        !           360: -                        dbmext = Extension('dbm', ['dbmmodule.c'],
        !           361: -                                           library_dirs=dblib_dir,
        !           362: -                                           runtime_library_dirs=dblib_dir,
        !           363: -                                           include_dirs=db_incs,
        !           364: -                                           define_macros=[
        !           365: -                                               ('HAVE_BERKDB_H', None),
        !           366: -                                               ('DB_DBM_HSEARCH', None),
        !           367: -                                               ],
        !           368: -                                           libraries=dblibs)
        !           369: -                        break
        !           370: +                  print "building dbm using bdb"
        !           371: +                  dbmext = Extension('dbm', ['dbmmodule.c'],
        !           372: +                                     define_macros=[
        !           373: +                                         ('HAVE_BERKDB_H', None),
        !           374: +                                         ('DB_DBM_HSEARCH', None),
        !           375: +                                         ],
        !           376: +                                     libraries=["db"])
        !           377: +                  break
        !           378:              if dbmext is not None:
        !           379:                  exts.append(dbmext)
        !           380:              else:
        !           381: @@ -1383,8 +1196,7 @@ class PyBuildExt(build_ext):
        !           382:              missing.append('_curses')
        !           383:  
        !           384:          # If the curses module is enabled, check for the panel module
        !           385: -        if (module_enabled(exts, '_curses') and
        !           386: -            self.compiler.find_library_file(lib_dirs, panel_library)):
        !           387: +        if (module_enabled(exts, '_curses')):
        !           388:              exts.append( Extension('_curses_panel', ['_curses_panel.c'],
        !           389:                                     include_dirs = curses_incs,
        !           390:                                     libraries = [panel_library] + curses_libs) )
        !           391: @@ -2296,9 +2108,9 @@ def main():
        !           392:            ext_modules=[Extension('_struct', ['_struct.c'])],
        !           393:  
        !           394:            # Scripts to install
        !           395: -          scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle',
        !           396: -                     'Tools/scripts/2to3',
        !           397: -                     'Lib/smtpd.py']
        !           398: +          scripts = ['Tools/scripts/pydoc2.7',
        !           399: +                     'Tools/scripts/2to3-2.7',
        !           400: +                     'Tools/scripts/smtpd2.7.py']
        !           401:          )
        !           402:  
        !           403:  # --install-platlib

CVSweb <webmaster@jp.NetBSD.org>