Completed
Pull Request — master (#27)
by Jerome
49s
created

getBuildnr()   A

Complexity

Conditions 4

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
c 1
b 0
f 0
dl 0
loc 14
rs 9.2
1
#!/usr/bin/env python
2
# -*- encoding: utf-8 -*-
3
from __future__ import absolute_import
4
from __future__ import print_function
5
6
import io
7
import re
8
import subprocess
9
from glob import glob
10
from os.path import basename
11
from os.path import dirname
12
from os.path import join
13
from os.path import splitext
14
from os import environ
15
16
from setuptools import find_packages
17
from setuptools import setup
18
19
20
def read(*names, **kwargs):
21
    return io.open(
22
        join(dirname(__file__), *names),
23
        encoding=kwargs.get('encoding', 'utf8')
24
    ).read()
25
26
# subprocess.check_output(['git', 'rev-list', '--count', 'HEAD']).decode('latin-1').strip()
27
28
def getBuildnr():
29
30
    buildnr = "."
31
    try:
32
        buildnr += subprocess.check_output(['git', 'show', '-s', '--format=%ct', 'HEAD^{commit}']).decode('latin-1').strip()
33
    except Exception:
34
        buildnr = ""
35
    else:
36
        tmp= environ.get("TRAVIS_BUILD_NUMBER", None)
37
        if tmp:
38
            buildnr+=tmp
39
        else:
40
            buildnr = ""
41
    return buildnr
42
43
setup(
44
    name='msquaredc',
45
    version='0.1.1{}'.format(getBuildnr()),
46
    license='BSD',
47
    description='A Tool for more independent data coding.',
48
    long_description='%s\n%s' % (
49
        re.compile('^.. start-badges.*^.. end-badges', re.M | re.S).sub('', read('README.rst')),
50
        re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst'))
51
    ),
52
    author='Jerome Bergmann',
53
    author_email='[email protected]',
54
    url='https://github.com/j340m3/python-msquaredc',
55
    packages=find_packages('src'),
56
    package_dir={'': 'src'},
57
    py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
58
    include_package_data=True,
59
    zip_safe=False,
60
    classifiers=[
61
        # complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
62
        'Development Status :: 1 - Planning',
63
        'Intended Audience :: Developers',
64
        'License :: OSI Approved :: BSD License',
65
        'Operating System :: Unix',
66
        'Operating System :: POSIX',
67
        'Operating System :: Microsoft :: Windows',
68
        'Programming Language :: Python',
69
        'Programming Language :: Python :: 2.7',
70
        'Programming Language :: Python :: 3',
71
        'Programming Language :: Python :: 3.3',
72
        'Programming Language :: Python :: 3.4',
73
        'Programming Language :: Python :: 3.5',
74
        'Programming Language :: Python :: 3.6',
75
        'Programming Language :: Python :: Implementation :: CPython',
76
        'Programming Language :: Python :: Implementation :: PyPy',
77
        # uncomment if you test on these interpreters:
78
        # 'Programming Language :: Python :: Implementation :: IronPython',
79
        # 'Programming Language :: Python :: Implementation :: Jython',
80
        # 'Programming Language :: Python :: Implementation :: Stackless',
81
        'Topic :: Utilities',
82
    ],
83
    keywords=[
84
        # eg: 'keyword1', 'keyword2', 'keyword3',
85
    ],
86
    install_requires=[
87
        'click',
88
        'PyYAML',
89
        'urwid',
90
        'six'
91
    ],
92
    extras_require={
93
        # eg:
94
        #   'rst': ['docutils>=0.11'],
95
        #   ':python_version=="2.6"': ['argparse'],
96
    },
97
    entry_points={
98
        'console_scripts': [
99
            'msquaredc = msquaredc.cli:main',
100
        ]
101
    },
102
)
103