setup.py 3.37 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
# Dependencies are listed in requirements.txt
install_requires = open(op.join(basedir, 'requirements.txt'), 'rt').readlines()

25
26
27
# Development/test dependencies are listed in requirements-dev.txt
dev_requires = open(op.join(basedir, 'requirements-dev.txt'), 'rt').readlines()

28
29
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

43
with open(op.join(basedir, 'README.rst'), 'rt') as f:
Paul McCarthy's avatar
Paul McCarthy committed
44
45
    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
        mockobj       = mock.MagicMock()
Paul McCarthy's avatar
Paul McCarthy committed
76
77
78
79
80
81
        mockobj.__version__ = '2.2.0'
        mockedModules = open(op.join(docdir, 'mock_modules.txt')).readlines()
        mockedModules = [l.strip()   for l in mockedModules]
        mockedModules = {m : mockobj for m in mockedModules}

        patches = [mock.patch.dict('sys.modules', **mockedModules)]
82

Paul McCarthy's avatar
Paul McCarthy committed
83
84
85
        [p.start() for p in patches]
        sphinx.main(['sphinx-build', docdir, destdir])
        [p.stop() for p in patches]
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.4',
105
        'Programming Language :: Python :: 3.5',
106
        'Programming Language :: Python :: 3.6',
107
108
        'Topic :: Software Development :: Libraries :: Python Modules'],

109
    packages=packages,
110

111
    install_requires=install_requires,
112
113
    setup_requires=dev_requires,

114
    test_suite='tests',
115

116
    cmdclass={'doc' : doc},
Paul McCarthy's avatar
Paul McCarthy committed
117
118
119

    entry_points={
        'console_scripts' : [
120
121
122
123
            'immv   = fsl.scripts.immv:main',
            'imcp   = fsl.scripts.imcp:main',
            'imglob = fsl.scripts.imglob:main',
            'atlasq = fsl.scripts.atlasq:main',
Paul McCarthy's avatar
Paul McCarthy committed
124
125
        ]
    }
126
)