@@ -1361,27 +1361,14 @@ class db_found(Exception): pass
13611361 exts .append ( Extension ('termios' , ['termios.c' ]) )
13621362 # Jeremy Hylton's rlimit interface
13631363 exts .append ( Extension ('resource' , ['resource.c' ]) )
1364+ else :
1365+ missing .extend (['resource' , 'termios' ])
13641366
1365- # Sun yellow pages. Some systems have the functions in libc.
1366- if (host_platform not in ['cygwin' , 'qnx6' ] and
1367- find_file ('rpcsvc/yp_prot.h' , inc_dirs , []) is not None ):
1368- nis_libs = []
1369- nis_includes = []
1370- if self .compiler .find_library_file (lib_dirs , 'nsl' ):
1371- nis_libs .append ('nsl' )
1372- if self .compiler .find_library_file (lib_dirs , 'tirpc' ):
1373- # Sun RPC has been moved from glibc to libtirpc
1374- # rpcsvc/yp_prot.h is still in /usr/include, but
1375- # rpc/rpc.h has been moved into tirpc/ subdir.
1376- nis_libs .append ('tirpc' )
1377- nis_includes .append ('/usr/include/tirpc' )
1378- exts .append ( Extension ('nis' , ['nismodule.c' ],
1379- libraries = nis_libs ,
1380- include_dirs = nis_includes ) )
1381- else :
1382- missing .append ('nis' )
1367+ nis = self ._detect_nis (inc_dirs , lib_dirs )
1368+ if nis is not None :
1369+ exts .append (nis )
13831370 else :
1384- missing .extend ([ 'nis' , 'resource' , 'termios' ] )
1371+ missing .append ( 'nis' )
13851372
13861373 # Curses support, requiring the System V version of curses, often
13871374 # provided by the ncurses library.
@@ -2225,6 +2212,52 @@ def _decimal_ext(self):
22252212 )
22262213 return ext
22272214
2215+ def _detect_nis (self , inc_dirs , lib_dirs ):
2216+ if host_platform in {'win32' , 'cygwin' , 'qnx6' }:
2217+ return None
2218+
2219+ libs = []
2220+ library_dirs = []
2221+ includes_dirs = []
2222+
2223+ # bpo-32521: glibc has deprecated Sun RPC for some time. Fedora 28
2224+ # moved headers and libraries to libtirpc and libnsl. The headers
2225+ # are in tircp and nsl sub directories.
2226+ rpcsvc_inc = find_file (
2227+ 'rpcsvc/yp_prot.h' , inc_dirs ,
2228+ [os .path .join (inc_dir , 'nsl' ) for inc_dir in inc_dirs ]
2229+ )
2230+ rpc_inc = find_file (
2231+ 'rpc/rpc.h' , inc_dirs ,
2232+ [os .path .join (inc_dir , 'tirpc' ) for inc_dir in inc_dirs ]
2233+ )
2234+ if rpcsvc_inc is None or rpc_inc is None :
2235+ # not found
2236+ return None
2237+ includes_dirs .extend (rpcsvc_inc )
2238+ includes_dirs .extend (rpc_inc )
2239+
2240+ if self .compiler .find_library_file (lib_dirs , 'nsl' ):
2241+ libs .append ('nsl' )
2242+ else :
2243+ # libnsl-devel: check for libnsl in nsl/ subdirectory
2244+ nsl_dirs = [os .path .join (lib_dir , 'nsl' ) for lib_dir in lib_dirs ]
2245+ libnsl = self .compiler .find_library_file (nsl_dirs , 'nsl' )
2246+ if libnsl is not None :
2247+ library_dirs .append (os .path .dirname (libnsl ))
2248+ libs .append ('nsl' )
2249+
2250+ if self .compiler .find_library_file (lib_dirs , 'tirpc' ):
2251+ libs .append ('tirpc' )
2252+
2253+ return Extension (
2254+ 'nis' , ['nismodule.c' ],
2255+ libraries = libs ,
2256+ library_dirs = library_dirs ,
2257+ include_dirs = includes_dirs
2258+ )
2259+
2260+
22282261class PyBuildInstall (install ):
22292262 # Suppress the warning about installation into the lib_dynload
22302263 # directory, which is not in sys.path when running Python during
0 commit comments