-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.py
172 lines (145 loc) · 4.64 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
from __future__ import print_function
__author__ = "John Kirkham <kirkhamj@janelia.hhmi.org>"
__date__ = "$Mar 30, 2015 23:17:09 EDT$"
from glob import glob
import os
import shutil
import sys
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
from setuptools.dist import Distribution
from distutils.version import LooseVersion
import versioneer
class NoseTestCommand(TestCommand):
description = "Run unit tests using nosetests"
user_options = []
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
import nose
nose.run_exit(argv=["nosetests"])
build_requires = []
install_requires = []
tests_require = ["nose"]
sphinx_build_pdf = False
if len(sys.argv) == 1:
pass
elif ("--help" in sys.argv) or ("-h" in sys.argv):
pass
elif sys.argv[1] == "bdist_conda":
from distutils.command.bdist_conda import CondaDistribution as Distribution
build_requires = [
"setuptools",
]
install_requires = [
"blas==1.1",
"openblas",
"future",
"psutil",
"numpy >=1.11",
"scipy",
"h5py",
"bottleneck",
"imgroi",
"kenjutsu",
"metawrap",
"npctypes",
"xnumpy",
"scikit-image",
"scikit-learn",
"tifffile",
"yail",
"mahotas",
"vigra",
"rank_filter"
]
if sys.version_info < (3, 2):
install_requires += [
"functools32"
]
elif sys.argv[1] == "build_sphinx":
import sphinx
import sphinx.apidoc
sphinx_apidoc_args = []
if LooseVersion(sphinx.__version__) < LooseVersion("1.7"):
sphinx_apidoc_args.append(sphinx.apidoc.__file__)
sphinx_apidoc_args.extend([
"-f", "-T", "-e", "-M",
"-o", "docs",
".",
"setup.py", "tests", "versioneer.py"
])
sphinx.apidoc.main(sphinx_apidoc_args)
build_prefix_arg_index = None
for each_build_arg in ["-b", "--builder"]:
try:
build_arg_index = sys.argv.index(each_build_arg)
except ValueError:
continue
if sys.argv[build_arg_index + 1] == "pdf":
sphinx_build_pdf = True
sys.argv[build_arg_index + 1] = "latex"
elif sys.argv[1] == "clean":
saved_rst_files = ["docs/index.rst", "docs/readme.rst", "docs/todo.rst"]
tmp_rst_files = glob("docs/*.rst")
print("removing 'docs/*.rst'")
for each_saved_rst_file in saved_rst_files:
print("skipping '" + each_saved_rst_file + "'")
tmp_rst_files.remove(each_saved_rst_file)
for each_tmp_rst_file in tmp_rst_files:
os.remove(each_tmp_rst_file)
if os.path.exists("build/sphinx/doctrees"):
print("removing 'build/sphinx/doctrees'")
shutil.rmtree("build/sphinx/doctrees")
else:
print("'build/sphinx/doctrees' does not exist -- can't clean it")
if os.path.exists(".eggs"):
print("removing '.eggs'")
shutil.rmtree(".eggs")
else:
print("'.eggs' does not exist -- can't clean it")
if (len(sys.argv) > 2) and (sys.argv[2] in ["-a", "--all"]):
if os.path.exists("build/sphinx"):
print("removing 'build/sphinx'")
shutil.rmtree("build/sphinx")
else:
print("'build/sphinx' does not exist -- can't clean it")
elif sys.argv[1] == "develop":
if (len(sys.argv) > 2) and (sys.argv[2] in ["-u", "--uninstall"]):
if os.path.exists("nanshe.egg-info"):
print("removing 'nanshe.egg-info'")
shutil.rmtree("nanshe.egg-info")
else:
print("'nanshe.egg-info' does not exist -- can't clean it")
setup(
name="nanshe",
version=versioneer.get_version(),
description="An image processing toolkit.",
url="https://github.com/nanshe-org/nanshe",
license="BSD 3-Clause",
author="John Kirkham",
author_email="kirkhamj@janelia.hhmi.org",
scripts=glob("bin/*"),
packages=find_packages(exclude=["tests*"]),
distclass=Distribution,
cmdclass=dict(sum([list(_.items()) for _ in [
versioneer.get_cmdclass(),
{"test": NoseTestCommand}
]], [])),
build_requires=build_requires,
install_requires=install_requires,
tests_require=tests_require,
test_suite="nose.collector",
data_files=[("", ["LICENSE.txt"])],
zip_safe=True,
conda_import_tests=False,
conda_command_tests=False
)
if sphinx_build_pdf:
make_cmd = os.environ.get("MAKE", "make")
cwd = os.getcwd()
os.chdir("build/sphinx/latex")
os.execlpe(make_cmd, "all", os.environ)
os.chdir(cwd)