Completed
Push — master ( 46d065...9e80fb )
by
unknown
01:39
created

BuildPyCommand   A

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
#!/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
          maintainer="Lasse Schuirmann, Fabian Neuschmidt, Mischa Kr\xfcger"
82
                      if not on_rtd else "L.S., F.N., M.K.",
83
          maintainer_email=('[email protected], '
84
                            '[email protected], '
85
                            '[email protected]'),
86
          url='http://coala-analyzer.org/',
87
          platforms='any',
88
          packages=find_packages(exclude=["build.*", "tests", "tests.*"]),
89
          install_requires=required,
90
          tests_require=test_required,
91
          package_data={'coalib': ['default_coafile', "VERSION",
92
                                   'bearlib/languages/definitions/*.coalang',
93
                                   'bearlib/languages/documentation/*.coalang']
94
                        },
95
          license="AGPL-3.0",
96
          data_files=data_files,
97
          long_description=long_description,
98
          entry_points={
99
              "console_scripts": [
100
                  "coala = coalib.coala:main",
101
                  "coala-ci = coalib.coala_ci:main",
102
                  "coala-dbus = coalib.coala_dbus:main",
103
                  "coala-json = coalib.coala_json:main",
104
                  "coala-format = coalib.coala_format:main",
105
                  "coala-delete-orig = coalib.coala_delete_orig:main"]},
106
          # from http://pypi.python.org/pypi?%3Aaction=list_classifiers
107
          classifiers=[
108
              'Development Status :: 4 - Beta',
109
110
              'Environment :: Console',
111
              'Environment :: MacOS X',
112
              'Environment :: Win32 (MS Windows)',
113
              'Environment :: X11 Applications :: Gnome',
114
115
              'Intended Audience :: Science/Research',
116
              'Intended Audience :: Developers',
117
118
              'License :: OSI Approved :: GNU Affero General Public License '
119
              'v3 or later (AGPLv3+)',
120
121
              'Operating System :: OS Independent',
122
123
              'Programming Language :: Python :: Implementation :: CPython',
124
              'Programming Language :: Python :: 3.4',
125
              'Programming Language :: Python :: 3.5',
126
              'Programming Language :: Python :: 3 :: Only',
127
128
              'Topic :: Scientific/Engineering :: Information Analysis',
129
              'Topic :: Software Development :: Quality Assurance',
130
              'Topic :: Text Processing :: Linguistic'],
131
          cmdclass={'build_manpage': BuildManPage,
132
                    'build_dbus': BuildDbusService,
133
                    'build_py': BuildPyCommand,
134
                    'docs': BuildDocsCommand,
135
                    'test': PyTestCommand})
136