11# -*- coding: utf-8 -*-
2+ """OpenAPI spec validator setup module"""
23import os
34import re
45import sys
5-
6- from setuptools import find_packages , setup
7- from setuptools .command .test import test as TestCommand
6+ try :
7+ from setuptools import setup
8+ except ImportError :
9+ from ez_setup import use_setuptools
10+ use_setuptools ()
11+ from setuptools import setup
12+ finally :
13+ from setuptools .command .test import test as TestCommand
814
915
1016def read_file (filename ):
@@ -20,85 +26,30 @@ def get_metadata(init_file):
2026
2127
2228class PyTest (TestCommand ):
23-
2429 """Command to run unit tests after in-place build."""
2530
2631 def finalize_options (self ):
2732 TestCommand .finalize_options (self )
28- self .test_args = [
29- '-sv' ,
30- '--flake8' ,
31- '--junitxml' , 'reports/junit.xml' ,
32- '--cov' , 'openapi_spec_validator' ,
33- '--cov-report' , 'term-missing' ,
34- '--cov-report' , 'xml:reports/coverage.xml' ,
35- ]
36- self .test_suite = True
33+ self .pytest_args = []
3734
3835 def run_tests (self ):
3936 # Importing here, `cause outside the eggs aren't loaded.
4037 import pytest
41- errno = pytest .main (self .test_args )
38+ errno = pytest .main (self .pytest_args )
4239 sys .exit (errno )
4340
4441
4542init_path = os .path .join ('openapi_spec_validator' , '__init__.py' )
4643init_py = read_file (init_path )
4744metadata = get_metadata (init_py )
4845
49-
50- setup (
51- name = 'openapi-spec-validator' ,
52- version = metadata ['version' ],
53- author = metadata ['author' ],
54- author_email = metadata ['email' ],
55- url = metadata ['url' ],
56- license = metadata ['license' ],
57- description = 'OpenAPI 2.0 (aka Swagger) and OpenAPI 3.0.0 spec validator' ,
58- long_description = read_file ('README.md' ),
59- long_description_content_type = 'text/markdown' ,
60- packages = find_packages (include = ('openapi_spec_validator*' ,)),
61- package_data = {
62- 'openapi_spec_validator' : [
63- 'openapi_spec_validator/resources/schemas/v3.0.0/*' ,
64- 'openapi_spec_validator/resources/schemas/v2.0/*' ,
65- ],
66- },
67- include_package_data = True ,
68- entry_points = {
69- 'console_scripts' : [
70- 'openapi-spec-validator = openapi_spec_validator.__main__:main'
71- ]
72- },
73- install_requires = [
74- "jsonschema" ,
75- "PyYAML>=5.1" ,
76- "six" ,
77- 'pathlib2;python_version=="2.7"' ,
78- ],
79- extras_require = {
80- 'dev' : [
81- 'pre-commit'
82- ]
83- },
84- tests_require = [
85- "mock" ,
86- "pytest" ,
87- "pytest-flake8" ,
88- "pytest-cov" ,
89- "tox" ,
90- ],
91- cmdclass = {'test' : PyTest },
92- classifiers = [
93- "Development Status :: 4 - Beta" ,
94- "Intended Audience :: Developers" ,
95- "Topic :: Software Development :: Libraries :: Python Modules" ,
96- "Operating System :: OS Independent" ,
97- "Programming Language :: Python :: 2.7" ,
98- "Programming Language :: Python :: 3.5" ,
99- "Programming Language :: Python :: 3.6" ,
100- "Programming Language :: Python :: 3.7" ,
101- "Programming Language :: Python :: 3.8" ,
102- "Programming Language :: Python :: 3.9" ,
103- ],
104- )
46+ if __name__ == '__main__' :
47+ setup (
48+ version = metadata ['version' ],
49+ author = metadata ['author' ],
50+ author_email = metadata ['email' ],
51+ url = metadata ['url' ],
52+ license = metadata ['license' ],
53+ cmdclass = {'test' : PyTest },
54+ setup_cfg = True ,
55+ )
0 commit comments