The necessary bits not found while compiling Python3.10

Dear All:

I am trying to install Python 3.10.4 on my virtual machine Rocky Linux 8.6.
But I have an issue that I don’t know how to solve it.
After compiling python, I saw message below:

Python build finished successfully!
The necessary bits to build these optional modules were not found:
nis
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

I’d tried to check from the file “setup.py” and found below:

   def detect_nis(self):
        if MS_WINDOWS or CYGWIN or HOST_PLATFORM == 'qnx6':
            self.missing.append('nis')
            return

        libs = []
        library_dirs = []
        includes_dirs = []

        # bpo-32521: glibc has deprecated Sun RPC for some time. Fedora 28
        # moved headers and libraries to libtirpc and libnsl. The headers
        # are in tircp and nsl sub directories.
        rpcsvc_inc = find_file(
            'rpcsvc/yp_prot.h', self.inc_dirs,
            [os.path.join(inc_dir, 'nsl') for inc_dir in self.inc_dirs]
        )
        rpc_inc = find_file(
            'rpc/rpc.h', self.inc_dirs,
            [os.path.join(inc_dir, 'tirpc') for inc_dir in self.inc_dirs]
        )
        if rpcsvc_inc is None or rpc_inc is None:
            # not found
            self.missing.append('nis')
            return
        includes_dirs.extend(rpcsvc_inc)
        includes_dirs.extend(rpc_inc)

        if self.compiler.find_library_file(self.lib_dirs, 'nsl'):
            libs.append('nsl')
        else:
            # libnsl-devel: check for libnsl in nsl/ subdirectory
            nsl_dirs = [os.path.join(lib_dir, 'nsl') for lib_dir in self.lib_dirs]
            libnsl = self.compiler.find_library_file(nsl_dirs, 'nsl')
            if libnsl is not None:
                library_dirs.append(os.path.dirname(libnsl))
                libs.append('nsl')

        if self.compiler.find_library_file(self.lib_dirs, 'tirpc'):
            libs.append('tirpc')

        self.add(Extension('nis', ['nismodule.c'],
                           libraries=libs,
                           library_dirs=library_dirs,
                           include_dirs=includes_dirs))

According to the codes above and my limited linux knowledge, I guess that I should miss these 2 tools:
“libnsl” and “libtirpc”.
However, after trying to install them via dnf:

sudo dnf install libnsl
sudo dnf install libtirpc

it told me both packages have been installed already.
So, I am stuck here now.
Can someone kindly give me any hint to solve this problem?

Thank you.

Dear All:

After googling, I seemed to find out the solution.
Checking from the file “setup.py”, it seems to find the file “rpcsvc/yp_prot.h”.
Then I googled “yp_prot.h”, it turned out only “libnsl2-devel” included this file.
I’d tried the command “sudo dnf install libnsl2-devel” but it could not find the file.
So I googled again and fount out its rpm file is on the link: “https://download.rockylinux.org/pub/rocky/8/PowerTools/x86_64/kickstart/Packages/l/
Then I downloaded the file and used the command “rpm -ivh” to install “libnsl2-devel” on my Rockylinux.
Finally, I could compile Python3.10.4 without any issue and installed on my Rocky linux.

I expect powertools repo wasn’t enabled, else you could have done:

dnf config-manager --set-enabled powertools
dnf install libnsl2-devel

For example:

[root@rocky ~]# dnf search libnsl2-devel
Last metadata expiration check: 1 day, 19:41:00 ago on Wed 25 May 2022 16:33:19 CEST.
========================================== Name Exactly Matched: libnsl2-devel ==========================================
libnsl2-devel.i686 : Development files for libnsl
libnsl2-devel.x86_64 : Development files for libnsl

[root@rocky ~]# dnf info libnsl2-devel
Last metadata expiration check: 1 day, 19:41:07 ago on Wed 25 May 2022 16:33:19 CEST.
Available Packages
Name         : libnsl2-devel
Version      : 1.2.0
Release      : 2.20180605git4a062cf.el8
Architecture : i686
Size         : 34 k
Source       : libnsl2-1.2.0-2.20180605git4a062cf.el8.src.rpm
Repository   : powertools
Summary      : Development files for libnsl
URL          : https://github.com/thkukuk/libnsl
License      : BSD and LGPLv2+
Description  : Development files for libnsl2

Name         : libnsl2-devel
Version      : 1.2.0
Release      : 2.20180605git4a062cf.el8
Architecture : x86_64
Size         : 34 k
Source       : libnsl2-1.2.0-2.20180605git4a062cf.el8.src.rpm
Repository   : powertools
Summary      : Development files for libnsl
URL          : https://github.com/thkukuk/libnsl
License      : BSD and LGPLv2+
Description  : Development files for libnsl2

and install:

[root@rocky ~]# dnf install libnsl2-devel
Last metadata expiration check: 1 day, 19:41:51 ago on Wed 25 May 2022 16:33:19 CEST.
Dependencies resolved.
=========================================================================================================================
 Package                    Architecture       Version                                      Repository              Size
=========================================================================================================================
Installing:
 libnsl2-devel              x86_64             1.2.0-2.20180605git4a062cf.el8               powertools              34 k
Installing dependencies:
 libtirpc-devel             x86_64             1.1.4-6.el8                                  baseos                 126 k

Transaction Summary
=========================================================================================================================
Install  2 Packages

Total download size: 160 k
Installed size: 357 k
Is this ok [y/N]: 
2 Likes

Hi iwalker:

Indeed, [powertool] repository was not enabled on my Rockylinux.
Thanks for your sharing!!!

1 Like