Annotation of pkgsrc/lang/python311/patches/patch-setup.py, revision 1.2

1.2     ! wiz         1: $NetBSD: patch-setup.py,v 1.1 2022/10/31 09:50:40 adam 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.
                      7: Don't search for modules in PREFIX. Fixes build failure when py-setuptools
                      8:   are installed.
                      9: Enable cross-build by setting sys._home and sys.path to build directory
                     10: Module _crypt might need -lcrypt (taken from Python 3.10).
                     11: 
                     12: --- setup.py.orig      2022-10-24 17:35:39.000000000 +0000
                     13: +++ setup.py
                     14: @@ -1,5 +1,11 @@
                     15:  # Autodetecting setup.py script for building the Python extensions
                     16:  
                     17: +import sys
                     18: +sys._home = __file__[:-len('/setup.py')]
                     19: +sys.path.append(__file__[:-len('/setup.py')] + '/Lib')
                     20: +with open('pybuilddir.txt') as pybuilddir:
                     21: +    sys.path.append(__file__[:-len('/setup.py')] + '/' + next(pybuilddir))
                     22: +
                     23:  import argparse
                     24:  import importlib._bootstrap
                     25:  import importlib.machinery
                     26: @@ -14,6 +20,7 @@ import warnings
                     27:  from glob import glob, escape
                     28:  import _osx_support
                     29:  
                     30: +sys.path = [p for p in sys.path if not re.compile('^' + sys.base_prefix + '/lib').match(p)]
                     31:  
                     32:  try:
                     33:      import subprocess
                     34: @@ -46,6 +53,7 @@ with warnings.catch_warnings():
                     35:          DeprecationWarning
                     36:      )
                     37:  
                     38: +    from distutils import text_file
                     39:      from distutils.command.build_ext import build_ext
                     40:      from distutils.command.build_scripts import build_scripts
                     41:      from distutils.command.install import install
                     42: @@ -56,7 +64,7 @@ with warnings.catch_warnings():
                     43:  
                     44:  
                     45:  # This global variable is used to hold the list of modules to be disabled.
                     46: -DISABLED_MODULE_LIST = []
1.2     ! wiz        47: +DISABLED_MODULE_LIST = ["_gdbm", "_tkinter", "xxlimited"]
1.1       adam       48:  
                     49:  # --list-module-names option used by Tools/scripts/generate_module_names.py
                     50:  LIST_MODULE_NAMES = False
                     51: @@ -230,6 +238,16 @@ def grep_headers_for(function, headers):
                     52:      return False
                     53:  
                     54:  
                     55: +def grep_headers_for(function, headers):
                     56: +    for header in headers:
                     57: +        try:
                     58: +            with open(header, 'r') as f:
                     59: +                if function in f.read():
                     60: +                    return True
                     61: +        except UnicodeDecodeError:
                     62: +            pass
                     63: +    return False
                     64: +
                     65:  def find_file(filename, std_dirs, paths):
                     66:      """Searches for the directory where a given file is located,
                     67:      and returns a possibly-empty list of additional directories, or None
                     68: @@ -843,15 +861,15 @@ class PyBuildExt(build_ext):
                     69:                          add_dir_to_list(dir_list, directory)
                     70:  
                     71:      def configure_compiler(self):
                     72: -        # Ensure that /usr/local is always used, but the local build
                     73: -        # directories (i.e. '.' and 'Include') must be first.  See issue
                     74: -        # 10520.
                     75: -        if not CROSS_COMPILING:
                     76: -            add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
                     77: -            add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
                     78: -        # only change this for cross builds for 3.3, issues on Mageia
                     79: -        if CROSS_COMPILING:
                     80: -            self.add_cross_compiling_paths()
                     81: +        # Add the buildlink directories for pkgsrc
                     82: +        if os.environ.get('BUILDLINK_DIR'):
                     83: +            dir = os.environ['BUILDLINK_DIR']
                     84: +            libdir = dir + '/lib'
                     85: +            incdir = dir + '/include'
                     86: +            if libdir not in self.compiler.library_dirs:
                     87: +                self.compiler.library_dirs.insert(0, libdir)
                     88: +            if incdir not in self.compiler.include_dirs:
                     89: +                self.compiler.include_dirs.insert(0, incdir)
                     90:          self.add_multiarch_paths()
                     91:          self.add_ldflags_cppflags()
                     92:  
                     93: @@ -899,6 +917,9 @@ class PyBuildExt(build_ext):
                     94:              self.lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32']
                     95:  
                     96:          if MACOS:
                     97: +            self.inc_dirs.append(macosx_sdk_root() + '/usr/include')
                     98: +            self.lib_dirs.append(macosx_sdk_root() + '/usr/lib')
                     99: +
                    100:              # This should work on any unixy platform ;-)
                    101:              # If the user has bothered specifying additional -I and -L flags
                    102:              # in OPT and LDFLAGS we might as well use them here.
                    103: @@ -1074,8 +1095,6 @@ class PyBuildExt(build_ext):
                    104:          # use the same library for the readline and curses modules.
                    105:          if 'curses' in readline_termcap_library:
                    106:              curses_library = readline_termcap_library
                    107: -        elif self.compiler.find_library_file(self.lib_dirs, 'ncursesw'):
                    108: -            curses_library = 'ncursesw'
                    109:          # Issue 36210: OSS provided ncurses does not link on AIX
                    110:          # Use IBM supplied 'curses' for successful build of _curses
                    111:          elif AIX and self.compiler.find_library_file(self.lib_dirs, 'curses'):
                    112: @@ -1166,8 +1185,7 @@ class PyBuildExt(build_ext):
                    113:          # If the curses module is enabled, check for the panel module
                    114:          # _curses_panel needs some form of ncurses
                    115:          skip_curses_panel = True if AIX else False
                    116: -        if (curses_enabled and not skip_curses_panel and
                    117: -                self.compiler.find_library_file(self.lib_dirs, panel_library)):
                    118: +        if curses_enabled and not skip_curses_panel:
                    119:              self.add(Extension('_curses_panel', ['_curses_panel.c'],
                    120:                             include_dirs=curses_includes,
                    121:                             define_macros=curses_defines,
                    122: @@ -1176,7 +1194,11 @@ class PyBuildExt(build_ext):
                    123:              self.missing.append('_curses_panel')
                    124:  
                    125:      def detect_crypt(self):
                    126: -        self.addext(Extension('_crypt', ['_cryptmodule.c']))
                    127: +        if self.compiler.find_library_file(self.lib_dirs, 'crypt'):
                    128: +            libs = ['crypt']
                    129: +        else:
                    130: +            libs = []
                    131: +        self.addext(Extension('_crypt', ['_cryptmodule.c'], libraries=libs))
                    132:  
                    133:      def detect_dbm_gdbm(self):
                    134:          # Modules that provide persistent dictionary-like semantics.  You will
                    135: @@ -1199,6 +1221,31 @@ class PyBuildExt(build_ext):
                    136:  
                    137:          # The standard Unix dbm module:
                    138:          if not CYGWIN:
                    139: +            # Top half based on find_file
                    140: +            def find_ndbm_h(dirs):
                    141: +                ret = None
                    142: +                if MACOS:
                    143: +                    sysroot = macosx_sdk_root()
                    144: +                for dir in dirs:
                    145: +                    f = os.path.join(dir, 'ndbm.h')
                    146: +                    if MACOS and is_macosx_sdk_path(dir):
                    147: +                        f = os.path.join(sysroot, dir[1:], 'ndbm.h')
                    148: +                    if not os.path.exists(f):
                    149: +                        continue
                    150: +
                    151: +                    ret = True
                    152: +                    input = text_file.TextFile(f)
                    153: +                    while True:
                    154: +                        line = input.readline()
                    155: +                        if not line:
                    156: +                            break
                    157: +                        if re.search('This file is part of GDBM', line):
                    158: +                            ret = None
                    159: +                            break
                    160: +                    input.close()
                    161: +                    break
                    162: +                return ret
                    163: +
                    164:              config_args = [arg.strip("'")
                    165:                             for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
                    166:              dbm_args = [arg for arg in config_args
                    167: @@ -1616,7 +1663,7 @@ def main():
                    168:            # If you change the scripts installed here, you also need to
                    169:            # check the PyBuildScripts command above, and change the links
                    170:            # created by the bininstall target in Makefile.pre.in
                    171: -          scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
                    172: +          scripts = ["Tools/scripts/pydoc3",
                    173:                       "Tools/scripts/2to3"]
                    174:          )
                    175:  

CVSweb <webmaster@jp.NetBSD.org>