1+ #!/usr/bin/env python
12"""OpenAPI core setup module"""
23import os
34import re
45import sys
5-
6- from setuptools import setup , find_packages
7- from setuptools .command .test import test as TestCommand
8-
9-
10- def read_requirements (filename ):
11- """Open a requirements file and return list of its lines."""
12- contents = read_file (filename ).strip ('\n ' )
13- return contents .split ('\n ' ) if contents else []
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
1414
1515
1616def read_file (filename ):
@@ -25,32 +25,17 @@ def get_metadata(init_file):
2525 return dict (re .findall ("__([a-z]+)__ = '([^']+)'" , init_file ))
2626
2727
28- def install_requires ():
29- py27 = '_2.7' if sys .version_info < (3 ,) else ''
30- return read_requirements ('requirements{}.txt' .format (py27 ))
31-
32-
3328class PyTest (TestCommand ):
34-
3529 """Command to run unit tests after in-place build."""
3630
3731 def finalize_options (self ):
3832 TestCommand .finalize_options (self )
39- self .test_args = [
40- '-sv' ,
41- '--flake8' ,
42- '--junitxml' , 'reports/junit.xml' ,
43- '--cov' , 'openapi_core' ,
44- '--cov-report' , 'term-missing' ,
45- '--cov-report' , 'xml:reports/coverage.xml' ,
46- 'tests' ,
47- ]
48- self .test_suite = True
33+ self .pytest_args = []
4934
5035 def run_tests (self ):
5136 # Importing here, `cause outside the eggs aren't loaded.
5237 import pytest
53- errno = pytest .main (self .test_args )
38+ errno = pytest .main (self .pytest_args )
5439 sys .exit (errno )
5540
5641
@@ -59,31 +44,12 @@ def run_tests(self):
5944metadata = get_metadata (init_py )
6045
6146
62- setup (
63- name = 'openapi-core' ,
64- version = metadata ['version' ],
65- author = metadata ['author' ],
66- author_email = metadata ['email' ],
67- url = metadata ['url' ],
68- long_description = read_file ("README.rst" ),
69- packages = find_packages (include = ('openapi_core*' ,)),
70- include_package_data = True ,
71- classifiers = [
72- "Development Status :: 4 - Beta" ,
73- 'Intended Audience :: Developers' ,
74- "Topic :: Software Development :: Libraries :: Python Modules" ,
75- "Operating System :: OS Independent" ,
76- 'Programming Language :: Python :: 2.7' ,
77- 'Programming Language :: Python :: 3.5' ,
78- 'Programming Language :: Python :: 3.6' ,
79- 'Programming Language :: Python :: 3.7' ,
80- 'Topic :: Software Development :: Libraries' ,
81- ],
82- install_requires = install_requires (),
83- tests_require = read_requirements ('requirements_dev.txt' ),
84- extras_require = {
85- 'flask' : ["werkzeug" ],
86- },
87- cmdclass = {'test' : PyTest },
88- zip_safe = False ,
89- )
47+ if __name__ == '__main__' :
48+ setup (
49+ version = metadata ['version' ],
50+ author = metadata ['author' ],
51+ author_email = metadata ['email' ],
52+ url = metadata ['url' ],
53+ cmdclass = {'test' : PyTest },
54+ setup_cfg = True ,
55+ )
0 commit comments