Completed
Push — develop ( 8e3cf4...604c57 )
by Jace
01:38
created

check_python_version()   A

Complexity

Conditions 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
1
#!/usr/bin/env python
2
3
"""Setup script for The Coverage Space CLI."""
4
5
import os
6
import sys
7
8
import setuptools
9
10
11
PACKAGE_NAME = 'coveragespace'
12
MINIMUM_PYTHON_VERSION = 2, 7
13
14
15
def check_python_version():
16
    """Exit when the Python version is too low."""
17
    if sys.version_info < MINIMUM_PYTHON_VERSION:
18
        sys.exit("Python {}.{}+ is required.".format(*MINIMUM_PYTHON_VERSION))
19
20
21
def read_package_variable(key):
22
    """Read the value of a variable from the package without importing."""
23
    module_path = os.path.join(PACKAGE_NAME, '__init__.py')
24
    with open(module_path) as module:
25
        for line in module:
26
            parts = line.strip().split(' ')
27
            if parts and parts[0] == key:
28
                return parts[-1].strip("'")
29
    assert 0, "'{0}' not found in '{1}'".format(key, module_path)
30
31
32
def read_descriptions():
33
    """Build a description for the project from documentation files."""
34
    try:
35
        readme = open("README.rst").read()
36
        changelog = open("CHANGELOG.rst").read()
37
    except IOError:
38
        return "<placeholder>"
39
    else:
40
        return readme + '\n' + changelog
41
42
43
check_python_version()
44
setuptools.setup(
45
    name=read_package_variable('__project__'),
46
    version=read_package_variable('__version__'),
47
48
    description="A place to track your code coverage metrics.",
49
    url='https://github.com/jacebrowning/coverage-space-cli',
50
    author='Jace Browning',
51
    author_email='[email protected]',
52
53
    packages=setuptools.find_packages(),
54
55
    entry_points={'console_scripts': [
56
        'coverage.space = coveragespace.cli:main',
57
    ]},
58
59
    long_description=read_descriptions(),
60
    license='MIT',
61
    classifiers=[
62
        'Development Status :: 4 - Beta',
63
        'Environment :: Console',
64
        'Intended Audience :: Developers',
65
        'License :: OSI Approved :: MIT License',
66
        'Natural Language :: English',
67
        'Operating System :: OS Independent',
68
        'Programming Language :: Python',
69
        'Programming Language :: Python :: 2',
70
        'Programming Language :: Python :: 2.7',
71
        'Programming Language :: Python :: 3',
72
        'Programming Language :: Python :: 3.3',
73
        'Programming Language :: Python :: 3.4',
74
        'Programming Language :: Python :: 3.5',
75
        'Topic :: Software Development',
76
        'Topic :: Software Development :: Quality Assurance',
77
        'Topic :: Software Development :: Testing',
78
    ],
79
80
    install_requires=open("requirements.txt").readlines(),
81
    dependency_links=[
82
        'https://github.com/chrippa/backports.shutil_get_terminal_size/tarball/159e269450dbf37c3a837f6ea7e628d59acbb96a#egg=backports.shutil-get-terminal-size'
83
    ]
84
)
85