Merge pull request #136 from AbdealiJK/ajk/setup

setup.py: Don't fail if pip fails in cmake err msg
This commit is contained in:
Davis E. King 2016-06-11 08:41:36 -04:00 committed by GitHub
commit 474ae9a878
1 changed files with 20 additions and 16 deletions

View File

@ -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"