setup.py 3.01 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
11
12
13
14
15

from __future__ import print_function

import               os
import os.path    as op
import subprocess as sp
import               shutil
import               pkgutil
16

Paul McCarthy's avatar
Paul McCarthy committed
17
18
from setuptools import setup
from setuptools import find_packages
19
from setuptools import Command
20
21
22


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

25
26
27
28
29
# Dependencies are listed in requirements.txt
install_requires = open(op.join(basedir, 'requirements.txt'), 'rt').readlines()

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

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

45

46
47
class doc(Command):
    """Build the API documentation. """
48

49
    user_options = []
50

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

65
66
67
68
69
        env     = dict(os.environ)
        dirname = pkgutil.get_loader('fsl').get_filename()
        dirname = op.dirname(dirname)
        dirname = op.abspath(op.join(dirname, '..'))
        ppath   = [dirname]
70

71
72
73
74
        env['PYTHONPATH'] = op.pathsep.join(ppath)

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

75
        sp.call(['sphinx-build', docdir, destdir], env=env)
76

77

78
79
80
81
setup(

    name='fslpy',

82
    version=version['__version__'],
83

Paul McCarthy's avatar
Paul McCarthy committed
84
    description='FSL Python library',
Paul McCarthy's avatar
Paul McCarthy committed
85
    long_description=readme,
86

87
    url='https://git.fmrib.ox.ac.uk/fsl/fslpy',
88
89
90
91
92

    author='Paul McCarthy',

    author_email='pauldmccarthy@gmail.com',

Paul McCarthy's avatar
Paul McCarthy committed
93
    license='Apache License Version 2.0',
94
95
96
97

    classifiers=[
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
Paul McCarthy's avatar
Paul McCarthy committed
98
        'License :: OSI Approved :: Apache Software License',
99
        'Programming Language :: Python :: 2.7',
100
        'Programming Language :: Python :: 3.6',
101
102
        'Topic :: Software Development :: Libraries :: Python Modules'],

103
    packages=packages,
104

105
106
107
    install_requires=install_requires,

    setup_requires=['pytest-runner'],
Paul McCarthy's avatar
Paul McCarthy committed
108
    tests_require=['mock',
109
110
                   'pytest-cov',
                   'pytest-html',
Paul McCarthy's avatar
Paul McCarthy committed
111
112
                   'pytest-runner',
                   'pytest'],
113
    test_suite='tests',
114

115
116
    cmdclass={'doc' : doc},

117
118
119
120
121
122
    entry_points={
        'console_scripts' : [
            'fslpy_imcp = fsl.scripts.imcp:main',
            'fslpy_immv = fsl.scripts.immv:main'
        ]
    }
123
)