Skip to content

Commit 38487a0

Browse files
authored
[2.7] bpo-32521: nis libnsl (GH-5190) (#5353)
The nismodule is now compatible with new libnsl and headers location Signed-off-by: Christian Heimes <[email protected]>. (cherry picked from commit 29a7df7)
1 parent f5e8f71 commit 38487a0

File tree

2 files changed

+49
-18
lines changed

2 files changed

+49
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The nis module is now compatible with new libnsl and headers location.

setup.py

+48-18
Original file line numberDiff line numberDiff line change
@@ -1346,26 +1346,11 @@ class db_found(Exception): pass
13461346
else:
13471347
missing.append('resource')
13481348

1349-
# Sun yellow pages. Some systems have the functions in libc.
1350-
if (host_platform not in ['cygwin', 'atheos', 'qnx6'] and
1351-
find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None):
1352-
nis_libs = []
1353-
nis_includes = []
1354-
if self.compiler.find_library_file(lib_dirs, 'nsl'):
1355-
nis_libs.append('nsl')
1356-
if self.compiler.find_library_file(lib_dirs, 'tirpc'):
1357-
# Sun RPC has been moved from glibc to libtirpc
1358-
# rpcsvc/yp_prot.h is still in /usr/include, but
1359-
# rpc/rpc.h has been moved into tirpc/ subdir.
1360-
nis_libs.append('tirpc')
1361-
nis_includes.append('/usr/include/tirpc')
1362-
exts.append( Extension('nis', ['nismodule.c'],
1363-
libraries = nis_libs,
1364-
include_dirs=nis_includes) )
1349+
nis = self._detect_nis(inc_dirs, lib_dirs)
1350+
if nis is not None:
1351+
exts.append(nis)
13651352
else:
13661353
missing.append('nis')
1367-
else:
1368-
missing.extend(['nis', 'resource', 'termios'])
13691354

13701355
# Curses support, requiring the System V version of curses, often
13711356
# provided by the ncurses library.
@@ -2164,6 +2149,51 @@ def detect_ctypes(self, inc_dirs, lib_dirs):
21642149
ext.libraries.append(ffi_lib)
21652150
self.use_system_libffi = True
21662151

2152+
def _detect_nis(self, inc_dirs, lib_dirs):
2153+
if host_platform in {'win32', 'cygwin', 'qnx6'}:
2154+
return None
2155+
2156+
libs = []
2157+
library_dirs = []
2158+
includes_dirs = []
2159+
2160+
# bpo-32521: glibc has deprecated Sun RPC for some time. Fedora 28
2161+
# moved headers and libraries to libtirpc and libnsl. The headers
2162+
# are in tircp and nsl sub directories.
2163+
rpcsvc_inc = find_file(
2164+
'rpcsvc/yp_prot.h', inc_dirs,
2165+
[os.path.join(inc_dir, 'nsl') for inc_dir in inc_dirs]
2166+
)
2167+
rpc_inc = find_file(
2168+
'rpc/rpc.h', inc_dirs,
2169+
[os.path.join(inc_dir, 'tirpc') for inc_dir in inc_dirs]
2170+
)
2171+
if rpcsvc_inc is None or rpc_inc is None:
2172+
# not found
2173+
return None
2174+
includes_dirs.extend(rpcsvc_inc)
2175+
includes_dirs.extend(rpc_inc)
2176+
2177+
if self.compiler.find_library_file(lib_dirs, 'nsl'):
2178+
libs.append('nsl')
2179+
else:
2180+
# libnsl-devel: check for libnsl in nsl/ subdirectory
2181+
nsl_dirs = [os.path.join(lib_dir, 'nsl') for lib_dir in lib_dirs]
2182+
libnsl = self.compiler.find_library_file(nsl_dirs, 'nsl')
2183+
if libnsl is not None:
2184+
library_dirs.append(os.path.dirname(libnsl))
2185+
libs.append('nsl')
2186+
2187+
if self.compiler.find_library_file(lib_dirs, 'tirpc'):
2188+
libs.append('tirpc')
2189+
2190+
return Extension(
2191+
'nis', ['nismodule.c'],
2192+
libraries=libs,
2193+
library_dirs=library_dirs,
2194+
include_dirs=includes_dirs
2195+
)
2196+
21672197

21682198
class PyBuildInstall(install):
21692199
# Suppress the warning about installation into the lib_dynload

0 commit comments

Comments
 (0)