-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
124 lines (109 loc) · 3.3 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import platform
from setuptools import setup, Extension
def check_rna_lib_installed(**kwa):
"Check Vienna RNA Packages"
def check_libs(paths):
for path in paths:
exts = ('.so', '.la', '.a')
libpaths = [path + '/libRNA' + ext for ext in exts]
return any(libpaths)
return False
def check_includes(paths):
for path in paths:
foldpath = path + '/ViennaRNA/fold.h'
if os.path.exists(foldpath):
return True
return False
return check_includes(kwa['include_dirs']) and check_libs(kwa['library_dirs'])
def get_rna_lib_intallation_path():
"Attempts to get the RNAlib Path"
includes = [
'/usr/include',
'/usr/local/include',
os.path.abspath('.build/include'),
]
libs = [
'/usr/lib',
'/usr/local/lib',
os.path.abspath('.build/lib'),
]
if 'VIENNA_RNA_PATH' in os.environ:
px = os.environ['VIENNA_RNA_PATH']
includes.append(px + '/include')
libs.append(px + '/lib')
return {
'include_dirs': includes[::-1],
'library_dirs': libs[::-1]
}
def check_sanity():
"""
Check Sanity of the System. Since metaRNA core depends on C extension,
only posix systems are supported at the moment.
"""
if not os.name == 'posix':
print("metaRNA is currently not tested on non-posix systems.")
if sys.version_info[:2] not in [(2, 7), (3, 3), (3, 4), (3, 5), (3, 6)]:
print("metaRNA is only supported on Python 2.7, 3.3, 3.4, 3.5, 3.6.")
return False
if not check_rna_lib_installed(**get_rna_lib_intallation_path()):
print(
"metaRNA requires Vienna RNA package. Please read the docs "
"for installation instructions.\n"
"If you have Vienna Package, then perhaps the installer is "
"unable to find the location. The location may be set by "
"setting the `VIENNA_RNA_PATH` environment variable."
)
return False
return True
if not check_sanity():
sys.exit(1)
def extension_args():
args = get_rna_lib_intallation_path()
args['depends'] = [
'metarna/pymiranda/miranda.h',
]
args['sources'] = [
'metarna/pymiranda/pymiranda.c',
'metarna/pymiranda/scan.c',
'metarna/pymiranda/swat.c',
'metarna/pymiranda/thermo.c',
'metarna/pymiranda/utils.c',
'metarna/pymiranda/output.c',
'metarna/pymiranda/ExpString.c',
]
args['libraries'] = [
'RNA',
'm'
]
if not platform.system() == 'Darwin':
args['extra_compile_args'] = ['-fopenmp']
args['extra_link_args'] = ['-lgomp']
return args
setup_args = {
'name': 'metarna',
'version': '4.0.5',
'author': 'Prashant Sinha',
'author_email': '[email protected]',
'url': 'https://github.com/prashnts/metarna',
'license': 'GPLv3',
'description': 'Finds target sites for the miRNAs in genomic sequences.',
'packages': ['metarna'],
'ext_modules': [
Extension('metarna.pymiranda', **extension_args()),
],
'classifiers': [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Scientific/Engineering :: Bio-Informatics',
]
}
setup(**setup_args)