-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyproject.toml
230 lines (207 loc) · 7.3 KB
/
pyproject.toml
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools"]
[project]
authors = [
{ name = "ticdenis", email = "navarrodenis940503@outlook.com" },
{ name = "yasti4", email = "adria_4_@hotmail.com" },
]
maintainers = [
{ name = "ticdenis", email = "navarrodenis940503@outlook.com" }
]
classifiers = [
"Intended Audience :: Information Technology",
"Intended Audience :: System Administrators",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development",
"Typing :: Typed",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = []
description = "Simple and lightweight async console runner."
dynamic = ["version"]
keywords = ["asyncio", "async", "aio", "cli", "console"]
license = { text = "MIT" }
name = "aiocli"
readme = "README.md"
requires-python = ">=3.9"
[project.optional-dependencies]
dev = [
"pre-commit>=3.8.0",
'tomli>=2.0.1; python_version<"3.11"',
'types-toml>=0.10.8.20240310; python_version<"3.11"',
]
deploy = [
"build>=1.2.2",
"setuptools>=75.1.0",
"twine>=5.1.1",
"wheel>=0.44.0",
]
docs = [
"mkdocs>=1.6.1",
"mkdocs-material>=9.5.37",
]
fmt = [
"black>=24.8.0",
"isort>=5.13.2",
]
security-analysis = [
"bandit>=1.7.4",
"liccheck>=0.9.2",
"setuptools>=75.1.0", # https://github.com/dhatim/python-license-check/issues/114
]
static-analysis = [
"mypy>=1.11.2",
"pylint>=3.3.1",
]
test = [
"nest-asyncio>=1.6.0",
"psutil>=6.0.0",
"pytest>=8.3.3",
"pytest-asyncio>=0.24.0",
"pytest-cov>=5.0.0",
"pytest-xdist>=3.6.1",
]
[project.urls]
"documentation" = "https://aiopy.github.io/python-aiocli/"
"repository" = "https://github.com/aiopy/python-aiocli"
[tool.setuptools.dynamic]
version = { attr = "aiocli.__version__" }
[tool.setuptools.packages.find]
include = ["aiocli*"]
[tool.setuptools.package-data]
"aiocli" = ["py.typed"]
[tool.bandit]
exclude_dirs = ["docs", "docs_src", "sample", "var"]
skips = ["B101", "B311"]
[tool.black]
include = '\.pyi?$'
line-length = 120
skip-string-normalization = true
[tool.coverage.paths]
source = ["aiocli"]
[tool.coverage.run]
data_file = "var/coverage/.coverage"
disable_warnings = ["no-data-collected"]
source = ["tests"]
[tool.coverage.report]
fail_under = 70
[tool.coverage.html]
directory = "var/coverage"
[tool.isort]
profile = "black"
[tool.liccheck]
authorized_licenses = []
no_deps = true
dependencies = true
[tool.mypy]
strict = true
cache_dir = "var/mypy"
[tool.pylint.master]
jobs = "0"
[tool.pylint.messages_control]
disable = "C0103,C0114,C0115,C0116,C0205,C0209,C0301,E0401,E0611,E1135,E1136,R0801,R0902,R0903,R0904,R0913,R0914,R0917,R1704,R1725,R1731,W0108,W0212,W0235,W0236,W0603,W0611,W0622,W0703,W0707,W1202"
[tool.pytest.ini_options]
asyncio_default_fixture_loop_scope = "function"
asyncio_mode = "auto"
cache_dir = "var/pytest"
addopts = "-q -n auto -p no:warnings --no-cov-on-fail"
testpaths = ["tests"]
[tool.run-script]
install = "python3 -m pip install ."
dev-install = "python3 -m pip install .[dev,deploy,docs,fmt,security-analysis,static-analysis,test]"
deploy = "python3 -m build --no-isolation && python3 -m twine upload dist/*"
docs = "python3 -m mkdocs build -f docs_src/config/en/mkdocs.yml && python3 -m mkdocs build -f docs_src/config/es/mkdocs.yml"
dev-docs = "python3 -m mkdocs serve -f docs_src/config/en/mkdocs.yml"
fmt = "python3 -m black aiocli tests && python3 -m isort aiocli tests"
security-analysis = "python3 -m liccheck && python3 -m bandit -r -c pyproject.toml aiocli tests"
static-analysis = "python3 -m mypy aiocli && python3 -m pylint aiocli"
test = "python3 -m pytest"
unit-tests = "python3 -m pytest tests/unit"
integration-tests = "python3 -m pytest tests/integration"
functional-tests = "python3 -m pytest tests/functional"
coverage = "python3 -m pytest --cov --cov-report=html"
clean = """python3 -c \"
from glob import iglob
from shutil import rmtree
for pathname in ['./build', './*.egg-info', './dist', './var', '**/__pycache__']:
for path in iglob(pathname, recursive=True):
rmtree(path, ignore_errors=True)
\""""
check-dependency-update = """python3 -c \"
from contextlib import suppress
from json import loads
from re import match
try:
from tomllib import load # Python 3.11+
except ModuleNotFoundError:
try:
from tomli import load
except ModuleNotFoundError:
from subprocess import run
run(['python3 -m pip install -U tomli'], stdout=-3, shell=True)
from tomli import load
from urllib.request import urlopen
def get_latest_version(package_name, pypi_url = 'https://pypi.org'):
with suppress(Exception), urlopen(f'{pypi_url}/pypi/{package_name}/json') as res:
return loads(res.read().decode()).get('info', {}).get('version')
def parse_dependency(dep):
result = match(r'([a-zA-Z0-9_-]+)(\\[.*\\])?(?:([<>=!~]+)(.+))?', dep)
return result.groups() if result else (dep, '', '', '')
def compare_deps(deps):
for pkg, extras, op, ver in [parse_dependency(dep) for dep in deps]:
if pkg and op and ver and (last := get_latest_version(pkg)):
if (op == '==' and ver != last) or (op == '>=' and last > ver) or (op == '<=' and last < ver):
yield (pkg + (extras or '') + ' (Current: ' + ver + ', Latest: ' + last + ')')
with open('pyproject.toml', 'rb') as f:
pyproject = load(f).get('project', {})
deps = compare_deps(pyproject.get('dependencies', []))
opt_deps = {group: compare_deps(deps) for group, deps in pyproject.get('optional-dependencies', {}).items()}
parsed_deps = '\\n'.join(deps)
parsed_opt_deps = [(f'[{opt_dep_group}]\\n', '\\n'.join(opt_deps[opt_dep_group])) for opt_dep_group in opt_deps]
if not parsed_deps and not (''.join([v for _, v in parsed_opt_deps])):
print('Already up-to-date.')
else:
print('# pyproject.toml\\n[project.dependencies]\\n{0}\\n[project.optional-dependencies]{1}'.format(parsed_deps, ''.join([k + v for k, v in parsed_opt_deps])))
exit(1)
\""""
dev-server = """python3 -c \"
from asyncio import CancelledError, TimeoutError as AsyncTimeoutError, get_event_loop, sleep, wait_for
from contextlib import suppress
from signal import SIGHUP, SIGINT, SIGTERM
async def development_server(timeout: int) -> None:
retry = True
async def _check() -> None:
if not retry:
return
while retry:
await sleep(1)
try:
print('Development server running...', '')
await wait_for(fut=_check(), timeout=timeout)
except (TimeoutError, AsyncTimeoutError):
pass
finally:
retry = False
async def run_development_server(timeout: int) -> None:
loop = get_event_loop() # lazy
coro = development_server(timeout)
task = loop.create_task(coro)
_ = [loop.add_signal_handler(sig, task.cancel) for sig in (SIGHUP, SIGTERM, SIGINT)]
with suppress(CancelledError):
await task
if __name__ >= '__main__':
get_event_loop().run_until_complete(run_development_server(timeout=3600)) # 1h
\""""