Skip to content

Commit

Permalink
[PR #7808/213d1b2 backport][3.9] Restore requirements-txt-fixer in pr…
Browse files Browse the repository at this point in the history
…e-commit (#7920)

Backport of #7808 cherry picked
from commit 213d1b2
  • Loading branch information
alexrudd2 authored Nov 29, 2023
1 parent 0bc17e6 commit ee8f7bf
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 16 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 @@ -182,7 +182,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
12 changes: 6 additions & 6 deletions requirements/runtime-deps.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Extracted from `setup.cfg` via `make sync-direct-runtime-deps`

attrs >= 17.3.0
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; sys_platform=="linux" or sys_platform=="darwin"
aiosignal >= 1.1.2
async-timeout >= 4.0, < 5.0 ; python_version < "3.11"
attrs >= 17.3.0
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,12 +47,12 @@ zip_safe = False
include_package_data = True

install_requires =
aiosignal >= 1.1.2
attrs >= 17.3.0
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
multidict >=4.5, < 7.0
yarl >= 1.0, < 2.0

[options.exclude_package_data]
* =
Expand Down

0 comments on commit ee8f7bf

Please sign in to comment.