-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
104 lines (81 loc) · 3.05 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
# Copyright 2016 Ifwe Inc.
#
# 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 setuptools import setup
from setuptools.command.test import test as TestCommand
import sys
# Let's add this later
# long_description = open('README.txt').read()
# Get version of project
import version
class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = [self.test_suite]
def run_tests(self):
#import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.test_args)
if errno != 0:
raise SystemExit("Test failures (errno=%d)", errno)
PYTHON27_REQ_BLACKLIST = ['argparse', 'ordereddict']
def reqfile_read(fname):
with open(fname, 'r') as reqfile:
reqs = reqfile.read()
return filter(None, reqs.strip().splitlines())
def load_requirements(fname):
requirements = []
for req in reqfile_read(fname):
if 'git+' in req:
req = '=='.join(req.rsplit('=')[-1].rsplit('-', 1))
if sys.version_info > (2, 7) or sys.version_info > (3, 2):
if any(req.startswith(bl) for bl in PYTHON27_REQ_BLACKLIST):
continue
requirements.append(req)
return requirements
def load_github_dependency_links(fname):
dep_links = []
for req in reqfile_read(fname):
if 'git+' in req and 'github' in req: # not exactly precise...
url, ref_egg = req.split('git+', 1)[-1].rsplit('@', 1)
dep_links.append(url + '/tarball/' + ref_egg)
return dep_links
REQUIREMENTS = {}
REQUIREMENTS['install'] = load_requirements('requirements.txt')
REQUIREMENTS['tests'] = load_requirements('requirements-dev.txt')
DEPENDENCY_LINKS = load_github_dependency_links('requirements.txt')
DEPENDENCY_LINKS.extend(load_github_dependency_links('requirements-dev.txt'))
setup_args = dict(
name='tagopsdb',
version=version.__version__,
description='Python library to interface with TagOps database',
# long_description = long_description,
author='Kenneth Lareau',
author_email='[email protected]',
license='Apache License, Version 2.0',
packages=[
'tagopsdb',
'tagopsdb.database',
'tagopsdb.deploy',
'tagopsdb.model',
'tagopsdb.model.meta',
],
entry_points={},
install_requires=REQUIREMENTS['install'],
test_suite='tests',
tests_require=REQUIREMENTS['tests'] + REQUIREMENTS['install'],
cmdclass=dict(test=PyTest),
dependency_links=DEPENDENCY_LINKS,
)
if __name__ == '__main__':
setup(**setup_args)