setup.build_description()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
#!/usr/bin/env python
2
3
import os
4
import sys
5
6
import setuptools
7
8
9
PACKAGE_NAME = 'yorm'
10
MINIMUM_PYTHON_VERSION = '3.3'
11
12
13
def check_python_version():
14
    """Exit when the Python version is too low."""
15
    if sys.version < MINIMUM_PYTHON_VERSION:
16
        sys.exit("Python {0}+ is required.".format(MINIMUM_PYTHON_VERSION))
17
18
19
def read_package_variable(key, filename='__init__.py'):
20
    """Read the value of a variable from the package without importing."""
21
    module_path = os.path.join(PACKAGE_NAME, filename)
22
    with open(module_path) as module:
23
        for line in module:
24
            parts = line.strip().split(' ', 2)
25
            if parts[:-1] == [key, '=']:
26
                return parts[-1].strip("'")
27
    sys.exit("'%s' not found in '%s'", key, module_path)
28
29
30
def build_description():
31
    """Build a description for the project from documentation files."""
32
    try:
33
        readme = open("README.rst").read()
34
        changelog = open("CHANGELOG.rst").read()
35
    except IOError:
36
        return "<placeholder>"
37
    else:
38
        return readme + '\n' + changelog
39
40
41
check_python_version()
42
43
setuptools.setup(
44
    name=read_package_variable('__project__'),
45
    version=read_package_variable('__version__'),
46
47
    description="Automatic object-YAML mapping for Python.",
48
    url='https://github.com/jacebrowning/yorm',
49
    author='Jace Browning',
50
    author_email='[email protected]',
51
52
    packages=setuptools.find_packages(),
53
54
    entry_points={'console_scripts': []},
55
56
    long_description=build_description(),
57
    license='MIT',
58
    classifiers=[
59
        'Development Status :: 5 - Production/Stable',
60
        'Intended Audience :: Developers',
61
        'License :: OSI Approved :: MIT License',
62
        'Natural Language :: English',
63
        'Operating System :: OS Independent',
64
        'Programming Language :: Python',
65
        'Programming Language :: Python :: 3',
66
        'Programming Language :: Python :: 3.5',
67
        'Programming Language :: Python :: 3.6',
68
        'Programming Language :: Python :: 3.7',
69
        'Topic :: Database',
70
        'Topic :: Software Development :: Libraries',
71
        'Topic :: Software Development :: Version Control',
72
        'Topic :: System :: Filesystems',
73
        'Topic :: Text Editors :: Text Processing',
74
    ],
75
76
    install_requires=[
77
        'PyYAML >= 3.13, < 4',
78
        'simplejson ~= 3.8',
79
        'parse ~= 1.8.0',
80
    ],
81
)
82