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

42

43
44
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
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) 

71

72
73
74
75
setup(

    name='fslpy',

76
    version=version['__version__'],
77

Paul McCarthy's avatar
Paul McCarthy committed
78
    description='FSL Python library',
79
80
81
82
83
84
85

    url='https://git.fmrib.ox.ac.uk/paulmc/fslpy',

    author='Paul McCarthy',

    author_email='pauldmccarthy@gmail.com',

Paul McCarthy's avatar
Paul McCarthy committed
86
    license='Apache License Version 2.0',
87
88
89
90

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

96
    packages=packages,
97

98
99
100
    install_requires=install_requires,

    setup_requires=['pytest-runner'],
101
    tests_require=['pytest', 'pytest-cov', 'pytest-runner'],
102
    test_suite='tests',
103

104
105
    cmdclass={'doc' : doc},

106
107
108
109
110
111
    entry_points={
        'console_scripts' : [
            'fslpy_imcp = fsl.scripts.imcp:main',
            'fslpy_immv = fsl.scripts.immv:main'
        ]
    }
112
)