setup.py 3.09 KB
Newer Older
1
2
3
4
5
6
7
#!/usr/bin/env python
#
# setup.py - setuptools configuration for installing the fslpy package.
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#

8
9
10

from __future__ import print_function

Paul McCarthy's avatar
Paul McCarthy committed
11
12
import os.path as op
import            shutil
13

Paul McCarthy's avatar
Paul McCarthy committed
14
15
from setuptools import setup
from setuptools import find_packages
16
from setuptools import Command
17
18
19


# The directory in which this setup.py file is contained.
20
21
basedir = op.dirname(__file__)

22
23
24
25
26
# Dependencies are listed in requirements.txt
install_requires = open(op.join(basedir, 'requirements.txt'), 'rt').readlines()

packages = find_packages(
    exclude=('doc', 'tests', 'dist', 'build', 'fslpy.egg-info'))
27
28
29
30
31
32
33

# Figure out the current fslpy version, as defined in fsl/version.py. We
# don't want to import the fsl package,  as this may cause build problems.
# So we manually parse the contents of fsl/version.py to extract the
# version number.
version = {}
with open(op.join(basedir, "fsl", "version.py")) as f:
34
35
36
    for line in f:
        if line.startswith('__version__'):
            exec(line, version)
37
            break
38
version = version['__version__']
39

40
with open(op.join(basedir, 'README.rst'), 'rt') as f:
Paul McCarthy's avatar
Paul McCarthy committed
41
42
    readme = f.read()

43

44
45
class doc(Command):
    """Build the API documentation. """
46

47
    user_options = []
48

49
50
51
52
53
54
55
56
57
58
59
60
61
62
    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def run(self):

        docdir  = op.join(basedir, 'doc')
        destdir = op.join(docdir, 'html')

        if op.exists(destdir):
            shutil.rmtree(destdir)

63
        print('Building documentation [{}]'.format(destdir))
64

65
        import sphinx
66

67
68
69
70
        try:
            import unittest.mock as mock
        except:
            import mock
71

72
73
74
75
76
        mockedModules = [
            'nibabel',
            'nibabel.fileslice',
            'numpy',
            'numpy.linalg']
77

78
79
        mockobj       = mock.MagicMock()
        mockedModules = { m : mockobj for m in mockedModules}
80

81
82
        with mock.patch.dict('sys.modules', **mockedModules):
            sphinx.main(['sphinx-build', docdir, destdir])
83
84


85
setup(
86

87
88
    name='fslpy',
    version=version,
Paul McCarthy's avatar
Paul McCarthy committed
89
    description='FSL Python library',
Paul McCarthy's avatar
Paul McCarthy committed
90
    long_description=readme,
91
    url='https://git.fmrib.ox.ac.uk/fsl/fslpy',
92
93
    author='Paul McCarthy',
    author_email='pauldmccarthy@gmail.com',
Paul McCarthy's avatar
Paul McCarthy committed
94
    license='Apache License Version 2.0',
95
96
97
98

    classifiers=[
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
Paul McCarthy's avatar
Paul McCarthy committed
99
        'License :: OSI Approved :: Apache Software License',
100
        'Programming Language :: Python :: 2.7',
101
        'Programming Language :: Python :: 3.4',
102
        'Programming Language :: Python :: 3.5',
103
        'Programming Language :: Python :: 3.6',
104
105
        'Topic :: Software Development :: Libraries :: Python Modules'],

106
    packages=packages,
107
    install_requires=install_requires,
108
    setup_requires=['pytest-runner', 'sphinx', 'sphinx-rtd-theme', 'mock'],
109

Paul McCarthy's avatar
Paul McCarthy committed
110
    tests_require=['mock',
Paul McCarthy's avatar
Paul McCarthy committed
111
                   'coverage',
112
113
                   'pytest-cov',
                   'pytest-html',
Paul McCarthy's avatar
Paul McCarthy committed
114
115
                   'pytest-runner',
                   'pytest'],
116
    test_suite='tests',
117

118
    cmdclass={'doc' : doc},
119
)