1import re
2from setuptools import setup, find_packages
3
4EXTRAS_REQUIRE = {
5    "marshmallow": ["marshmallow>=3.13.0"],
6    "yaml": ["PyYAML>=3.10"],
7    "validation": ["prance[osv]>=0.11"],
8    "lint": ["flake8==3.9.2", "flake8-bugbear==21.9.1", "pre-commit~=2.4"],
9    "docs": [
10        "marshmallow>=3.13.0",
11        "pyyaml==5.4.1",
12        "sphinx==4.2.0",
13        "sphinx-issues==1.2.0",
14        "sphinx-rtd-theme==1.0.0",
15    ],
16}
17EXTRAS_REQUIRE["tests"] = (
18    EXTRAS_REQUIRE["yaml"]
19    + EXTRAS_REQUIRE["validation"]
20    + ["marshmallow>=3.13.0", "pytest", "mock"]
21)
22EXTRAS_REQUIRE["dev"] = EXTRAS_REQUIRE["tests"] + EXTRAS_REQUIRE["lint"] + ["tox"]
23
24
25def find_version(fname):
26    """Attempts to find the version number in the file names fname.
27    Raises RuntimeError if not found.
28    """
29    version = ""
30    with open(fname) as fp:
31        reg = re.compile(r'__version__ = [\'"]([^\'"]*)[\'"]')
32        for line in fp:
33            m = reg.match(line)
34            if m:
35                version = m.group(1)
36                break
37    if not version:
38        raise RuntimeError("Cannot find version information.")
39    return version
40
41
42def read(fname):
43    with open(fname) as fp:
44        content = fp.read()
45    return content
46
47
48setup(
49    name="apispec",
50    version=find_version("src/apispec/__init__.py"),
51    description="A pluggable API specification generator. Currently supports the "
52    "OpenAPI Specification (f.k.a. the Swagger specification).",
53    long_description=read("README.rst"),
54    author="Steven Loria",
55    author_email="sloria1@gmail.com",
56    url="https://github.com/marshmallow-code/apispec",
57    packages=find_packages("src"),
58    package_dir={"": "src"},
59    include_package_data=True,
60    extras_require=EXTRAS_REQUIRE,
61    license="MIT",
62    zip_safe=False,
63    keywords="apispec swagger openapi specification oas documentation spec rest api",
64    python_requires=">=3.6",
65    classifiers=[
66        "License :: OSI Approved :: MIT License",
67        "Programming Language :: Python :: 3",
68        "Programming Language :: Python :: 3.6",
69        "Programming Language :: Python :: 3.7",
70        "Programming Language :: Python :: 3.8",
71        "Programming Language :: Python :: 3.9",
72        "Programming Language :: Python :: 3 :: Only",
73    ],
74    test_suite="tests",
75    project_urls={
76        "Funding": "https://opencollective.com/marshmallow",
77        "Issues": "https://github.com/marshmallow-code/apispec/issues",
78        "Tidelift": "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-apispec&utm_medium=pypi",  # noqa: B950,E501
79    },
80)
81