From 99e828d15db7dae71e2822825574a28c60777be1 Mon Sep 17 00:00:00 2001 From: "Tim D. Smith" Date: Tue, 28 Jun 2016 21:48:06 -0700 Subject: [PATCH 1/2] Avoid importing pip pip doesn't have a stable Python API and shouldn't be `import`ed. `pkg_resources` is provided by setuptools. --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index ed3cbf2..860ed32 100755 --- a/setup.py +++ b/setup.py @@ -1,10 +1,10 @@ #!/usr/bin/env python from setuptools import setup, find_packages -import pip +import pkg_resources import sys import os -if int(pip.__version__.split('.')[0]) < 6: +if int(pkg_resources.get_distribution("pip").version.split('.')[0]) < 6: print('pip older than 6.0 not supported, please upgrade pip with:\n\n' ' pip install -U pip') sys.exit(-1) From a7d1c725e490e3aca553bda8c619c9c5b3177cc2 Mon Sep 17 00:00:00 2001 From: "Tim D. Smith" Date: Tue, 28 Jun 2016 21:50:06 -0700 Subject: [PATCH 2/2] Keep working if pip isn't installed This might be installed by invoking setup.py directly. --- setup.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 860ed32..7920744 100755 --- a/setup.py +++ b/setup.py @@ -4,10 +4,13 @@ import pkg_resources import sys import os -if int(pkg_resources.get_distribution("pip").version.split('.')[0]) < 6: - print('pip older than 6.0 not supported, please upgrade pip with:\n\n' - ' pip install -U pip') - sys.exit(-1) +try: + if int(pkg_resources.get_distribution("pip").version.split('.')[0]) < 6: + print('pip older than 6.0 not supported, please upgrade pip with:\n\n' + ' pip install -U pip') + sys.exit(-1) +except pkg_resources.DistributionNotFound: + pass if os.environ.get('CONVERT_README'): import pypandoc