openapi-core/setup.py

87 lines
2.5 KiB
Python
Raw Normal View History

2017-09-21 11:51:37 +00:00
"""OpenAPI core setup module"""
import os
import re
import sys
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
def read_requirements(filename):
"""Open a requirements file and return list of its lines."""
contents = read_file(filename).strip('\n')
return contents.split('\n') if contents else []
def read_file(filename):
"""Open and a file, read it and return its contents."""
path = os.path.join(os.path.dirname(__file__), filename)
with open(path) as f:
return f.read()
def get_metadata(init_file):
"""Read metadata from a given file and return a dictionary of them"""
return dict(re.findall("__([a-z]+)__ = '([^']+)'", init_file))
class PyTest(TestCommand):
"""Command to run unit tests after in-place build."""
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = [
'-sv',
'--pep8',
'--flakes',
'--junitxml', 'reports/junit.xml',
'--cov', 'openapi_core',
'--cov-report', 'term-missing',
'--cov-report', 'xml:reports/coverage.xml',
]
self.test_suite = True
def run_tests(self):
# Importing here, `cause outside the eggs aren't loaded.
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)
init_path = os.path.join('openapi_core', '__init__.py')
init_py = read_file(init_path)
metadata = get_metadata(init_py)
py27 = '_2.7' if sys.version_info < (3,) else ''
2017-09-21 11:51:37 +00:00
setup(
name='openapi-core',
version=metadata['version'],
author=metadata['author'],
author_email=metadata['email'],
url=metadata['url'],
long_description=read_file("README.rst"),
packages=find_packages(include=('openapi_core*',)),
include_package_data=True,
classifiers=[
2017-09-22 09:20:55 +00:00
"Development Status :: 4 - Beta",
2017-09-21 11:51:37 +00:00
'Intended Audience :: Developers',
"Topic :: Software Development :: Libraries :: Python Modules",
"Operating System :: OS Independent",
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.4',
2017-09-21 11:51:37 +00:00
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Software Development :: Libraries',
],
install_requires=read_requirements('requirements{}.txt'.format(py27)),
2017-09-21 11:51:37 +00:00
tests_require=read_requirements('requirements_dev.txt'),
2018-03-02 09:16:49 +00:00
extras_require={
'flask': ["werkzeug"],
},
2017-09-21 11:51:37 +00:00
cmdclass={'test': PyTest},
zip_safe=False,
)