-
Notifications
You must be signed in to change notification settings - Fork 440
/
setup.py
executable file
·107 lines (84 loc) · 3.54 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import io
import os
import sys
from setuptools import find_packages, setup
def read_req(req_file):
with open(os.path.join('requirements', req_file)) as req:
return [line.strip() for line in req.readlines() if line.strip() and not line.strip().startswith('#')]
with io.open('README.rst', encoding='utf-8') as readme:
description = readme.read()
requirements = read_req('base.txt')
requirements_validation = read_req('validation.txt')
def find_versions_from_readme(prefix):
for line in description.splitlines():
line = line.strip()
if line.startswith(prefix):
versions = [v.strip() for v in line[len(prefix):].split(',')]
if versions:
return versions
raise RuntimeError("failed to find supported versions list for '{}'".format(prefix))
python_versions = find_versions_from_readme("- **Python**: ")
django_versions = find_versions_from_readme("- **Django**: ")
python_requires = ">=" + python_versions[0]
python_classifiers = [
'Programming Language :: Python',
'Programming Language :: Python :: 3',
] + ['Programming Language :: Python :: {}'.format(v) for v in python_versions]
django_classifiers = [
'Framework :: Django',
] + ['Framework :: Django :: {}'.format(v) for v in django_versions]
def drf_yasg_setup(**kwargs):
setup(
name='drf-yasg',
packages=find_packages('src'),
package_dir={'': 'src'},
include_package_data=True,
install_requires=requirements,
extras_require={
'validation': requirements_validation,
'coreapi': ['coreapi>=2.3.3', 'coreschema>=0.0.4']
},
license='BSD License',
description='Automated generation of real Swagger/OpenAPI 2.0 schemas from Django Rest Framework code.',
long_description=description,
long_description_content_type='text/x-rst',
url='https://github.com/axnsan12/drf-yasg',
author='Cristi V.',
author_email='cristi@cvjd.me',
keywords='drf django django-rest-framework schema swagger openapi codegen swagger-codegen '
'documentation drf-yasg django-rest-swagger drf-openapi',
python_requires=python_requires,
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Development Status :: 5 - Production/Stable',
'Operating System :: OS Independent',
'Environment :: Web Environment',
'Topic :: Documentation',
'Topic :: Software Development :: Code Generators',
] + python_classifiers + django_classifiers,
**kwargs
)
try:
# noinspection PyUnresolvedReferences
import setuptools_scm # noqa: F401
drf_yasg_setup(use_scm_version=True)
except (ImportError, LookupError) as e:
if os.getenv('CI', 'false') == 'true':
# don't silently fail on CI - we don't want to accidentally push a dummy version to PyPI
raise
err_msg = str(e)
if 'setuptools-scm' in err_msg or 'setuptools_scm' in err_msg:
import time
import traceback
timestamp_ms = int(time.time() * 1000)
timestamp_str = hex(timestamp_ms)[2:].zfill(16)
dummy_version = '1!0.0.0.dev0+noscm.' + timestamp_str
drf_yasg_setup(version=dummy_version)
traceback.print_exc(file=sys.stderr)
print("failed to detect version, package was built with dummy version " + dummy_version, file=sys.stderr)
else:
raise