-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.py
139 lines (125 loc) · 5.09 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import logging
import os
import sys
from typing import Set
from setuptools import find_packages, setup
CUR_DIR = os.path.abspath(os.path.dirname(__file__))
LONG_DESCRIPTION = None
if all(os.path.isfile(os.path.join(CUR_DIR, f)) for f in ["README.rst", "CHANGES.rst"]):
README = open(os.path.join(CUR_DIR, "README.rst")).read()
CHANGES = open(os.path.join(CUR_DIR, "CHANGES.rst")).read()
LONG_DESCRIPTION = f"{README}\n\n{CHANGES}"
# ensure that 'weaver' directory can be found for metadata import
sys.path.insert(0, CUR_DIR)
sys.path.insert(0, os.path.join(CUR_DIR, os.path.split(CUR_DIR)[-1]))
# pylint: disable=C0413,wrong-import-order
from weaver import __meta__ # isort:skip # noqa: E402
# pylint: disable=C0209,consider-using-f-string
LOGGER = logging.getLogger(f"{__meta__.__name__}.setup")
if logging.StreamHandler not in LOGGER.handlers:
LOGGER.addHandler(logging.StreamHandler(sys.stdout)) # type: ignore # noqa
LOGGER.setLevel(logging.INFO)
LOGGER.info("starting setup")
with open("README.rst") as readme_file:
README = readme_file.read()
with open("CHANGES.rst") as changes_file:
CHANGES = changes_file.read().replace(".. :changelog:", "")
def _parse_requirements(file_path, requirements, links):
# type: (str, Set[str], Set[str]) -> None
"""
Parses a requirements file to extra packages and links.
:param file_path: file path to the requirements file.
:param requirements: pre-initialized set in which to store extracted package requirements.
:param links: pre-initialized set in which to store extracted link reference requirements.
"""
with open(file_path, "r") as requirements_file:
for line in requirements_file:
# ignore empty line, comment line or reference to other requirements file (-r flag)
if not line or line.startswith("#") or line.startswith("-"):
continue
if "git+https" in line:
pkg = line.split("#")[-1]
links.add(line.strip())
requirements.add(pkg.replace("egg=", "").rstrip())
elif line.startswith("http"):
links.add(line.strip())
else:
requirements.add(line.strip())
LOGGER.info("reading requirements")
# See https://github.com/pypa/pip/issues/3610
# use set to have unique packages by name
LINKS = set()
REQUIREMENTS = set()
DOCS_REQUIREMENTS = set()
TEST_REQUIREMENTS = set()
_parse_requirements("requirements.txt", REQUIREMENTS, LINKS)
_parse_requirements("requirements-doc.txt", DOCS_REQUIREMENTS, LINKS)
_parse_requirements("requirements-dev.txt", TEST_REQUIREMENTS, LINKS)
LINKS = list(LINKS)
REQUIREMENTS = list(REQUIREMENTS)
LOGGER.info("base requirements: %s", REQUIREMENTS)
LOGGER.info("docs requirements: %s", DOCS_REQUIREMENTS)
LOGGER.info("test requirements: %s", TEST_REQUIREMENTS)
LOGGER.info("link requirements: %s", LINKS)
setup(
name=__meta__.__name__,
version=__meta__.__version__,
description=__meta__.__description__,
long_description=LONG_DESCRIPTION,
long_description_content_type="text/x-rst",
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
"Framework :: Celery",
"Framework :: Paste",
"Framework :: Pyramid",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
__meta__.__license_classifier__,
"Natural Language :: English",
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
"Topic :: Scientific/Engineering :: Atmospheric Science",
"Topic :: Scientific/Engineering :: GIS",
"Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator",
"Topic :: System :: Distributed Computing",
],
author=__meta__.__author__,
author_email=", ".join(__meta__.__emails__),
url=__meta__.__source_repository__,
download_url=__meta__.__docker_repository__,
license=__meta__.__license_type__,
keywords=" ".join(__meta__.__keywords__),
packages=find_packages(),
include_package_data=True,
package_data={"": ["*.mako"]},
zip_safe=False,
test_suite="tests",
python_requires=">=3.7, <4",
install_requires=REQUIREMENTS,
dependency_links=LINKS,
extras_require={
"docs": DOCS_REQUIREMENTS,
"dev": TEST_REQUIREMENTS,
"test": TEST_REQUIREMENTS,
},
entry_points={
"paste.app_factory": [
f"main = {__meta__.__name__}:main"
],
"console_scripts": [
"{0} = {0}.cli:main".format(__meta__.__name__)
]
}
)