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

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

CVSweb <webmaster@jp.NetBSD.org>