|
1 | 1 | # -*- coding: utf-8 -*- |
2 | | -# Copyright 2015-TODAY LasLabs Inc. |
| 2 | +# Copyright 2016-TODAY LasLabs Inc. |
3 | 3 | # License MIT (https://opensource.org/licenses/MIT). |
4 | 4 |
|
5 | | -from setuptools import setup |
| 5 | +from setuptools import Command, setup |
6 | 6 | from setuptools import find_packages |
7 | | -from tests import Tests |
| 7 | +from unittest import TestLoader, TextTestRunner |
| 8 | + |
| 9 | +from os import environ, path |
| 10 | + |
| 11 | + |
| 12 | +PROJECT = 'carepoint' |
| 13 | +SHORT_DESC = ( |
| 14 | + 'This library will allow you to interact with a remote CarePoint ' |
| 15 | + 'instance using Python.' |
| 16 | +) |
| 17 | +README_FILE = 'README.rst' |
| 18 | + |
| 19 | +version = environ.get('RELEASE') or environ.get('VERSION') or '0.0.0' |
| 20 | + |
| 21 | +if environ.get('TRAVIS_BUILD_NUMBER'): |
| 22 | + version += 'b%s' % environ.get('TRAVIS_BUILD_NUMBER') |
8 | 23 |
|
9 | 24 |
|
10 | 25 | setup_vals = { |
11 | | - 'name': 'carepoint', |
12 | | - 'version': '0.1.8', |
| 26 | + 'name': PROJECT, |
13 | 27 | 'author': 'LasLabs Inc.', |
14 | 28 | 'author_email': 'support@laslabs.com', |
15 | | - 'description': 'This library will allow you to interact with CarePoint ' |
16 | | - 'using Python.', |
17 | | - 'url': 'https://github.com/laslabs/python-carepoint', |
| 29 | + 'description': SHORT_DESC, |
| 30 | + 'url': 'https://laslabs.github.io/%s' % PROJECT, |
| 31 | + 'download_url': 'https://github.com/LasLabs/%s' % PROJECT, |
18 | 32 | 'license': 'MIT', |
19 | 33 | 'classifiers': [ |
20 | 34 | 'Development Status :: 4 - Beta', |
|
26 | 40 | 'Programming Language :: Python', |
27 | 41 | 'Topic :: Software Development :: Libraries :: Python Modules', |
28 | 42 | ], |
| 43 | + 'version': version, |
29 | 44 | } |
30 | 45 |
|
31 | 46 |
|
32 | | -setup( |
33 | | - packages=find_packages(exclude=('tests')), |
34 | | - cmdclass={'test': Tests}, |
35 | | - tests_require=[ |
36 | | - 'xmlrunner', |
37 | | - 'mock', |
38 | | - ], |
39 | | - install_requires=[ |
40 | | - 'enum34', |
41 | | - 'pyodbc', |
42 | | - 'pysmb', |
43 | | - 'sqlalchemy', |
44 | | - ], |
45 | | - **setup_vals |
46 | | -) |
| 47 | +if path.exists(README_FILE): |
| 48 | + with open(README_FILE) as fh: |
| 49 | + setup_vals['long_description'] = fh.read() |
| 50 | + |
| 51 | + |
| 52 | +install_requires = [] |
| 53 | +if path.exists('requirements.txt'): |
| 54 | + with open('requirements.txt') as fh: |
| 55 | + install_requires = fh.read().splitlines() |
| 56 | + |
| 57 | + |
| 58 | +class FailTestException(Exception): |
| 59 | + """ It provides a failing build """ |
| 60 | + pass |
| 61 | + |
| 62 | + |
| 63 | +class Tests(Command): |
| 64 | + ''' Run test & coverage, save reports as XML ''' |
| 65 | + |
| 66 | + user_options = [] # < For Command API compatibility |
| 67 | + |
| 68 | + def initialize_options(self, ): |
| 69 | + pass |
| 70 | + |
| 71 | + def finalize_options(self, ): |
| 72 | + pass |
| 73 | + |
| 74 | + def run(self, ): |
| 75 | + loader = TestLoader() |
| 76 | + tests = loader.discover('.', 'test_*.py') |
| 77 | + t = TextTestRunner(verbosity=1) |
| 78 | + res = t.run(tests) |
| 79 | + if not res.wasSuccessful(): |
| 80 | + raise FailTestException() |
| 81 | + |
| 82 | +if __name__ == "__main__": |
| 83 | + setup( |
| 84 | + packages=find_packages(exclude=('tests')), |
| 85 | + cmdclass={'test': Tests}, |
| 86 | + tests_require=[ |
| 87 | + 'mock', |
| 88 | + ], |
| 89 | + install_requires=install_requires, |
| 90 | + **setup_vals |
| 91 | + ) |
0 commit comments