setup.py 3.6 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
with open(op.join(basedir, 'requirements.txt'), 'rt') as f:
Paul McCarthy's avatar
Paul McCarthy committed
24
    install_requires = [l.strip() for l in f.readlines()]
25

26
27
# Optional dependencies are listed in requirements-extra.txt
with open(op.join(basedir, 'requirements-extra.txt'), 'rt') as f:
Paul McCarthy's avatar
Paul McCarthy committed
28
    extra_requires = {'extras' : [l.strip() for l in f.readlines()]}
29

30
31
packages = find_packages(
    exclude=('doc', 'tests', 'dist', 'build', 'fslpy.egg-info'))
32
33
34
35
36
37
38

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

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

48

49
50
class doc(Command):
    """Build the API documentation. """
51

52
    user_options = []
53

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

68
        print('Building documentation [{}]'.format(destdir))
69

70
        import sphinx
71

72
73
74
75
        try:
            import unittest.mock as mock
        except:
            import mock
76

77
        mockobj       = mock.MagicMock()
Paul McCarthy's avatar
Paul McCarthy committed
78
79
80
81
82
83
        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)]
84

Paul McCarthy's avatar
Paul McCarthy committed
85
86
87
        [p.start() for p in patches]
        sphinx.main(['sphinx-build', docdir, destdir])
        [p.stop() for p in patches]
88
89


90
setup(
91

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

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

111
    packages=packages,
112

113
    install_requires=install_requires,
114
    extras_require=extra_requires,
115

116
    test_suite='tests',
117

118
    cmdclass={'doc' : doc},
Paul McCarthy's avatar
Paul McCarthy committed
119
120
121

    entry_points={
        'console_scripts' : [
122
123
124
125
126
            'immv          = fsl.scripts.immv:main',
            'imcp          = fsl.scripts.imcp:main',
            'imglob        = fsl.scripts.imglob:main',
            'atlasq        = fsl.scripts.atlasq:main',
            'atlasquery    = fsl.scripts.atlasq:atlasquery_emulation',
127
            'fsl_ents = fsl.scripts.fsl_ents:main',
Paul McCarthy's avatar
Paul McCarthy committed
128
129
        ]
    }
130
)