-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
89 lines (76 loc) · 2.62 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
"""Macro module for MetaSUB Utilites.
Based on: https://blog.shazam.com/python-microlibs-5be9461ad979
"""
import os
from six import iteritems
from setuptools import setup
from setuptools.command.develop import develop
from setuptools.command.install import install
from subprocess import check_call
PACKAGE_NAME = 'metasub_utils'
SOURCES = {
'metasub_utils.athena': 'metasub_utils/athena',
'metasub_utils.bridges': 'metasub_utils/bridges',
'metasub_utils.hudson_alpha': 'metasub_utils/hudson_alpha',
'metasub_utils.metadata>=0.3.1': 'metasub_utils/metadata',
'metasub_utils.metagenscope': 'metasub_utils/metagenscope',
'metasub_utils.wasabi>=0.7.0': 'metasub_utils/wasabi',
'metasub_utils.zurich': 'metasub_utils/zurich',
'metasub_utils.packet_parse>=0.1.6': 'metasub_utils/packet_parse',
'metasub_utils.data_packet>=0.3.0': 'metasub_utils/data_packet',
}
def install_microlibs(sources, develop=False):
""" Use pip to install all microlibraries. """
print('Installing all microlibs in {} mode'.format(
'development' if develop else 'normal'))
working_dir = os.getcwd()
for name, path in iteritems(sources):
try:
os.chdir(os.path.join(working_dir, path))
if develop:
check_call(["python", '-m', 'pip', 'install', '-e', '.'])
else:
check_call(["python", '-m', 'pip', 'install', '.'])
except Exception as e:
print('Something went wrong installing', name)
print(e)
finally:
os.chdir(working_dir)
class DevelopCmd(develop):
""" Add custom steps for the develop command """
def run(self):
install_microlibs(SOURCES, develop=True)
develop.run(self)
class InstallCmd(install):
""" Add custom steps for the install command """
def run(self):
install_microlibs(SOURCES, develop=False)
install.run(self)
setup(
name=PACKAGE_NAME,
version='0.9.0',
author='David Danko',
author_email='[email protected]',
description='Utility functions for the MetaSUB Consortium',
license='MIT License',
classifiers=[
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3.6',
],
install_requires=[
'future',
'six',
] + list(SOURCES.keys()),
entry_points={
'console_scripts': [
'metasub=metasub_utils.cli:main'
]
},
cmdclass={
'install': InstallCmd,
'develop': DevelopCmd,
},
packages=[PACKAGE_NAME],
package_dir={PACKAGE_NAME: 'metasub_utils'},
)