Commit 8da4053c authored by AbdealiJK's avatar AbdealiJK

setup.py: Don't fail if pip fails in cmake err msg

When cmake is not found, the error message suggests what to do to
install cmake. But if `distro` is not found and cannot be installed,
the distro specific error message cannot be shown. Hence, we simply
ignore this and continue on.

Also, make the pip install quiet so that if there is an error message
in that, the user does not get confused by it.
parent 6938af9d
......@@ -468,26 +468,30 @@ class build(_build):
message = msg_pkgmanager.format('OSX', manager)
break
elif sys.platform.startswith('linux'):
distname = None
try:
import distro
except ImportError:
except ImportError as err:
import pip
pip_exit = pip.main(['install', 'distro'])
pip_exit = pip.main(['install', '-q', 'distro'])
if pip_exit > 0:
raise SystemExit('Pip was unable to install `distro`')
import distro
distname = distro.id()
if distname in ('debian', 'ubuntu'):
message = msg_pkgmanager.format(
distname.title(), 'apt-get')
elif distname in ('fedora', 'centos', 'redhat'):
pkgmanagers = ("dnf", "yum")
for manager in pkgmanagers:
if find_executable(manager) is not None:
message = msg_pkgmanager.format(
distname.title(), manager)
break
log.debug("Unable to install `distro` to identify "
"the recommended command. Falling back "
"to default error message.")
distro = err
else:
import distro
if not isinstance(distro, ImportError):
distname = distro.id()
if distname in ('debian', 'ubuntu'):
message = msg_pkgmanager.format(
distname.title(), 'apt-get')
elif distname in ('fedora', 'centos', 'redhat'):
pkgmanagers = ("dnf", "yum")
for manager in pkgmanagers:
if find_executable(manager) is not None:
message = msg_pkgmanager.format(
distname.title(), manager)
break
raise DistutilsSetupError(
"Cannot find cmake, ensure it is installed and in the path.\n"
+ message + "\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment