-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetup.py
117 lines (95 loc) · 3.55 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
# vim: fdm=marker
'''
author: Fabio Zanini
date: 26/01/14
content: Setup file for the Python wrapper of SeqAn.
'''
# Modules
import os
import sys
from distutils.command import build_ext
from distutils.core import setup, Extension
from distutils.cmd import Command
from distutils.log import INFO as logINFO
# Globals
py_maj = sys.version_info[0]
# Use this env variable to set your SeqAn include folder
seqan_path = os.getenv('SEQAN_INCLUDE_PATH',
'/usr/include').rstrip(os.path.sep)
seqan_cpp_std = 'c++11'
if os.path.isdir(seqan_path+'/seqan'):
with open(seqan_path+'/seqan/version.h', 'rt') as f:
for line in f:
if 'define SEQAN_VERSION_MAJOR' in line:
seqan_vma = int(line.rstrip('\n').split(' ')[-1])
if 'define SEQAN_VERSION_MINOR' in line:
seqan_vmi = int(line.rstrip('\n').split(' ')[-1])
if (seqan_vma > 2) or ((seqan_vma == 2) and (seqan_vmi >= 2)):
print('SeqAn 2.2+ found. Setting C++ standard to c++14.')
seqan_cpp_std = 'c++14'
class install_seqan(Command):
'''Install seqan before anything else'''
description = "check SeqAn installation"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
self.install_seqan()
def install_seqan(self):
from subprocess import check_call
if py_maj == 2:
from subprocess import CalledProcessError as SubprocessError
else:
from subprocess import SubprocessError
def c(x): return check_call(x, shell=True)
def p(x): return self.announce(x, level=logINFO)
if os.path.isdir(seqan_path+'/seqan'):
p('SeqAn include folder found. Not installing.')
return
raise IOError('SeqAn include folder NOT found. Install it and set the'+
' environment variable SEQAN_INCLUDE_PATH to the parent'+
' of the SeqAn include folder and retry.')
class my_build_ext(build_ext.build_ext):
def run(self):
self.run_command('install_seqan')
build_ext.build_ext.run(self)
def find_swig(self):
import os
swig_cmd = os.getenv('SWIG')
if swig_cmd is not None:
return swig_cmd
else:
return build_ext.build_ext.find_swig(self)
_seqanpy = Extension('_seqanpy',
sources=['seqanpy.i',
'test.cpp',
'align.cpp'],
swig_opts=['-c++',
'-modern',
'-modernargs',
'-keyword',
'-I'+seqan_path],
extra_compile_args=['-std='+seqan_cpp_std],
include_dirs=[seqan_path],
)
setup(name='seqanpy',
version="0.2",
author="Fabio Zanini",
description="""Fast pairwise sequence alignment using SeqAn""",
long_description="""Fast pairwise sequence alignment using SeqAn.
Instructions and development: https://github.com/iosonofabio/seqanpy
""",
ext_modules=[_seqanpy],
py_modules=["seqanpy"],
# metadata for upload to PyPI
author_email="[email protected]",
license="BSD/2-clause",
keywords="alignment sequence pairwise C++",
url="https://github.com/iosonofabio/seqanpy",
cmdclass={
'install_seqan': install_seqan,
'build_ext': my_build_ext
},
)