setup.py 3.04 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
11
12
13
14
15

from __future__ import print_function

import               os
import os.path    as op
import subprocess as sp
import               shutil
import               pkgutil
16

Paul McCarthy's avatar
Paul McCarthy committed
17
18
from setuptools import setup
from setuptools import find_packages
19
from setuptools import Command
20
21
22


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

25
26
27
28
29
# 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'))
30
31
32
33
34
35
36

# 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:
37
38
39
    for line in f:
        if line.startswith('__version__'):
            exec(line, version)
40
            break
41
version = version['__version__']
42

Paul McCarthy's avatar
Paul McCarthy committed
43
44
45
with open(op.join(basedir, 'README.md'), 'rt') as f:
    readme = f.read()

46

47
48
class doc(Command):
    """Build the API documentation. """
49

50
    user_options = []
51

52
53
54
55
56
57
58
59
60
61
62
63
64
65
    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)

66
        print('Building documentation [{}]'.format(destdir))
67

68
        import sphinx
69

70
71
72
73
        try:
            import unittest.mock as mock
        except:
            import mock
74

75
76
77
78
79
        mockedModules = [
            'nibabel',
            'nibabel.fileslice',
            'numpy',
            'numpy.linalg']
80

81
82
        mockobj       = mock.MagicMock()
        mockedModules = { m : mockobj for m in mockedModules}
83

84
85
        with mock.patch.dict('sys.modules', **mockedModules):
            sphinx.main(['sphinx-build', docdir, destdir])
86
87


88
setup(
89

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

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

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

Paul McCarthy's avatar
Paul McCarthy committed
111
    tests_require=['mock',
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
)