forked from python-openapi/openapi-spec-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
88 lines (74 loc) · 2.34 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
# -*- coding: utf-8 -*-
import os
import re
import sys
from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand
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',
'--cov', 'openapi_spec_validator',
'--cov-report', 'term-missing',
]
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_spec_validator', '__init__.py')
init_py = read_file(init_path)
metadata = get_metadata(init_py)
setup(
name='openapi-spec-validator',
version=metadata['version'],
author=metadata['author'],
author_email=metadata['email'],
url=metadata['url'],
license=metadata['license'],
long_description=read_file('README.md'),
packages=find_packages(include=('openapi_spec_validator*',)),
package_data={
'openapi_spec_validator': [
'openapi_spec_validator/resources/schemas/v3.0.0/*',
],
},
include_package_data=True,
install_requires=[
"jsonschema",
"pyaml",
"six",
],
tests_require=[
"mock",
"pytest",
"pytest-pep8",
"pytest-flakes",
"pytest-cov",
"tox",
],
cmdclass={'test': PyTest},
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
],
)