setup.py 4.21 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

11
12
13
import os.path       as op
import                  shutil
import unittest.mock as mock
14

Paul McCarthy's avatar
Paul McCarthy committed
15
from setuptools import setup
16
from setuptools import find_namespace_packages
17
from setuptools import Command
18
19
20


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

23
# Dependencies are listed in requirements.txt
24
with open(op.join(basedir, 'requirements.txt'), 'rt') as f:
Paul McCarthy's avatar
Paul McCarthy committed
25
    install_requires = [l.strip() for l in f.readlines()]
26

27
28
# 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
29
    extra_requires = {'extras' : [l.strip() for l in f.readlines()]}
30

31
packages = find_namespace_packages(include=('fsl', 'fsl.*'))
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

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

72
        mockobj       = mock.MagicMock()
Paul McCarthy's avatar
Paul McCarthy committed
73
74
75
76
77
78
        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)]
79

Paul McCarthy's avatar
Paul McCarthy committed
80
        [p.start() for p in patches]
Paul McCarthy's avatar
Paul McCarthy committed
81
        sphinx_build.main([docdir, destdir])
Paul McCarthy's avatar
Paul McCarthy committed
82
        [p.stop() for p in patches]
83
84


85
setup(
86

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

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

107
    packages=packages,
108

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

113
    test_suite='tests',
114

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

    entry_points={
        'console_scripts' : [
119
            'imcp           = fsl.scripts.imcp:main',
Paul McCarthy's avatar
Paul McCarthy committed
120
121
122
            'imln           = fsl.scripts.imln:main',
            'immv           = fsl.scripts.immv:main',
            'imrm           = fsl.scripts.imrm:main',
123
            'imglob         = fsl.scripts.imglob:main',
Paul McCarthy's avatar
Paul McCarthy committed
124
125
126
127
128
            'imtest         = fsl.scripts.imtest:main',
            'remove_ext     = fsl.scripts.remove_ext:main',
            'fsl_abspath    = fsl.scripts.fsl_abspath:main',
            'Text2Vest      = fsl.scripts.Text2Vest:main',
            'Vest2Text      = fsl.scripts.Vest2Text:main',
129
130
131
132
            '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
133
            'fsl_convert_x5 = fsl.scripts.fsl_convert_x5:main',
Paul McCarthy's avatar
Paul McCarthy committed
134
            'fsl_apply_x5   = fsl.scripts.fsl_apply_x5:main'
Paul McCarthy's avatar
Paul McCarthy committed
135
136
        ]
    }
137
)