setup   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 140
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 97
dl 0
loc 140
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A optional_build_ext.run() 0 7 2
A optional_build_ext._unavailable() 0 13 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A read() 0 6 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 os
8
import re
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 relpath
14
from os.path import splitext
15
16
from setuptools import Extension
17
from setuptools import find_packages
18
from setuptools import setup
19
from setuptools.command.build_ext import build_ext
20
21
22
def read(*names, **kwargs):
23
    with io.open(
24
        join(dirname(__file__), *names),
25
        encoding=kwargs.get('encoding', 'utf8')
26
    ) as fh:
27
        return fh.read()
28
29
30
# Enable code coverage for C code: we can't use CFLAGS=-coverage in tox.ini,
31
# since that may mess with compiling dependencies (e.g. numpy). Therefore we
32
# set SETUPPY_CFLAGS=-coverage in tox.ini and copy it to CFLAGS here (after
33
# deps have been safely installed).
34
if 'TOXENV' in os.environ and 'SETUPPY_CFLAGS' in os.environ:
35
    os.environ['CFLAGS'] = os.environ['SETUPPY_CFLAGS']
36
37
38
class optional_build_ext(build_ext):
39
    """Allow the building of C extensions to fail."""
40
    def run(self):
41
        try:
42
            build_ext.run(self)
43
        except Exception as e:
44
            self._unavailable(e)
45
            # avoid copying missing files (it would fail).
46
            self.extensions = []
47
48
    def _unavailable(self, e):
49
        print('*' * 80)
50
        print('''WARNING:
51
52
    An optional code optimization (C extension) could not be compiled.
53
54
    Optimizations for this package will not be available!
55
        ''')
56
57
        print('CAUSE:')
58
        print('')
59
        print('    ' + repr(e))
60
        print('*' * 80)
61
62
63
description = 'AIscalate your Jupyter Notebook Prototypes ' \
64
              'into Airflow Data Products'
65
66
setup(
67
    name='aiscalator',
68
    version='0.1.18',
69
    license='Apache Software License 2.0',
70
    description=description,
71
    long_description='%s\n%s' % (
72
        re.compile('^.. start-badges.*^.. end-badges',
73
                   re.M | re.S).sub('', read('README.rst')),
74
        re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('HISTORY.rst'))
75
    ),
76
    author='Christophe Duong',
77
    author_email='[email protected]',
78
    url='https://github.com/Aiscalate/aiscalator',
79
    packages=find_packages('src'),
80
    package_dir={'': 'src'},
81
    py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
82
    include_package_data=True,
83
    zip_safe=False,
84
    classifiers=[
85
        # complete classifier list:
86
        # http://pypi.python.org/pypi?%3Aaction=list_classifiers
87
        'Development Status :: 3 - Alpha',
88
        'Intended Audience :: Developers',
89
        'Intended Audience :: Science/Research',
90
        'Intended Audience :: System Administrators',
91
        'License :: OSI Approved :: Apache Software License',
92
        'Natural Language :: English',
93
        'Operating System :: Unix',
94
        'Operating System :: POSIX',
95
        # 'Operating System :: Microsoft :: Windows',
96
        'Programming Language :: Python',
97
        'Programming Language :: Python :: 3',
98
        'Programming Language :: Python :: 3.4',
99
        'Programming Language :: Python :: 3.5',
100
        'Programming Language :: Python :: 3.6',
101
        'Programming Language :: Python :: 3.7',
102
        # 'Programming Language :: Python :: Implementation :: CPython',
103
        'Programming Language :: Python :: Implementation :: PyPy',
104
        'Topic :: Utilities',
105
        'Topic :: Scientific/Engineering :: Artificial Intelligence',
106
        'Topic :: Software Development :: Libraries :: Application Frameworks',
107
    ],
108
    keywords=[
109
        # eg: 'keyword1', 'keyword2', 'keyword3',
110
        'data science', 'jupyter', 'jupyter notebook', 'prototype',
111
        'papermill', 'jupytext',
112
        'data engineering', 'product', 'airflow',
113
    ],
114
    install_requires=[
115
        # eg: 'aspectlib==1.1.1', 'six>=1.7',
116
        'Click>=6.0',
117
        'jupytext>=1.5.2',
118
        'pyhocon>=0.3.48',
119
        'pytz>=2018.5',
120
    ],
121
    extras_require={
122
        # eg:
123
        #   'rst': ['docutils>=0.11'],
124
        #   ':python_version=="2.6"': ['argparse'],
125
    },
126
    entry_points={
127
        'console_scripts': [
128
            'aiscalator = aiscalator.cli:main',
129
        ]
130
    },
131
    cmdclass={'build_ext': optional_build_ext},
132
    ext_modules=[
133
        Extension(
134
            splitext(relpath(path, 'src').replace(os.sep, '.'))[0],
135
            sources=[path],
136
            include_dirs=[dirname(path)]
137
        )
138
        for root, _, _ in os.walk('src')
139
        for path in glob(join(root, '*.c'))
140
    ],
141
)
142