-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
153 lines (121 loc) · 4.76 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
import os
import sys
import subprocess
from setuptools import Command, find_packages, setup
from setuptools.command.install import install
from setuptools.command.develop import develop
from setuptools.command.egg_info import egg_info
from LineageTracker import __VERSION__
MIN_PY_VER = (3, 6)
if sys.version_info[:2] < MIN_PY_VER:
sys.stderr.write(
("Biopython requires Python %i.%i or later. " % MIN_PY_VER)
+ ("Python %d.%d detected.\n" % sys.version_info[:2])
)
sys.exit(1)
required = ['pandas',
'numpy',
'scikit-learn',
'scipy',
'matplotlib',
'ete3',
'networkx',
'BioPython',
'pysam',
'pyqt5',
'adjustText']
request = ['pygraphviz']
def get_virtualenv_path():
'''Used to work out path to install compiled binaries to.'''
if hasattr(sys, 'real_prefix'):
return sys.prefix
if hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix:
return sys.prefix
if 'conda' in sys.prefix:
return sys.prefix
return None
def compile_and_install_software():
'''Used the subprocess module to compile/install the C software.'''
src_path = './LineageTracker/src/'
# install the software (into the virtualenv bin dir if present)
try:
subprocess.check_call('make', cwd=src_path, shell=True)
except:
print('make command is required for installation')
try:
import platform
system = platform.system()
if platform == 'Windows':
subprocess.check_call('pip install pygraphviz', shell=True)
else:
subprocess.check_call('pip install --install-option="--include-path=/usr/local/include/" --install-option="--library-path=/usr/local/lib/" pygraphviz', shell=True)
except:
print('Failed to install pygraphviz')
class CustomInstall(install):
'''Custom handler for the 'install' command.'''
def run(self):
install.run(self)
compile_and_install_software()
super().run()
class CustomDevelopCommand(develop):
def run(self):
develop.run(self)
compile_and_install_software()
class CustomEggInfoCommand(egg_info):
def run(self):
egg_info.run(self)
compile_and_install_software()
class TestProgram(Command):
description = 'run to test Y-LineageTracker'
user_options = [('cmd', None, 'test all commands'),]
def initialize_options(self):
'''Set default values for options'''
self.cmd = 'all'
def finalize_options(self):
'''Post-process options'''
print('[Y-LineageTracker] [Test] Testing started')
def run(self):
'''Run command'''
import importlib
for i in required:
found = importlib.util.find_spec(i)
if not found:
print('[Y-LineageTracker] [Test] Package [%s] is required for testing')
sys.exit()
current_dir = os.path.split(os.path.realpath(__file__))[0]
sys.path.insert(0, current_dir+ '/Test')
from Test import TestProgram
if self.cmd == 'all':
TestProgram.main()
setup(name='Y-LineageTracker',
version=__VERSION__,
author='Hao Chen',
author_email='chenhao@picb.ac.cn',
description='Y-LineageTracker: A framework to fully analyze human Y-chromosome sequencing data',
license='GPL-3.0',
keywords=['Bioinformatics', 'Computational biology', 'Population genetics',
'Genomics', 'Y chromosome', 'haplogroup', 'Y-STR'],
url='http://www.picb.ac.cn/PGG/resource.php',
packages=['LineageTracker',
'LineageTracker.ProcessData',
'LineageTracker.GetLineage',
'LineageTracker.Test'],
package_data={'LineageTracker': ['Data/*', 'sans-serif/*', 'src/*', 'Test/TestData/*', 'Config.ini']},
entry_points={'console_scripts':
['LineageTracker = LineageTracker.RunLineagerTracker:main']},
install_requires=required,
classifiers=['Development Status :: 3 - Alpha',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: C',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'Topic :: Scientific/Engineering :: Visualization'],
zip_safe=False,
cmdclass={'test': TestProgram,
'install': CustomInstall,
'develop': CustomDevelopCommand,
'egg_info': CustomEggInfoCommand},
python_requires=">=%i.%i" % MIN_PY_VER)