forked from mtholder/pytbeaglehon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·262 lines (228 loc) · 9.5 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#! /usr/bin/env python
# Copyright (c) 2010-2011 by Mark T. Holder
# (see bottom of file)
import ez_setup
import sys, os
from setuptools import setup, find_packages, Extension
###############################################################################
# setuptools/distutils/etc. import and configuration
try:
import ez_setup
try:
ez_setup_path = " ('" + os.path.abspath(ez_setup.__file__) + "')"
except OSError:
ez_setup_path = ""
sys.stderr.write("using ez_setup%s\n" % ez_setup_path)
ez_setup.use_setuptools()
import setuptools
try:
setuptools_path = " ('" + os.path.abspath(setuptools.__file__) + "')"
except OSError:
setuptools_path = ""
sys.stderr.write("using setuptools%s\n" % setuptools_path)
from setuptools import setup, find_packages
except ImportError, e:
sys.stderr.write("using distutils\n")
from distutils.core import setup
sys.stderr.write("using canned package list\n")
PACKAGES = ['pytbeaglehon',
'pytbeaglehon.ccore',
]
EXTRA_KWARGS = {}
else:
sys.stderr.write("searching for packages\n")
PACKAGES = find_packages()
EXTRA_KWARGS = dict(
install_requires = ['setuptools'],
include_package_data=True,
test_suite = "pytbeaglehon.tests"
)
args = sys.argv
help_msg = """
pybeathon specific options:
Compilation flags
--debug compile in debug mode
--no-inline use this if your compiler does not deal with the "inline"
keyword.
--use-ncl enable functions that depend on the NEXUS Class library.
Note that the build is sensitive to your CFLAGS environmental variable (and
a simple "split" call is used to break the value of the variable into
arguments, use of quoted strings with spaces may cause problems).
Environmental variables
BEAGLE_VERSION The full version appended to the beaglelib. Default: 1
BEAGLE_PREFIX The directory used as the prefix for the beagle install
Default: /usr/local
BEAGLE_DEPENDENCY_LIB The name of any dynamic library that beagle needs to
link with (for instance "cuda"). Default: none
BEAGLE_DEPENDENCY_LIB_DIR The directory that holds libraries that beagle needs
to link to (eg. the "/usr/local/cuda/lib" to find the CUDA libraries).
Default: none
NCL_PREFIX The directory used as the prefix for the NCL install (only used
--use-ncl
"""
if ("--help" in args) or ("-h" in args):
sys.stderr.write(help_msg)
if "--debug" in args:
kDebugPrint = "1"
extra_compile_args = ["-Wall"]
else:
kDebugPrint = "0"
extra_compile_args = []
if 'CFLAGS' in os.environ:
extra_compile_args.extend(os.environ['CFLAGS'].split())
if "--no-inline" in args:
have_inline = 0
args.remove("--no-inline")
else:
have_inline = 1
if "--use-ncl" in args:
have_ncl = 1
else:
have_ncl = 0
if "--trace-printing" in args:
if kDebugPrint != "1":
sys.stderr.write("Warning: --trace-printing only has an effect if --debug is also specified\n")
kTracePrint = "1"
args.remove("--trace-printing")
else:
kTracePrint = "0"
PACKAGE_DIRS = [p.replace(".", os.path.sep) for p in PACKAGES]
PACKAGE_INFO = [("% 40s : %s" % p) for p in zip(PACKAGES, PACKAGE_DIRS)]
sys.stderr.write("packages identified:\n%s\n" % ("\n".join(PACKAGE_INFO)))
SCRIPT_SUBPATHS = [
['scripts', 'gtr_prob_mat.py'],
]
SCRIPTS = [os.path.join(*i) for i in SCRIPT_SUBPATHS]
sys.stderr.write("\nscripts identified: %s\n" % ", ".join(SCRIPTS))
include_dirs = []
library_dirs = []
libraries = []
preprocessor_defines =[("DEBUG_PRINTING", kDebugPrint),
("API_TRACE_PRINTING", kTracePrint),
("BEAGLE_API_TRACE_PRINTING", kTracePrint),
("BUILDING_FOR_PYTHON", 1),
("HAVE_INLINE", have_inline),
("HAVE_NCL", have_ncl)
]
beagle_full_version = os.environ.get("BEAGLE_VERSION")
if beagle_full_version is None:
beagle_full_version = "1"
sys.stderr.write('BEAGLE_VERSION not found in environment... Assuming "%s"\n' % beagle_full_version)
beagle_version = ".".join(beagle_full_version.split(".")[:2])
beagle_lib_dir = os.environ.get('BEAGLE_PREFIX')
if not beagle_lib_dir:
beagle_lib_dir = "/usr/local"
sys.stderr.write('BEAGLE_PREFIX not found in environment... Assuming "%s"\n' % beagle_lib_dir)
if not os.path.exists(beagle_lib_dir):
sys.exit("Could not find the directory %s" % beagle_lib_dir)
beagle_lib_inc_dir = os.path.join(beagle_lib_dir, "include", "libhmsbeagle-%s" % beagle_version)
if not os.path.exists(beagle_lib_inc_dir):
sys.exit("Could not find the directory %s" % beagle_lib_inc_dir)
beagle_lib_lib_dir = os.path.join(beagle_lib_dir, "lib")
if not os.path.exists(beagle_lib_lib_dir):
sys.exit("Could not find the directory %s" % kbeagle_lib_lib_dir)
include_dirs.append(beagle_lib_inc_dir)
library_dirs.append(beagle_lib_lib_dir)
cuda_lib_dir = os.environ.get('BEAGLE_DEPENDENCY_LIB_DIR')
if cuda_lib_dir is None:
sys.stderr.write('BEAGLE_DEPENDENCY_LIB_DIR not found in environment... Assuming no additional directories to be added to the link path\n')
else:
library_dirs.append(cuda_lib_dir)
cuda_lib = os.environ.get('BEAGLE_DEPENDENCY_LIB')
if cuda_lib is None:
sys.stderr.write('BEAGLE_DEPENDENCY_LIB not found in environment... Assuming no additional libraries to be added to the link path\n')
else:
libraries.append(cuda_lib)
libraries.append('hmsbeagle')
using_ncl = "--use-ncl" in args
if using_ncl:
args.remove("--use-ncl")
ncl_install_dir = os.environ.get('NCL_PREFIX')
if ncl_install_dir is None:
ncl_install_dir = "/usr/local"
sys.stderr.write('NCL_PREFIX not found in environment... Assuming "%s"\n'% ncl_install_dir)
if not os.path.exists(ncl_install_dir):
sys.exit("Could not find the directory %s" % ncl_install_dir)
ncl_inc_dir = os.path.join(ncl_install_dir, "include")
if not os.path.exists(ncl_inc_dir):
sys.exit("Could not find the directory %s" % ncl_inc_dir)
ncl_lib_dir = os.path.join(ncl_install_dir, "lib", "ncl")
if not os.path.exists(ncl_lib_dir):
sys.exit("Could not find the directory %s" % ncl_lib_dir)
include_dirs.append(ncl_inc_dir)
library_dirs.append(ncl_lib_dir)
libraries.append('ncl')
ENTRY_POINTS = {}
try:
from setuptools import Command
except ImportError:
sys.stderr.write("setuptools.Command could not be imported: setuptools extensions not available\n")
else:
sys.stderr.write("setuptools command extensions are available\n")
command_hook = "distutils.commands"
ENTRY_POINTS[command_hook] = []
src_prefix = "pytbeaglehon/ccore"
ext_source_files =[ "asrv.c",
"calc_instance.c",
"discrete_state_model.c",
"phylo_util.c",
"py_asrv.c",
"py_beagle.c",
"py_calc_instance.c",
"py_discrete_state_model.c",
"py_util.c",
]
ext_sources = [os.path.join(src_prefix, i) for i in ext_source_files]
setup(name = "pytbeaglehon",
version = "0.01",
packages=PACKAGES,
scripts = SCRIPTS,
entry_points = ENTRY_POINTS,
maintainer = "Mark Holder",
maintainer_email = "mtholder@gmail.com",
description = "Calculations of likelihoods for phylogenetics using C extensions and the beaglelib library",
ext_modules = [
Extension("pytbeaglehon.ccore.disc_state_cont_time_model",
define_macros=preprocessor_defines,
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
extra_compile_args=extra_compile_args,
sources=ext_sources)],
license = "GNU General Public License (see LICENCE.txt and GPL.txt)",
keywords = "phylogenetics bioinformatics likelihood",
url = "http://people.ku.edu/~mtholder",
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"License :: OSI Approved :: GNU Library or General Public License (GPL)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Scientific/Engineering :: Bio-Informatics",
],
**EXTRA_KWARGS
)
################################################################################
# cPhyProb is a package implementing some probability calculations used in
# calculating likelihoods on phylogenies.
#
# Copyright (C) 2005-2007 Mark Holder mtholder@gmail.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
################################################################################