setup.py 3.78 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
packages = find_packages(include=('fsl', 'fsl.*'))
31
32
33
34
35
36
37

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

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

47

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

51
    user_options = []
52

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

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

Paul McCarthy's avatar
Paul McCarthy committed
69
        import sphinx.cmd.build as sphinx_build
70

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

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

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


89
setup(
90

91
92
    name='fslpy',
    version=version,
Paul McCarthy's avatar
Paul McCarthy committed
93
    description='FSL Python library',
Paul McCarthy's avatar
Paul McCarthy committed
94
    long_description=readme,
95
    long_description_content_type='text/x-rst',
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 :: 3.7',
Paul McCarthy's avatar
Paul McCarthy committed
106
        'Programming Language :: Python :: 3.8',
107
108
        'Topic :: Software Development :: Libraries :: Python Modules'],

109
    packages=packages,
110

111
    install_requires=install_requires,
112
    extras_require=extra_requires,
113
    package_data={'fsl': ['utils/filetree/trees/*']},
114

115
    test_suite='tests',
116

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

    entry_points={
        'console_scripts' : [
121
122
123
124
125
126
127
            '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',
            'fsl_ents       = fsl.scripts.fsl_ents:main',
            'resample_image = fsl.scripts.resample_image:main',
Paul McCarthy's avatar
Paul McCarthy committed
128
            'fsl_convert_x5 = fsl.scripts.fsl_convert_x5:main',
Paul McCarthy's avatar
Paul McCarthy committed
129
            'fsl_apply_x5   = fsl.scripts.fsl_apply_x5:main'
Paul McCarthy's avatar
Paul McCarthy committed
130
131
        ]
    }
132
)