Annotation of pkgsrc/lang/python310/patches/patch-setup.py, revision 1.4

1.4     ! tnn         1: $NetBSD: patch-setup.py,v 1.3 2022/01/11 15:13:20 tnn Exp $
1.1       adam        2: 
                      3: Disable certain modules, so they can be built as separate packages.
                      4: Do not look for ncursesw.
                      5: Assume panel_library is correct; this is a fix for ncurses' gnupanel
                      6: which will get transformed to panel in buildlink.
1.3       tnn         7: Don't search for modules in PREFIX. Fixes build failure when py-setuptools
                      8:   are installed.  
1.1       adam        9: 
1.2       adam       10: --- setup.py.orig      2021-12-06 18:23:39.000000000 +0000
1.1       adam       11: +++ setup.py
1.3       tnn        12: @@ -13,6 +13,7 @@ import warnings
                     13:  from glob import glob, escape
                     14:  import _osx_support
                     15:  
1.4     ! tnn        16: +sys.path = [p for p in sys.path if not re.compile('^' + sys.base_prefix + '/').match(p)]
1.3       tnn        17:  
                     18:  try:
                     19:      import subprocess
                     20: @@ -45,6 +46,7 @@ with warnings.catch_warnings():
1.1       adam       21:          DeprecationWarning
                     22:      )
                     23:  
                     24: +    from distutils import text_file
                     25:      from distutils.command.build_ext import build_ext
                     26:      from distutils.command.build_scripts import build_scripts
                     27:      from distutils.command.install import install
1.3       tnn        28: @@ -58,7 +60,7 @@ with warnings.catch_warnings():
1.1       adam       29:  TEST_EXTENSIONS = (sysconfig.get_config_var('TEST_MODULES') == 'yes')
                     30:  
                     31:  # This global variable is used to hold the list of modules to be disabled.
                     32: -DISABLED_MODULE_LIST = []
                     33: +DISABLED_MODULE_LIST = ["_curses", "_curses_panel", "_elementtree", "_gdbm", "pyexpat", "readline", "_sqlite3", "_tkinter", "xxlimited"]
                     34:  
                     35:  # --list-module-names option used by Tools/scripts/generate_module_names.py
                     36:  LIST_MODULE_NAMES = False
1.3       tnn        37: @@ -249,6 +251,16 @@ def grep_headers_for(function, headers):
1.1       adam       38:      return False
                     39:  
                     40:  
                     41: +def grep_headers_for(function, headers):
                     42: +    for header in headers:
                     43: +        try:
                     44: +            with open(header, 'r') as f:
                     45: +                if function in f.read():
                     46: +                    return True
                     47: +        except UnicodeDecodeError:
                     48: +            pass
                     49: +    return False
                     50: +
                     51:  def find_file(filename, std_dirs, paths):
                     52:      """Searches for the directory where a given file is located,
                     53:      and returns a possibly-empty list of additional directories, or None
1.3       tnn        54: @@ -821,15 +833,15 @@ class PyBuildExt(build_ext):
1.1       adam       55:                          add_dir_to_list(dir_list, directory)
                     56:  
                     57:      def configure_compiler(self):
                     58: -        # Ensure that /usr/local is always used, but the local build
                     59: -        # directories (i.e. '.' and 'Include') must be first.  See issue
                     60: -        # 10520.
                     61: -        if not CROSS_COMPILING:
                     62: -            add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
                     63: -            add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
                     64: -        # only change this for cross builds for 3.3, issues on Mageia
                     65: -        if CROSS_COMPILING:
                     66: -            self.add_cross_compiling_paths()
                     67: +        # Add the buildlink directories for pkgsrc
                     68: +        if os.environ.get('BUILDLINK_DIR'):
                     69: +            dir = os.environ['BUILDLINK_DIR']
                     70: +            libdir = dir + '/lib'
                     71: +            incdir = dir + '/include'
                     72: +            if libdir not in self.compiler.library_dirs:
                     73: +                self.compiler.library_dirs.insert(0, libdir)
                     74: +            if incdir not in self.compiler.include_dirs:
                     75: +                self.compiler.include_dirs.insert(0, incdir)
                     76:          self.add_multiarch_paths()
                     77:          self.add_ldflags_cppflags()
                     78:  
1.3       tnn        79: @@ -877,6 +889,9 @@ class PyBuildExt(build_ext):
1.1       adam       80:              self.lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32']
                     81:  
                     82:          if MACOS:
                     83: +            self.inc_dirs.append(macosx_sdk_root() + '/usr/include')
                     84: +            self.lib_dirs.append(macosx_sdk_root() + '/usr/lib')
                     85: +
                     86:              # This should work on any unixy platform ;-)
                     87:              # If the user has bothered specifying additional -I and -L flags
                     88:              # in OPT and LDFLAGS we might as well use them here.
1.3       tnn        89: @@ -1104,8 +1119,6 @@ class PyBuildExt(build_ext):
1.1       adam       90:          # use the same library for the readline and curses modules.
                     91:          if 'curses' in readline_termcap_library:
                     92:              curses_library = readline_termcap_library
                     93: -        elif self.compiler.find_library_file(self.lib_dirs, 'ncursesw'):
                     94: -            curses_library = 'ncursesw'
                     95:          # Issue 36210: OSS provided ncurses does not link on AIX
                     96:          # Use IBM supplied 'curses' for successful build of _curses
                     97:          elif AIX and self.compiler.find_library_file(self.lib_dirs, 'curses'):
1.3       tnn        98: @@ -1209,8 +1222,7 @@ class PyBuildExt(build_ext):
1.1       adam       99:          # If the curses module is enabled, check for the panel module
                    100:          # _curses_panel needs some form of ncurses
                    101:          skip_curses_panel = True if AIX else False
                    102: -        if (curses_enabled and not skip_curses_panel and
                    103: -                self.compiler.find_library_file(self.lib_dirs, panel_library)):
                    104: +        if curses_enabled and not skip_curses_panel:
                    105:              self.add(Extension('_curses_panel', ['_curses_panel.c'],
                    106:                             include_dirs=curses_includes,
                    107:                             define_macros=curses_defines,
1.3       tnn       108: @@ -1455,6 +1467,31 @@ class PyBuildExt(build_ext):
1.1       adam      109:          dbm_order = ['gdbm']
                    110:          # The standard Unix dbm module:
                    111:          if not CYGWIN:
                    112: +            # Top half based on find_file
                    113: +            def find_ndbm_h(dirs):
                    114: +                ret = None
                    115: +                if MACOS:
                    116: +                    sysroot = macosx_sdk_root()
                    117: +                for dir in dirs:
                    118: +                    f = os.path.join(dir, 'ndbm.h')
                    119: +                    if MACOS and is_macosx_sdk_path(dir):
                    120: +                        f = os.path.join(sysroot, dir[1:], 'ndbm.h')
                    121: +                    if not os.path.exists(f):
                    122: +                        continue
                    123: +
                    124: +                    ret = True
                    125: +                    input = text_file.TextFile(f)
                    126: +                    while True:
                    127: +                        line = input.readline()
                    128: +                        if not line:
                    129: +                            break
                    130: +                        if re.search('This file is part of GDBM', line):
                    131: +                            ret = None
                    132: +                            break
                    133: +                    input.close()
                    134: +                    break
                    135: +                return ret
                    136: +
                    137:              config_args = [arg.strip("'")
                    138:                             for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
                    139:              dbm_args = [arg for arg in config_args
1.3       tnn       140: @@ -1466,7 +1503,7 @@ class PyBuildExt(build_ext):
1.1       adam      141:              dbmext = None
                    142:              for cand in dbm_order:
                    143:                  if cand == "ndbm":
                    144: -                    if find_file("ndbm.h", self.inc_dirs, []) is not None:
                    145: +                    if find_ndbm_h(self.inc_dirs) is not None:
                    146:                          # Some systems have -lndbm, others have -lgdbm_compat,
                    147:                          # others don't have either
                    148:                          if self.compiler.find_library_file(self.lib_dirs,
1.3       tnn       149: @@ -2326,10 +2363,7 @@ class PyBuildExt(build_ext):
1.1       adam      150:              sources = ['_decimal/_decimal.c']
                    151:              depends = ['_decimal/docstrings.h']
                    152:          else:
                    153: -            include_dirs = [os.path.abspath(os.path.join(self.srcdir,
                    154: -                                                         'Modules',
                    155: -                                                         '_decimal',
                    156: -                                                         'libmpdec'))]
                    157: +            include_dirs = ['Modules/_decimal/libmpdec']
                    158:              libraries = ['m']
                    159:              sources = [
                    160:                '_decimal/_decimal.c',
1.3       tnn       161: @@ -2745,7 +2779,7 @@ def main():
1.1       adam      162:            # If you change the scripts installed here, you also need to
                    163:            # check the PyBuildScripts command above, and change the links
                    164:            # created by the bininstall target in Makefile.pre.in
                    165: -          scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
                    166: +          scripts = ["Tools/scripts/pydoc3",
                    167:                       "Tools/scripts/2to3"]
                    168:          )
                    169:  

CVSweb <webmaster@jp.NetBSD.org>