setup.py 2.83 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
40
    for line in f:
        if line.startswith('__version__'):
            exec(line, version)
            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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class doc(Command):
    """Build the API documentation. """
    
    user_options = []
    
    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)

        env   = dict(os.environ)
        ppath = [op.join(pkgutil.get_loader('fsl').filename, '..')]
        
        env['PYTHONPATH'] = op.pathsep.join(ppath)

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

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

74

75
76
77
78
setup(

    name='fslpy',

79
    version=version['__version__'],
80

Paul McCarthy's avatar
Paul McCarthy committed
81
    description='FSL Python library',
Paul McCarthy's avatar
Paul McCarthy committed
82
    long_description=readme,
83

84
    url='https://git.fmrib.ox.ac.uk/fsl/fslpy',
85
86
87
88
89

    author='Paul McCarthy',

    author_email='pauldmccarthy@gmail.com',

Paul McCarthy's avatar
Paul McCarthy committed
90
    license='Apache License Version 2.0',
91
92
93
94

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

100
    packages=packages,
101

102
103
104
    install_requires=install_requires,

    setup_requires=['pytest-runner'],
Paul McCarthy's avatar
Paul McCarthy committed
105
    tests_require=['pytest', 'mock', 'pytest-cov', 'pytest-runner'],
106
    test_suite='tests',
107

108
109
    cmdclass={'doc' : doc},

110
111
112
113
114
115
    entry_points={
        'console_scripts' : [
            'fslpy_imcp = fsl.scripts.imcp:main',
            'fslpy_immv = fsl.scripts.immv:main'
        ]
    }
116
)