setup.py 4.14 KB
Newer Older
Stephan Seitz's avatar
Stephan Seitz committed
1
2
import distutils
import io
3
4
import os
import sys
Martin Bauer's avatar
Martin Bauer committed
5
6
7
from contextlib import redirect_stdout
from importlib import import_module

Stephan Seitz's avatar
Stephan Seitz committed
8
9
from setuptools import find_packages, setup

Martin Bauer's avatar
Martin Bauer committed
10
11
12
13
14
15
if '--use-cython' in sys.argv:
    USE_CYTHON = True
    sys.argv.remove('--use-cython')
else:
    USE_CYTHON = False

Martin Bauer's avatar
Martin Bauer committed
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
quick_tests = [
    'test_datahandling.test_kernel',
    'test_blocking_staggered.test_blocking_staggered',
    'test_blocking_staggered.test_blocking_staggered',
    'test_vectorization.test_vectorization_variable_size',
]


class SimpleTestRunner(distutils.cmd.Command):
    """A custom command to run selected tests"""

    description = 'run some quick tests'
    user_options = []

    @staticmethod
    def _run_tests_in_module(test):
        """Short test runner function - to work also if py.test is not installed."""
        test = 'pystencils_tests.' + test
        mod, function_name = test.rsplit('.', 1)
        if isinstance(mod, str):
            mod = import_module(mod)

        func = getattr(mod, function_name)
        print("   -> %s in %s" % (function_name, mod.__name__))
        with redirect_stdout(io.StringIO()):
            func()

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def run(self):
        """Run command."""
        for test in quick_tests:
            self._run_tests_in_module(test)
53

Stephan Seitz's avatar
Stephan Seitz committed
54

55
56
57
58
def readme():
    with open('README.md') as f:
        return f.read()

59

Martin Bauer's avatar
Martin Bauer committed
60
def cython_extensions(*extensions):
61
    from distutils.extension import Extension
Martin Bauer's avatar
Martin Bauer committed
62
63
64
65
66
67
68
69
    ext = '.pyx' if USE_CYTHON else '.c'
    result = [Extension(e, [e.replace('.', '/') + ext]) for e in extensions]
    if USE_CYTHON:
        from Cython.Build import cythonize
        result = cythonize(result, language_level=3)
    return result


Martin Bauer's avatar
Martin Bauer committed
70
71
72
try:
    sys.path.insert(0, os.path.abspath('doc'))
    from version_from_git import version_number_from_git
Stephan Seitz's avatar
Stephan Seitz committed
73
74

    version = version_number_from_git()
Martin Bauer's avatar
Martin Bauer committed
75
76
77
78
79
    with open("RELEASE-VERSION", "w") as f:
        f.write(version)
except ImportError:
    version = open('RELEASE-VERSION', 'r').read()

80
setup(name='pystencils',
81
      description='Speeding up stencil computations on CPUs and GPUs',
Martin Bauer's avatar
Martin Bauer committed
82
      version=version,
83
84
      long_description=readme(),
      long_description_content_type="text/markdown",
85
86
87
      author='Martin Bauer',
      license='AGPLv3',
      author_email='martin.bauer@fau.de',
88
      url='https://i10git.cs.fau.de/pycodegen/pystencils/',
89
90
      packages=['pystencils'] + ['pystencils.' + s for s in find_packages('pystencils')],
      install_requires=['sympy>=1.1', 'numpy', 'appdirs', 'joblib'],
91
92
93
94
      package_data={'pystencils': ['include/*.h',
                                   'backends/cuda_known_functions.txt',
                                   'backends/opencl1.1_known_functions.txt']},

Stephan Seitz's avatar
Stephan Seitz committed
95
      ext_modules=cython_extensions("pystencils.boundaries.createindexlistcython"),
96
97
98
99
100
101
102
103
104
      classifiers=[
          'Development Status :: 4 - Beta',
          'Framework :: Jupyter',
          'Topic :: Software Development :: Code Generators',
          'Topic :: Scientific/Engineering :: Physics',
          'Intended Audience :: Developers',
          'Intended Audience :: Science/Research',
          'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
      ],
105
106
107
108
109
      project_urls={
          "Bug Tracker": "https://i10git.cs.fau.de/pycodegen/pystencils/issues",
          "Documentation": "http://pycodegen.pages.walberla.net/pystencils/",
          "Source Code": "https://i10git.cs.fau.de/pycodegen/pystencils",
      },
110
111
      extras_require={
          'gpu': ['pycuda'],
112
          'opencl': ['pyopencl'],
113
114
115
          'alltrafos': ['islpy', 'py-cpuinfo'],
          'bench_db': ['blitzdb', 'pymongo', 'pandas'],
          'interactive': ['matplotlib', 'ipy_table', 'imageio', 'jupyter', 'pyevtk'],
Stephan Seitz's avatar
Stephan Seitz committed
116
          'autodiff': ['pystencils-autodiff'],
117
118
119
          'doc': ['sphinx', 'sphinx_rtd_theme', 'nbsphinx',
                  'sphinxcontrib-bibtex', 'sphinx_autodoc_typehints', 'pandoc'],
      },
Martin Bauer's avatar
Martin Bauer committed
120
      tests_require=['pytest', 'pytest-cov', 'pytest-xdist', 'flake8', 'nbformat', 'nbconvert', 'ipython'],
121
      python_requires=">=3.6",
Martin Bauer's avatar
Martin Bauer committed
122
123
      cmdclass={
          'quicktest': SimpleTestRunner
Martin Bauer's avatar
Martin Bauer committed
124
      },
125
      )