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): ...@@ -468,26 +468,30 @@ class build(_build):
message = msg_pkgmanager.format('OSX', manager) message = msg_pkgmanager.format('OSX', manager)
break break
elif sys.platform.startswith('linux'): elif sys.platform.startswith('linux'):
distname = None
try: try:
import distro import distro
except ImportError: except ImportError as err:
import pip import pip
pip_exit = pip.main(['install', 'distro']) pip_exit = pip.main(['install', '-q', 'distro'])
if pip_exit > 0: if pip_exit > 0:
raise SystemExit('Pip was unable to install `distro`') log.debug("Unable to install `distro` to identify "
import distro "the recommended command. Falling back "
distname = distro.id() "to default error message.")
if distname in ('debian', 'ubuntu'): distro = err
message = msg_pkgmanager.format( else:
distname.title(), 'apt-get') import distro
elif distname in ('fedora', 'centos', 'redhat'): if not isinstance(distro, ImportError):
pkgmanagers = ("dnf", "yum") distname = distro.id()
for manager in pkgmanagers: if distname in ('debian', 'ubuntu'):
if find_executable(manager) is not None: message = msg_pkgmanager.format(
message = msg_pkgmanager.format( distname.title(), 'apt-get')
distname.title(), manager) elif distname in ('fedora', 'centos', 'redhat'):
break pkgmanagers = ("dnf", "yum")
for manager in pkgmanagers:
if find_executable(manager) is not None:
message = msg_pkgmanager.format(
distname.title(), manager)
break
raise DistutilsSetupError( raise DistutilsSetupError(
"Cannot find cmake, ensure it is installed and in the path.\n" "Cannot find cmake, ensure it is installed and in the path.\n"
+ message + "\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