forked from BD2KGenomics/protect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
99 lines (86 loc) · 3.6 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
from __future__ import print_function
from pkg_resources import parse_version, SetuptoolsLegacyVersion
from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand
from version import version
import errno
import subprocess
import sys
def check_tool_version(tool, required_version, binary=False):
"""
This will ensure that the required_version of `tool` is at least `required_version`.
:param str tool: The tool under review
:param str required_version: The version of the tool required by ProTECT
:param bool binary: Is the tool a binary
:return: None
"""
if binary:
try:
installed_version = subprocess.check_output([tool, '--version'],
stderr=subprocess.STDOUT)
except OSError as err:
if err.errno == errno.ENOENT:
raise RuntimeError('Is %s installed as a binary and present on your $PATH?' % tool)
else:
raise
installed_version = installed_version.rstrip()
else:
try:
module = __import__(tool + '.version')
except ImportError:
raise RuntimeError('Is %s installed as a library, and is it accessible in the same '
'environment as ProTECT?' % tool)
try:
installed_version = getattr(module, 'version').version
except AttributeError:
raise RuntimeError('Does %s have a version.py?' % tool)
if type(parse_version(installed_version)) == SetuptoolsLegacyVersion:
print('Detecting that the installed version of "%s"(%s) is probably based off a git commit '
'and assuming this build is for testing purposes. If this is not the case, please '
'try again with a valid version of "%s".' % (tool, installed_version, tool))
elif parse_version(installed_version) < parse_version(required_version):
raise RuntimeError('%s was detected to be version (%s) but ProTECT requires (%s)' %
(tool, installed_version, required_version))
# Check Toil version
check_tool_version('toil', '3.5.1', binary=False)
# Check S3am version
check_tool_version('s3am', '2.0.1', binary=True)
# Set up a test class
# noinspection PyAttributeOutsideInit
class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = []
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
import pytest
# Sanitize command line arguments to avoid confusing Toil code attempting to parse them
sys.argv[1:] = []
err_number = pytest.main(self.pytest_args)
sys.exit(err_number)
setup(name='protect',
version=version,
description='Prediction of T-Cell Epitopes for Cancer Therapy',
url='http://github.com/BD2KGenomics/protect',
author='Arjun Arkal Rao',
author_email='[email protected]',
license='Apache',
install_requires=[
'PyYAML'
],
tests_require=[
'pytest==2.8.3'],
test_suite='protect',
entry_points={
'console_scripts': [
'ProTECT = protect.pipeline.ProTECT:main']},
cmdclass={'test': PyTest},
package_dir={'': 'src'},
packages=find_packages('src', exclude=['*.test']),
package_data={'':['src/protect/pipeline/input_parameters.yaml']},
include_package_data=True,
zip_safe=False)