Annotation of pkgsrc/lang/python39/patches/patch-setup.py, revision 1.7

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

CVSweb <webmaster@jp.NetBSD.org>