Skip to content

Commit f12b6d8

Browse files
authored
Merge pull request #161 from p1c2u/feature/setup-config-refactor
Setup config file
2 parents df5fbe7 + ffce1ab commit f12b6d8

File tree

3 files changed

+103
-54
lines changed

3 files changed

+103
-54
lines changed

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.EXPORT_ALL_VARIABLES:
2+
3+
PROJECT_NAME=openapi-core
4+
PACKAGE_NAME=$(subst -,_,${PROJECT_NAME})
5+
VERSION=`git describe --abbrev=0`
6+
7+
PYTHONDONTWRITEBYTECODE=1
8+
9+
params:
10+
@echo "Project name: ${PROJECT_NAME}"
11+
@echo "Package name: ${PACKAGE_NAME}"
12+
@echo "Version: ${VERSION}"
13+
14+
dist-build:
15+
@python setup.py bdist_wheel
16+
17+
dist-cleanup:
18+
@rm -rf build dist ${PACKAGE_NAME}.egg-info
19+
20+
dist-upload:
21+
@twine upload dist/*.whl
22+
23+
test-python:
24+
@python setup.py test
25+
26+
test-cache-cleanup:
27+
@rm -rf .pytest_cache
28+
29+
reports-cleanup:
30+
@rm -rf reports
31+
32+
test-cleanup: test-cache-cleanup reports-cleanup
33+
34+
cleanup: dist-cleanup test-cleanup

setup.cfg

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[metadata]
2+
name = openapi-core
3+
long_description = file: README.rst
4+
long-description-content-type = text/x-rst; charset=UTF-8
5+
keywords = openapi, swagger, schema
6+
classifiers =
7+
Development Status :: 4 - Beta
8+
Intended Audience :: Developers
9+
Topic :: Software Development :: Libraries :: Python Modules
10+
Operating System :: OS Independent
11+
Programming Language :: Python :: 2.7
12+
Programming Language :: Python :: 3.5
13+
Programming Language :: Python :: 3.6
14+
Programming Language :: Python :: 3.7
15+
Topic :: Software Development :: Libraries
16+
17+
[options]
18+
include_package_data = True
19+
packages = find:
20+
zip_safe = False
21+
test_suite = tests
22+
python_requires = >= 2.7, != 3.0.*, != 3.1.*, != 3.2.*, != 3.3.*, != 3.4.*
23+
setup_requires =
24+
setuptools
25+
install_requires =
26+
openapi-spec-validator
27+
six
28+
lazy-object-proxy
29+
strict_rfc3339
30+
isodate
31+
attrs
32+
backports.functools-lru-cache; python_version<"3.0"
33+
backports.functools-partialmethod; python_version<"3.0"
34+
tests_require =
35+
mock; python_version<"3.0"
36+
pytest
37+
pytest-flake8
38+
pytest-cov
39+
flask
40+
41+
[options.packages.find]
42+
exclude =
43+
tests
44+
45+
[options.extras_require]
46+
flask = werkzeug
47+
48+
[tool:pytest]
49+
addopts = -sv --flake8 --junitxml reports/junit.xml --cov openapi_core --cov-report term-missing --cov-report xml:reports/coverage.xml tests

setup.py

Lines changed: 20 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
#!/usr/bin/env python
12
"""OpenAPI core setup module"""
23
import os
34
import re
45
import 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

1616
def 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-
3328
class 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):
5944
metadata = 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

Comments
 (0)