Skip to content

Commit

Permalink
Restore requirements-txt-fixer in pre-commit (#7808)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudd2 committed Nov 27, 2023
1 parent 2a3eaa1 commit 213d1b2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ repos:
exclude: >-
^docs/[^/]*\.svg$
- id: requirements-txt-fixer
exclude: >-
^requirements/.*\.txt$
files: requirements/.*\.in$
- id: trailing-whitespace
- id: file-contents-sorter
args: ['--ignore-case']
Expand Down
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,4 @@ install-dev: .develop
.PHONY: sync-direct-runtime-deps
sync-direct-runtime-deps:
@echo Updating 'requirements/runtime-deps.in' from 'setup.cfg'... >&2
@echo '# Extracted from `setup.cfg` via `make sync-direct-runtime-deps`' > requirements/runtime-deps.in
@echo >> requirements/runtime-deps.in
@python -c 'from configparser import ConfigParser; from itertools import chain; from pathlib import Path; cfg = ConfigParser(); cfg.read_string(Path("setup.cfg").read_text()); print("\n".join(line.strip() for line in chain(cfg["options"].get("install_requires").splitlines(), "\n".join(cfg["options.extras_require"].values()).splitlines()) if line.strip()))' \
>> requirements/runtime-deps.in
@python requirements/sync-direct-runtime-deps.py
10 changes: 5 additions & 5 deletions requirements/runtime-deps.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Extracted from `setup.cfg` via `make sync-direct-runtime-deps`

multidict >=4.5, < 7.0
async-timeout >= 4.0, < 5.0 ; python_version < "3.11"
yarl >= 1.0, < 2.0
frozenlist >= 1.1.1
aiosignal >= 1.1.2
aiodns >= 1.1; sys_platform=="linux" or sys_platform=="darwin"
aiosignal >= 1.1.2
async-timeout >= 4.0, < 5.0 ; python_version < "3.11"
Brotli; platform_python_implementation == 'CPython'
brotlicffi; platform_python_implementation != 'CPython'
frozenlist >= 1.1.1
multidict >=4.5, < 7.0
yarl >= 1.0, < 2.0
16 changes: 16 additions & 0 deletions requirements/sync-direct-runtime-deps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python
"""Sync direct runtime dependencies from setup.cfg to runtime-deps.in."""

from configparser import ConfigParser
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("")

with open(Path("requirements", "runtime-deps.in"), "w") as outfile:
header = "# Extracted from `setup.cfg` via `make sync-direct-runtime-deps`\n\n"
outfile.write(header)
outfile.write("\n".join(reqs) + "\n")
2 changes: 1 addition & 1 deletion requirements/test.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r base.in
-c broken-projects.in
-r base.in

coverage
mypy; implementation_name == "cpython"
Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ zip_safe = False
include_package_data = True

install_requires =
multidict >=4.5, < 7.0
aiosignal >= 1.1.2
async-timeout >= 4.0, < 5.0 ; python_version < "3.11"
yarl >= 1.0, < 2.0
frozenlist >= 1.1.1
aiosignal >= 1.1.2
multidict >=4.5, < 7.0
yarl >= 1.0, < 2.0

[options.exclude_package_data]
* =
Expand Down

0 comments on commit 213d1b2

Please sign in to comment.