-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
177 lines (146 loc) · 5.11 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
===========================================================
mauve-py:
===========================================================
``mauve-py`` is a Python wrappers for a derivative of the
popular mauve genome aligner.
See README.md for more information for usage examples.
Installation
------------
``mauve-py`` has three dependencies and should compile on
most linux and OS X systems that are running Python 2.7, 3.3, or 3.4.
To build ``mauve-py`` within the package directory run::
$ python setup.py build_ext --inplace
If you would like to install mauve-py in your local Python environment
you may do so using the setup.py script::
$ python setup.py install
'''
import os
import stat
import platform
import subprocess
from distutils import log as dlog
from distutils.core import setup, Extension
from distutils.command import install_lib
from os.path import join as pjoin
from os.path import relpath as rpath
dlog.set_verbosity(dlog.INFO)
try:
from Cython.Build import cythonize
except:
print("Please install cython")
raise
try:
import numpy.distutils.misc_util
except:
print("Please install numpy")
raise
try:
import bitarray
except:
print("Please install bitarray")
raise
# list of all executable built by the mauve source
mauve_executables = ["addUnalignedIntervals", "makeBadgerMatrix",
"alignmentProjector", "backbone_global_to_local",
"bbAnalyze", "bbFilter",
"coordinateTranslate", "createBackboneMFA",
"extractBCITrees", "getAlignmentWindows",
"getOrthologList", "repeatoire",
"mauveAligner", "mauveStatic",
"mauveToXMFA", "mfa2xmfa",
"muscle", "progressiveMauve",
"progressiveMauveStatic",
"projectAndStrip", "randomGeneSample",
"scoreAlignment", "stripGapColumns",
"stripSubsetLCBs", "toGrimmFormat",
"toMultiFastA", "toRawSequence",
"uniqueMerCount", "uniquifyTrees",
"xmfa2maf"
]
# to install executable files in package_data
class ExeInstallLib(install_lib.install_lib):
def run(self):
install_lib.install_lib.run(self)
for fn in self.get_outputs():
base_filename = os.path.basename(fn)
if base_filename == "progressiveMauveStatic" or \
base_filename == "progressiveMauve":
# make sure user executable
mode = os.stat(fn).st_mode | stat.S_IXUSR | stat.S_IXGRP
dlog.info("Changing mode of %s to %d", fn, mode)
os.chmod(fn, mode)
# end class
with open('README.md') as fd:
LONG_DESCRIPTION = fd.read()
PACKAGE_PATH = os.path.abspath(os.path.dirname(__file__))
MODULE_PATH = pjoin(PACKAGE_PATH, 'mauve')
SRC_PATH = pjoin(MODULE_PATH, 'src')
BIN_PATH = pjoin(SRC_PATH, 'bin')
INCLUDE_PATH = pjoin(SRC_PATH, 'include')
# Build mauve for subprocess bindings
os_system = platform.system()
if os_system == 'Darwin':
mauve_make = 'build_osx.sh'
elif os_system == 'Linux': # update this for BSD, other POSIX etc
mauve_make = 'build_linux.sh'
else:
raise OSError("Platform %s not supported" % (os_system))
print("Building mauve dependencies...")
mauve_make = pjoin(SRC_PATH, mauve_make)
mauvebuild = subprocess.Popen([mauve_make], shell=True, cwd=SRC_PATH)
mauvebuild.wait()
print("Finished building mauve dependencies")
# Find all mauve data files to include with the package
mauve_files = [rpath(pjoin(root, f), MODULE_PATH) for root, _, files in
os.walk(BIN_PATH) for f in files]
mauve_files += [rpath(pjoin(root, f), MODULE_PATH) for root, _, files in
os.walk(INCLUDE_PATH) for f in files]
DESCRIPTION = ("Python wrapper for progressive mauve genome aligner")
DISTNAME = 'mauve-py'
LICENSE = 'GPLv2'
AUTHORS = "Nick Conway, Ben Pruitt"
EMAIL = "nick.conway@wyss.harvard.edu"
URL = ""
DOWNLOAD_URL = ''
CLASSIFIERS = [
'Development Status :: 1 - Beta',
'Environment :: Console',
'Intended Audience :: Science/Research',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Cython',
'Topic :: Scientific/Engineering',
]
MAJOR = 0
MINOR = 1
MICRO = 1
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
mauve_extensions = [Extension('mauve.indexutils',
sources=['mauve/indexutils.pyx'],
extra_compile_args=['-Wno-error=declaration-after-statement',
'-Wno-unused-function'])]
mauve_ext_list = cythonize(mauve_extensions)
setup(
version=VERSION,
name=DISTNAME,
maintainer=AUTHORS,
packages=['mauve'],
ext_modules=mauve_ext_list,
include_dirs=numpy.distutils.misc_util.get_numpy_include_dirs(),
maintainer_email=EMAIL,
description=DESCRIPTION,
license=LICENSE,
url=URL,
download_url=DOWNLOAD_URL,
long_description=LONG_DESCRIPTION,
classifiers=CLASSIFIERS,
package_data={'mauve': mauve_files},
cmdclass={'install_lib':ExeInstallLib}
)