-
Notifications
You must be signed in to change notification settings - Fork 13
/
setup.py
133 lines (118 loc) · 5.02 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
#!/usr/bin/env python2.7
# Copyright 2016 UCSC Computational Genomics Lab
# Original contributor: Arjun Arkal Rao
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from pkg_resources import parse_version
try:
from pkg_resources import SetuptoolsLegacyVersion as _LegacyVersion
except ImportError as e:
if 'SetuptoolsLegacyVersion' in e.message:
from packaging.version import LegacyVersion as _LegacyVersion
else:
raise
from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand
from version import version
import errno
import subprocess
import sys
toil_version = '3.8.0'
s3am_version = '2.0.1'
gdc_version = 'v1.1.0'
def check_tool_version(tool, required_version, blacklisted_versions=None, 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 list blacklisted_versions: Version of the tool blacklisted 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)) == _LegacyVersion:
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))
if blacklisted_versions is not None:
if parse_version(installed_version) in [parse_version(v) for v in blacklisted_versions]:
raise RuntimeError('The version of %s was detected to be on the a blacklist (%s).' %
(tool, installed_version))
# Check Toil version
check_tool_version('toil', toil_version, binary=True)
# Check S3am version
check_tool_version('s3am', s3am_version, binary=True)
# Check gdc-client version
check_tool_version('gdc-client', gdc_version, binary=True, blacklisted_versions=['v1.2.0'])
# 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',
'pandas==0.19.2'
],
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)