Skip to content

Commit

Permalink
Add a check for the pip version in setup.py
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sphuber committed Apr 19, 2018
1 parent ca75832 commit 5f46591
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
18 changes: 17 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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',
Expand Down
7 changes: 4 additions & 3 deletions utils/validate_pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 5f46591

Please sign in to comment.