forked from briancheung/C-PAC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·133 lines (109 loc) · 4.48 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env python
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
'''
Configurable Pipeline for the Analysis of Connectomes (C-PAC)
'''
# Package Information
DISTNAME = 'CPAC'
DESCRIPTION = 'Configurable Pipeline for the Analysis of Connectomes'
LONG_DESCRIPTION = ''
MAINTAINER = ''
MAINTAINER_EMAIL = ''
URL = 'http://fcp-indi.github.io/'
LICENSE = 'BSD License'
DOWNLOAD_URL = 'https://github.com/FCP-INDI/C-PAC/tarball/master'
# Import packages
import os, sys
# Import build helpers
try:
from nisext.sexts import package_check, get_comrec_build
except ImportError:
raise RuntimeError('Need nisext package from nibabel installation'
' - please install nibabel first')
from build_helpers import INFO_VARS
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration, \
get_numpy_include_dirs
config = Configuration(None, parent_package, top_path)
config.set_options(ignore_setup_xxx_py=True,
assume_default_configuration=True,
delegate_options_to_subpackages=True,
quiet=True)
config.get_version('CPAC/__init__.py')
config.add_subpackage('CPAC')
# cython
config.add_extension('CPAC.network_centrality.thresh_and_sum',
sources=['CPAC/network_centrality/thresh_and_sum.pyx'],
include_dirs=[get_numpy_include_dirs()])
return config
################################################################################
# For some commands, use setuptools package
if len(set(('develop', 'bdist_egg', 'bdist_rpm', 'bdist', 'bdist_dumb',
'bdist_wininst', 'install_egg_info', 'egg_info', 'easy_install',
)).intersection(sys.argv)) > 0:
try:
from setup_egg import extra_setuptools_args
except ImportError:
pass
# extra_setuptools_args can be defined from the line above, but it can
# also be defined here because setup.py has been exec'ed from
# setup_egg.py.
if not 'extra_setuptools_args' in globals():
extra_setuptools_args = dict()
# Hard and soft dependency checking
#package_check('matplotlib', INFO_VARS['MATPLOTLIB_MIN_VERSION'])
#package_check('jinja2', INFO_VARS['JINJA_MIN_VERSION'])
#package_check('lockfile', INFO_VARS['PYLOCKFILE_MIN_VERSION']) # checking doesn't really work
#package_check('yaml', INFO_VARS['PYYAML_MIN_VERSION'])
################################################################################
def main(**extra_args):
from numpy.distutils.core import setup
from glob import glob
# monkey-patch numpy distutils to use Cython instead of Pyrex
from numpy.distutils.command.build_ext import build_ext
from numpy.distutils.command.build_src import build_src
from build_helpers import generate_a_pyrex_source
build_src.generate_a_pyrex_source = generate_a_pyrex_source
cmdclass = {
'build_src': build_src,
'build_ext': build_ext
}
setup(name=INFO_VARS['NAME'],
maintainer=INFO_VARS['MAINTAINER'],
maintainer_email=INFO_VARS['MAINTAINER_EMAIL'],
description=INFO_VARS['DESCRIPTION'],
long_description=INFO_VARS['LONG_DESCRIPTION'],
url=INFO_VARS['URL'],
download_url=INFO_VARS['DOWNLOAD_URL'],
license=INFO_VARS['LICENSE'],
classifiers=INFO_VARS['CLASSIFIERS'],
author=INFO_VARS['AUTHOR'],
author_email=INFO_VARS['AUTHOR_EMAIL'],
platforms=INFO_VARS['PLATFORMS'],
version=INFO_VARS['VERSION'],
requires = INFO_VARS['REQUIRES'],
install_requires = INFO_VARS['INSTALL_REQUIRES'],
configuration = configuration,
cmdclass = cmdclass,
scripts = glob('scripts/*'),
entry_points={
'console_scripts': [
'cpac_extract_parameters=CPAC.utils.extract_parameters:main'
]
},
package_data = {'CPAC': ['test_data/*']},
#script_args = ['build_ext', '--inplace'],
**extra_args)
# Run main by default
if __name__ == "__main__":
# Import packages
import site, shutil
from shutil import rmtree, copytree
# Get in the right directory
old_path = os.getcwd()
local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
os.chdir(local_path)
sys.path.insert(0, local_path)
# Run main function
main(**extra_setuptools_args)