setup.py 3.61 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
# Dependencies are listed in requirements.txt
23
24
with open(op.join(basedir, 'requirements.txt'), 'rt') as f:
    install_requires = f.readlines()
25

26
# Development/test dependencies are listed in requirements-dev.txt
27
28
29
30
31
32
with open(op.join(basedir, 'requirements-dev.txt'), 'rt') as f:
    dev_requires = f.readlines()

# Optional dependencies are listed in requirements-extra.txt
with open(op.join(basedir, 'requirements-extra.txt'), 'rt') as f:
    extra_requires = {'extras' : f.readlines()}
33

34
35
packages = find_packages(
    exclude=('doc', 'tests', 'dist', 'build', 'fslpy.egg-info'))
36
37
38
39
40
41
42

# 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:
43
44
45
    for line in f:
        if line.startswith('__version__'):
            exec(line, version)
46
            break
47
version = version['__version__']
48

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

52

53
54
class doc(Command):
    """Build the API documentation. """
55

56
    user_options = []
57

58
59
60
61
62
63
64
65
66
67
68
69
70
71
    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)

72
        print('Building documentation [{}]'.format(destdir))
73

74
        import sphinx
75

76
77
78
79
        try:
            import unittest.mock as mock
        except:
            import mock
80

81
        mockobj       = mock.MagicMock()
Paul McCarthy's avatar
Paul McCarthy committed
82
83
84
85
86
87
        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)]
88

Paul McCarthy's avatar
Paul McCarthy committed
89
90
91
        [p.start() for p in patches]
        sphinx.main(['sphinx-build', docdir, destdir])
        [p.stop() for p in patches]
92
93


94
setup(
95

96
97
    name='fslpy',
    version=version,
Paul McCarthy's avatar
Paul McCarthy committed
98
    description='FSL Python library',
Paul McCarthy's avatar
Paul McCarthy committed
99
    long_description=readme,
100
    url='https://git.fmrib.ox.ac.uk/fsl/fslpy',
101
102
    author='Paul McCarthy',
    author_email='pauldmccarthy@gmail.com',
Paul McCarthy's avatar
Paul McCarthy committed
103
    license='Apache License Version 2.0',
104
105
106
107

    classifiers=[
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
Paul McCarthy's avatar
Paul McCarthy committed
108
        'License :: OSI Approved :: Apache Software License',
109
        'Programming Language :: Python :: 2.7',
110
        'Programming Language :: Python :: 3.4',
111
        'Programming Language :: Python :: 3.5',
112
        'Programming Language :: Python :: 3.6',
113
114
        'Topic :: Software Development :: Libraries :: Python Modules'],

115
    packages=packages,
116

117
    install_requires=install_requires,
118
    extras_require=extra_requires,
119
120
    setup_requires=dev_requires,

121
    test_suite='tests',
122

123
    cmdclass={'doc' : doc},
Paul McCarthy's avatar
Paul McCarthy committed
124
125
126

    entry_points={
        'console_scripts' : [
127
128
129
130
            '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
131
132
        ]
    }
133
)