BuildPyCommand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 6
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 4 1
1
#!/usr/bin/env python3
2
3
# Start ignoring PyImportSortBear as imports below may yield syntax errors
4
from coalib import assert_supported_version, VERSION, get_version, BUS_NAME
5
6
assert_supported_version()
7
# Stop ignoring
8
9
import datetime
10
import locale
11
import sys
12
from os import getenv
13
from subprocess import call
14
15
import setuptools.command.build_py
16
from coalib.misc.BuildManPage import BuildManPage
17
from coalib.output.dbus.BuildDbusService import BuildDbusService
18
from setuptools import find_packages, setup
19
from setuptools.command.test import test as TestCommand
20
21
try:
22
    locale.getlocale()
23
except (ValueError, UnicodeError):
24
    locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
25
26
27
class BuildPyCommand(setuptools.command.build_py.build_py):
28
29
    def run(self):
30
        self.run_command('build_manpage')
31
        self.run_command('build_dbus')
32
        setuptools.command.build_py.build_py.run(self)
33
34
35
class PyTestCommand(TestCommand):
36
37
    def run_tests(self):
38
        # import here, cause outside the eggs aren't loaded
39
        import pytest
40
        errno = pytest.main([])
41
        sys.exit(errno)
42
43
44
class BuildDocsCommand(setuptools.command.build_py.build_py):
45
    apidoc_command = ('sphinx-apidoc', '-f', '-o', 'docs/API/',
46
                      'coalib')
47
    doc_command = ('make', '-C', 'docs', 'html')
48
49
    def run(self):
50
        call(self.apidoc_command)
51
        call(self.doc_command)
52
53
54
# Generate API documentation only if we are running on readthedocs.org
55
on_rtd = getenv('READTHEDOCS', None) != None
56
if on_rtd:
57
    call(BuildDocsCommand.apidoc_command)
58
    if "dev" in VERSION:
59
        current_version = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
60
        call(['python3', '.misc/adjust_version_number.py', 'coalib/VERSION',
61
              '-b {}'.format(current_version)])
62
        VERSION = get_version()
63
64
with open('requirements.txt') as requirements:
65
    required = requirements.read().splitlines()
66
67
with open('test-requirements.txt') as requirements:
68
    test_required = requirements.read().splitlines()
69
70
with open("README.rst") as readme:
71
    long_description = readme.read()
72
73
74
if __name__ == "__main__":
75
    data_files = [('.', ['coala.1']), ('.', [BUS_NAME + '.service'])]
76
77
    setup(name='coala',
78
          version=VERSION,
79
          description='Code Analysis Application (coala)',
80
          author="The coala developers",
81
          author_email="[email protected]",
82
          maintainer="Lasse Schuirmann, Fabian Neuschmidt, Mischa Kr\xfcger"
83
                     if not on_rtd else "L.S., F.N., M.K.",
84
          maintainer_email=('[email protected], '
85
                            '[email protected], '
86
                            '[email protected]'),
87
          url='http://coala-analyzer.org/',
88
          platforms='any',
89
          packages=find_packages(exclude=["build.*", "tests", "tests.*"]),
90
          install_requires=required,
91
          tests_require=test_required,
92
          package_data={'coalib': ['default_coafile', "VERSION",
93
                                   'bearlib/languages/definitions/*.coalang',
94
                                   'bearlib/languages/documentation/*.coalang']
95
                        },
96
          license="AGPL-3.0",
97
          data_files=data_files,
98
          long_description=long_description,
99
          entry_points={
100
              "console_scripts": [
101
                  "coala = coalib.coala:main",
102
                  "coala-ci = coalib.coala_ci:main",
103
                  "coala-dbus = coalib.coala_dbus:main",
104
                  "coala-json = coalib.coala_json:main",
105
                  "coala-format = coalib.coala_format:main",
106
                  "coala-delete-orig = coalib.coala_delete_orig:main"]},
107
          # from http://pypi.python.org/pypi?%3Aaction=list_classifiers
108
          classifiers=[
109
              'Development Status :: 4 - Beta',
110
111
              'Environment :: Console',
112
              'Environment :: MacOS X',
113
              'Environment :: Win32 (MS Windows)',
114
              'Environment :: X11 Applications :: Gnome',
115
116
              'Intended Audience :: Science/Research',
117
              'Intended Audience :: Developers',
118
119
              'License :: OSI Approved :: GNU Affero General Public License '
120
              'v3 or later (AGPLv3+)',
121
122
              'Operating System :: OS Independent',
123
124
              'Programming Language :: Python :: Implementation :: CPython',
125
              'Programming Language :: Python :: 3.4',
126
              'Programming Language :: Python :: 3.5',
127
              'Programming Language :: Python :: 3 :: Only',
128
129
              'Topic :: Scientific/Engineering :: Information Analysis',
130
              'Topic :: Software Development :: Quality Assurance',
131
              'Topic :: Text Processing :: Linguistic'],
132
          cmdclass={'build_manpage': BuildManPage,
133
                    'build_dbus': BuildDbusService,
134
                    'build_py': BuildPyCommand,
135
                    'docs': BuildDocsCommand,
136
                    'test': PyTestCommand})
137