Skip to content

Commit

Permalink
Fix sync-direct-runtime-deps script
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Nov 19, 2024
1 parent 8f80fdc commit 51bb1d2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,5 @@ install-dev: .develop

.PHONY: sync-direct-runtime-deps
sync-direct-runtime-deps:
@echo Updating 'requirements/runtime-deps.in' from 'setup.cfg'... >&2
@echo Updating 'requirements/runtime-deps.in' from 'pyproject.toml'... >&2
@python requirements/sync-direct-runtime-deps.py
1 change: 1 addition & 0 deletions requirements/lint.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pytest-mock
pytest_codspeed
python-on-whales
slotscheck
tomli; python_version < '3.11'
trustme
uvloop; platform_system != "Windows"
valkey
1 change: 1 addition & 0 deletions requirements/lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ slotscheck==0.19.1
# via -r requirements/lint.in
tomli==2.0.2
# via
# -r requirements/lint.in
# mypy
# pytest
# slotscheck
Expand Down
6 changes: 3 additions & 3 deletions requirements/runtime-deps.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Extracted from `setup.cfg` via `make sync-direct-runtime-deps`
# Extracted from `pyproject.toml` via `make sync-direct-runtime-deps`

aiodns >= 3.2.0; sys_platform=="linux" or sys_platform=="darwin"
aiodns >= 3.2.0; sys_platform=='linux' or sys_platform=='darwin'
aiohappyeyeballs >= 2.3.0
aiosignal >= 1.1.2
async-timeout >= 4.0, < 6.0 ; python_version < "3.11"
async-timeout >= 4.0, < 6.0 ; python_version < '3.11'
Brotli; platform_python_implementation == 'CPython'
brotlicffi; platform_python_implementation != 'CPython'
frozenlist >= 1.1.1
Expand Down
22 changes: 14 additions & 8 deletions requirements/sync-direct-runtime-deps.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
#!/usr/bin/env python
"""Sync direct runtime dependencies from setup.cfg to runtime-deps.in."""
"""Sync direct runtime dependencies from pyproject.toml to runtime-deps.in."""

from configparser import ConfigParser
import sys
from pathlib import Path

cfg = ConfigParser()
cfg.read(Path("setup.cfg"))
reqs = cfg["options"]["install_requires"] + cfg.items("options.extras_require")[0][1]
reqs = sorted(reqs.split("\n"), key=str.casefold)
reqs.remove("")
if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib

data = tomllib.loads(Path("pyproject.toml").read_text())
reqs = (
data["project"]["dependencies"]
+ data["project"]["optional-dependencies"]["speedups"]
)
reqs = sorted(reqs, key=str.casefold)

with open(Path("requirements", "runtime-deps.in"), "w") as outfile:
header = "# Extracted from `setup.cfg` via `make sync-direct-runtime-deps`\n\n"
header = "# Extracted from `pyproject.toml` via `make sync-direct-runtime-deps`\n\n"
outfile.write(header)
outfile.write("\n".join(reqs) + "\n")

0 comments on commit 51bb1d2

Please sign in to comment.