forked from HelikarLab/candis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.py
executable file
·92 lines (78 loc) · 2.67 KB
/
package.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
# inspired by npm's package.json
# imports - standard imports
import os
import io
from setuptools import find_packages
# imports - third-party imports
try: # for pip >= 10
from pip._internal.req import parse_requirements
except ImportError: # for pip <= 9.0.3
from pip.req import parse_requirements
# Python 2
try:
FileNotFoundError
except NameError:
FileNotFoundError = IOError
basedir = os.path.dirname(__file__)
srcpath = os.path.join(basedir, 'candis', '__attr__.py')
with open(srcpath) as f:
code = f.read()
exec(code)
def get_long_description(*filepaths):
for filepath in filepaths:
abspath = os.path.abspath(filepath)
if os.path.exists(abspath):
if os.path.isfile(abspath):
if os.path.getsize(abspath) > 0:
with io.open(abspath, mode = 'r', encoding = 'utf-8') as f:
content = f.read()
else:
raise ValueError('Not a file: {filepath}'.format(filepath = abspath))
else:
raise FileNotFoundError('No such file found: {filepath}'.format(filepath = abspath))
def get_dependencies(type_ = None, dirpath = 'requirements'):
abspath = dirpath if os.path.isabs(dirpath) else os.path.join(basedir, dirpath)
types = [os.path.splitext(fname)[0] for fname in os.listdir(abspath)]
if not os.path.exists(abspath):
raise ValueError('Directory {directory} not found.'.format(directory = abspath))
elif not os.path.isdir(abspath):
raise ValueError('{directory} is not a directory.'.format(directory = abspath))
if type_:
if type_ in types:
path = os.path.join(abspath, '{type_}.txt'.format(type_ = type_))
dependencies = [str(d.req) for d in parse_requirements(path, session = 'meh')]
return dependencies
else:
raise ValueError('Incorrect dependency type {type_}'.format(type_ = type_))
else:
dependencies = dict()
for type_ in types:
dependencies[type_] = get_dependencies(type_)
return dependencies
package = dict(
name = 'candis',
version = __version__,
release = __release__,
description = 'A data mining suite for DNA Microarrays.',
long_description = get_long_description('README.md', 'LICENSE'),
homepage = 'https://candis.readthedocs.io',
authors = \
[
{ 'name': 'Achilles Rasquinha', 'email': '[email protected]' }
],
maintainers = \
[
{ 'name': 'Achilles Rasquinha', 'email': '[email protected]' }
],
license = 'GNU General Public License v3.0',
modules = find_packages(exclude = ['test']),
test_modules = find_packages(include = ['test']),
classifiers = \
[
],
keywords = \
[
'data', 'mining', 'suite', 'dna', 'microarray', 'bioinformatics'
],
# dependencies = get_dependencies()
)