From 5f46591efc0bcd2eb71a131669a093ce5c849dd8 Mon Sep 17 00:00:00 2001 From: Sebastiaan Huber Date: Thu, 19 Apr 2018 15:55:52 +0200 Subject: [PATCH] Add a check for the pip version in setup.py The new build procedure employing the pyproject.toml file relies on pip being at least v10.0.0, so we test that this requirement is satisfied in the setup.py or exit with a warning --- setup.py | 18 +++++++++++++++++- utils/validate_pyproject.py | 7 ++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 5094ce67dc..d645cb9ffe 100644 --- a/setup.py +++ b/setup.py @@ -9,11 +9,12 @@ ########################################################################### import fastentrypoints import re +import sys +from distutils.version import StrictVersion from os import path from setuptools import setup, find_packages from setup_requirements import install_requires, extras_require - if __name__ == '__main__': # Get the version number aiida_folder = path.split(path.abspath(__file__))[0] @@ -22,6 +23,21 @@ match_expr = "__version__[^'\"]+(['\"])([^'\"]+)" aiida_version = re.search(match_expr, aiida_init.read()).group(2).strip() + # Ensure that pip is installed and the version is at least 10.0.0, which is required for the build process + try: + import pip + except ImportError: + print 'Could not import pip, which is required for installation' + sys.exit(1) + + PIP_REQUIRED_VERSION = '10.0.0' + required_version = StrictVersion(PIP_REQUIRED_VERSION) + installed_version = StrictVersion(pip.__version__) + + if installed_version < required_version: + print 'The installation requires pip>={}, whereas currently {} is installed'.format(required_version, installed_version) + sys.exit(1) + bin_folder = path.join(aiida_folder, 'bin') setup( name='aiida-core', diff --git a/utils/validate_pyproject.py b/utils/validate_pyproject.py index d30b4cca4c..1026b5ff52 100644 --- a/utils/validate_pyproject.py +++ b/utils/validate_pyproject.py @@ -3,20 +3,21 @@ import click import os import sys +import toml @click.command() def validate_pyproject(): """ Ensure that the version of reentry in setup_requirements.py and pyproject.toml are identical """ - import setup_requirements - import toml - filename_pyproject = 'pyproject.toml' filename_requirements = 'setup_requirements.py' dir_path = os.path.dirname(os.path.realpath(__file__)) toml_file = os.path.join(dir_path, os.pardir, filename_pyproject) + sys.path.append(os.path.join(dir_path, os.pardir)) + + import setup_requirements reentry_requirement = None