Build fails in python-ensurepip on Linux

Hi!

I am trying to build the nightly version of Slicer on Arch Linux (5.7.2-arch1-1) in debug mode using the developers instructions.

During the install step for ‘python-ensurepip’ I get the following error:

[ 59%] Performing install step for 'python-ensurepip'
-- Looking for 26 include files stdio.h, ..., krb.h - not found
-- Looking for 26 include files stdio.h, ..., libgen.h
-- Looking for 26 include files stdio.h, ..., libgen.h - found
-- Looking for 27 include files stdio.h, ..., libssh2.h
-- Looking for 27 include files stdio.h, ..., libssh2.h - found
-- Looking for 28 include files stdio.h, ..., limits.h
-- Looking for 28 include files stdio.h, ..., limits.h - found
-- Looking for 29 include files stdio.h, ..., locale.h
-- Looking for 29 include files stdio.h, ..., locale.h - found
-- Looking for 30 include files stdio.h, ..., net/if.h
-- Looking for 30 include files stdio.h, ..., net/if.h - found
-- Looking for 31 include files stdio.h, ..., netdb.h
-- Looking for 31 include files stdio.h, ..., netdb.h - found
-- Looking for 32 include files stdio.h, ..., netinet/in.h
-- Looking for 32 include files stdio.h, ..., netinet/in.h - found
-- Looking for 33 include files stdio.h, ..., netinet/tcp.h
-- Looking for 33 include files stdio.h, ..., netinet/tcp.h - found
-- Looking for 34 include files stdio.h, ..., openssl/crypto.h
-- Looking for 34 include files stdio.h, ..., openssl/crypto.h - found
-- Looking for 35 include files stdio.h, ..., openssl/engine.h
-- Looking for 35 include files stdio.h, ..., openssl/engine.h - found
-- Looking for 36 include files stdio.h, ..., openssl/err.h
-- Looking for 36 include files stdio.h, ..., openssl/err.h - found
-- Looking for 37 include files stdio.h, ..., openssl/pem.h
CMake Error at /home/rutger/Desktop/Studie/graduation/slicer/Slicer-SuperBuild-Debug/python-ensurepip-prefix/src/python-ensurepip-stamp/python-ensurepip-install-Debug.cmake:16 (message):
  Command failed: 2

   '/home/rutger/Desktop/Studie/graduation/slicer/Slicer-SuperBuild-Debug/python-install/bin/PythonSlicer' '-m' 'ensurepip' '--default-pip'

  See also

    /home/rutger/Desktop/Studie/graduation/slicer/Slicer-SuperBuild-Debug/python-ensurepip-prefix/src/python-ensurepip-stamp/python-ensurepip-install-*.log


make[2]: *** [CMakeFiles/python-ensurepip.dir/build.make:75: python-ensurepip-prefix/src/python-ensurepip-stamp/python-ensurepip-install] Error 1
make[2]: Leaving directory '/home/rutger/Documents/Studie/tu-eindhoven/Master/year-2019-2020/graduation/slicer/Slicer-SuperBuild-Debug'
make[1]: *** [CMakeFiles/Makefile2:682: CMakeFiles/python-ensurepip.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

The output log is empty. The error log contains the following:

Exception:
Traceback (most recent call last):
  File "/tmp/tmpsiaxhdyv/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/basecommand.py", line 228, in main
    status = self.run(options, args)
  File "/tmp/tmpsiaxhdyv/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/commands/install.py", line 241, in run
    with self._build_session(options) as session:
  File "/tmp/tmpsiaxhdyv/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/basecommand.py", line 81, in _build_session
    insecure_hosts=options.trusted_hosts,
  File "/tmp/tmpsiaxhdyv/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/download.py", line 338, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/tmp/tmpsiaxhdyv/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/download.py", line 101, in user_agent
    zip(["name", "version", "id"], distro.linux_distribution()),
  File "/tmp/tmpsiaxhdyv/pip-10.0.1-py2.py3-none-any.whl/pip/_vendor/distro.py", line 120, in linux_distribution
    return _distro.linux_distribution(full_distribution_name)
  File "/tmp/tmpsiaxhdyv/pip-10.0.1-py2.py3-none-any.whl/pip/_vendor/distro.py", line 634, in linux_distribution
    self.version(),
  File "/tmp/tmpsiaxhdyv/pip-10.0.1-py2.py3-none-any.whl/pip/_vendor/distro.py", line 688, in version
    self.lsb_release_attr('release'),
  File "/tmp/tmpsiaxhdyv/pip-10.0.1-py2.py3-none-any.whl/pip/_vendor/distro.py", line 836, in lsb_release_attr
    return self._lsb_release_info.get(attribute, '')
  File "/tmp/tmpsiaxhdyv/pip-10.0.1-py2.py3-none-any.whl/pip/_vendor/distro.py", line 522, in __get__
    ret = obj.__dict__[self._fname] = self._f(obj)
  File "/tmp/tmpsiaxhdyv/pip-10.0.1-py2.py3-none-any.whl/pip/_vendor/distro.py", line 933, in _lsb_release_info
    stdout = subprocess.check_output(cmd, stderr=devnull)
  File "/home/rutger/Desktop/Studie/graduation/slicer/Slicer-SuperBuild-Debug/python-install/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/home/rutger/Desktop/Studie/graduation/slicer/Slicer-SuperBuild-Debug/python-install/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.

I could not find any related issues on GitHub nor any topics here on Discourse. Would anyone be so kind to point me in the right direction as to what I am doing wrong? I assume it has something to do with my Python version (3.8), but I did not see any specific requirements in the developers build instructions regarding Python versions.

Thanks in advance!

It should not matter what Python distributions you have installed on your system. Do you see something that would indicate that your system Python interferes with the build process?

Was the release-mode build successful?

Hi Andras,

Honestly I don’t see any indicators why my system python would interfere with the build process.
Calling lsb_release -a directly on the command-line worked fine so I am not sure what is going wrong.

In the end I decided to temporarily remove /usr/bin/lsb_release, which circumvented the error. I based this on https://github.com/pypa/pip/issues/4924. Not sure why this worked exactly, I’m not that familiar with Python.

Thanks again and keep up the good work.

Older distributions have an implementation of lsb_release in python that do not specify flag -Es in the shebang. Without these flags, the script was lsb_release incorrectly using the Slicer python environment instead of the one on the system.

This is why in Slicer build system we work around the issue generating a launcher emulating the role of -Es.

If you are curious, you could look at https://bugs.launchpad.net/ubuntu/+source/lsb/+bug/938869/comments/28 and what is done in the Slicer build system:

1 Like