aiohttp-zip-response 2.4.0__tar.gz → 3.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,33 +1,33 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiohttp-zip-response
3
- Version: 2.4.0
4
- Summary: A AIOHTTP response class streaming a directory as ZIP archive
5
- Project-URL: homepage, https://github.com/DoctorJohn/aiohttp-zip-response
6
- Project-URL: repository, https://github.com/DoctorJohn/aiohttp-zip-response
7
- Project-URL: documentation, https://github.com/DoctorJohn/aiohttp-zip-response
3
+ Version: 3.0.0
4
+ Summary: An AIOHTTP response class streaming a directory as a ZIP archive
5
+ Author: Jonathan Ehwald
8
6
  Author-email: Jonathan Ehwald <github@ehwald.info>
9
- License: MIT
7
+ License-Expression: MIT
10
8
  License-File: LICENSE
11
9
  Classifier: Development Status :: 5 - Production/Stable
12
10
  Classifier: Environment :: Web Environment
13
11
  Classifier: Intended Audience :: Developers
14
- Classifier: License :: OSI Approved :: MIT License
15
12
  Classifier: Operating System :: OS Independent
16
13
  Classifier: Programming Language :: Python
17
14
  Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3.9
19
- Classifier: Programming Language :: Python :: 3.10
20
15
  Classifier: Programming Language :: Python :: 3.11
21
16
  Classifier: Programming Language :: Python :: 3.12
22
17
  Classifier: Programming Language :: Python :: 3.13
23
18
  Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Programming Language :: Python :: 3.15
24
20
  Classifier: Topic :: Internet :: WWW/HTTP
25
21
  Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
26
22
  Classifier: Topic :: Software Development :: Libraries
27
23
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
- Requires-Python: <4.0,>=3.9
29
- Requires-Dist: aiohttp<4.0,>=3.9.5
30
- Requires-Dist: stream-zip<0.1.0,>=0.0.83
24
+ Classifier: Typing :: Typed
25
+ Requires-Dist: aiohttp>=3.9.5,<4.0
26
+ Requires-Dist: stream-zip>=0.0.83,<0.1.0
27
+ Requires-Python: >=3.11, <4.0
28
+ Project-URL: homepage, https://github.com/DoctorJohn/aiohttp-zip-response
29
+ Project-URL: repository, https://github.com/DoctorJohn/aiohttp-zip-response
30
+ Project-URL: documentation, https://github.com/DoctorJohn/aiohttp-zip-response
31
31
  Description-Content-Type: text/markdown
32
32
 
33
33
  # AIOHTTP ZIP Response
@@ -46,7 +46,7 @@ Description-Content-Type: text/markdown
46
46
  [license-image]: https://img.shields.io/pypi/l/aiohttp-zip-response
47
47
  [license-url]: https://github.com/DoctorJohn/aiohttp-zip-response/blob/main/LICENSE
48
48
 
49
- A AIOHTTP response class streaming the contents of a directory as a ZIP archive.
49
+ An AIOHTTP response class streaming the contents of a directory as a ZIP archive.
50
50
  Thanks to [stream-zip](https://github.com/uktrade/stream-zip/), this works **without storing the entire ZIP in memory or disk**.
51
51
 
52
52
  Generally, this package is meant to complement the existing `aiohttp.web.FileResponse` class which can be used to stream the contents of a single file.
@@ -65,11 +65,11 @@ from aiohttp_zip_response import ZipResponse
65
65
 
66
66
 
67
67
  async def handle_zip(request):
68
- return ZipResponse('path/to/directory')
68
+ return ZipResponse("path/to/directory")
69
69
 
70
70
 
71
71
  app = web.Application()
72
- app.router.add_get('/zip', handle_zip)
72
+ app.router.add_get("/zip", handle_zip)
73
73
  web.run_app(app)
74
74
  ```
75
75
 
@@ -14,7 +14,7 @@
14
14
  [license-image]: https://img.shields.io/pypi/l/aiohttp-zip-response
15
15
  [license-url]: https://github.com/DoctorJohn/aiohttp-zip-response/blob/main/LICENSE
16
16
 
17
- A AIOHTTP response class streaming the contents of a directory as a ZIP archive.
17
+ An AIOHTTP response class streaming the contents of a directory as a ZIP archive.
18
18
  Thanks to [stream-zip](https://github.com/uktrade/stream-zip/), this works **without storing the entire ZIP in memory or disk**.
19
19
 
20
20
  Generally, this package is meant to complement the existing `aiohttp.web.FileResponse` class which can be used to stream the contents of a single file.
@@ -33,11 +33,11 @@ from aiohttp_zip_response import ZipResponse
33
33
 
34
34
 
35
35
  async def handle_zip(request):
36
- return ZipResponse('path/to/directory')
36
+ return ZipResponse("path/to/directory")
37
37
 
38
38
 
39
39
  app = web.Application()
40
- app.router.add_get('/zip', handle_zip)
40
+ app.router.add_get("/zip", handle_zip)
41
41
  web.run_app(app)
42
42
  ```
43
43
 
@@ -1,6 +1,6 @@
1
+ from collections.abc import AsyncGenerator
1
2
  from datetime import datetime
2
3
  from pathlib import Path
3
- from typing import AsyncGenerator, Optional
4
4
 
5
5
  from aiohttp import web
6
6
  from aiohttp.typedefs import LooseHeaders, PathLike
@@ -13,12 +13,12 @@ class ZipResponse(web.StreamResponse):
13
13
  base_path: PathLike,
14
14
  chunk_size: int = 256 * 1024,
15
15
  status: int = 200,
16
- reason: Optional[str] = None,
17
- headers: Optional[LooseHeaders] = None,
16
+ reason: str | None = None,
17
+ headers: LooseHeaders | None = None,
18
18
  ) -> None:
19
19
  self._base_path = Path(base_path)
20
20
  self._chunk_size = chunk_size
21
- return super().__init__(
21
+ super().__init__(
22
22
  status=status,
23
23
  reason=reason,
24
24
  headers=headers,
@@ -0,0 +1,75 @@
1
+ [project]
2
+ name = "aiohttp-zip-response"
3
+ version = "3.0.0"
4
+ description = "An AIOHTTP response class streaming a directory as a ZIP archive"
5
+ license = "MIT"
6
+ license-files = ["LICENSE"]
7
+ readme = "README.md"
8
+ requires-python = ">=3.11,<4.0"
9
+ dependencies = [
10
+ "aiohttp (>=3.9.5,<4.0)",
11
+ "stream-zip (>=0.0.83,<0.1.0)",
12
+ ]
13
+ classifiers = [
14
+ "Development Status :: 5 - Production/Stable",
15
+ "Environment :: Web Environment",
16
+ "Intended Audience :: Developers",
17
+ "Operating System :: OS Independent",
18
+ "Programming Language :: Python",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Programming Language :: Python :: 3.14",
24
+ "Programming Language :: Python :: 3.15",
25
+ "Topic :: Internet :: WWW/HTTP",
26
+ "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
27
+ "Topic :: Software Development :: Libraries",
28
+ "Topic :: Software Development :: Libraries :: Python Modules",
29
+ "Typing :: Typed",
30
+ ]
31
+
32
+ [[project.authors]]
33
+ name = "Jonathan Ehwald"
34
+ email = "github@ehwald.info"
35
+
36
+ [project.urls]
37
+ homepage = "https://github.com/DoctorJohn/aiohttp-zip-response"
38
+ repository = "https://github.com/DoctorJohn/aiohttp-zip-response"
39
+ documentation = "https://github.com/DoctorJohn/aiohttp-zip-response"
40
+
41
+ [dependency-groups]
42
+ dev = [
43
+ "mypy>=1.15.0",
44
+ "prek>=0.2.29",
45
+ "pytest>=8.3.5",
46
+ "pytest-aiohttp>=1.1.0",
47
+ "pytest-asyncio>=0.26.0",
48
+ "pytest-cov>=6.1.1",
49
+ "pytest-randomly>=3.16.0",
50
+ "ruff>=0.11.6",
51
+ ]
52
+
53
+ [build-system]
54
+ requires = ["uv_build>=0.13.4,<0.14.0"]
55
+ build-backend = "uv_build"
56
+
57
+ [tool.uv.build-backend]
58
+ module-root = ""
59
+
60
+ [tool.ruff.lint]
61
+ extend-select = [
62
+ "I",
63
+ "UP",
64
+ ]
65
+
66
+ [tool.ruff.lint.per-file-ignores]
67
+ "tests/**" = ["ASYNC221"]
68
+
69
+ [tool.pytest.ini_options]
70
+ asyncio_mode = "auto"
71
+ asyncio_default_fixture_loop_scope = "function"
72
+ addopts = "--cov=aiohttp_zip_response --cov-report term-missing --cov-report html"
73
+
74
+ [tool.mypy]
75
+ check_untyped_defs = true
@@ -1,30 +1,30 @@
1
1
  [project]
2
2
  name = "aiohttp-zip-response"
3
- version = "2.4.0"
4
- description = "A AIOHTTP response class streaming a directory as ZIP archive"
3
+ version = "3.0.0"
4
+ description = "An AIOHTTP response class streaming a directory as a ZIP archive"
5
5
  authors = [{ name = "Jonathan Ehwald", email = "github@ehwald.info" }]
6
- license = { text = "MIT" }
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
7
8
  readme = "README.md"
8
- requires-python = ">=3.9,<4.0"
9
+ requires-python = ">=3.11,<4.0"
9
10
  dependencies = ["aiohttp (>=3.9.5,<4.0)", "stream-zip (>=0.0.83,<0.1.0)"]
10
11
  classifiers = [
11
12
  "Development Status :: 5 - Production/Stable",
12
13
  "Environment :: Web Environment",
13
14
  "Intended Audience :: Developers",
14
- "License :: OSI Approved :: MIT License",
15
15
  "Operating System :: OS Independent",
16
16
  "Programming Language :: Python",
17
17
  "Programming Language :: Python :: 3",
18
- "Programming Language :: Python :: 3.9",
19
- "Programming Language :: Python :: 3.10",
20
18
  "Programming Language :: Python :: 3.11",
21
19
  "Programming Language :: Python :: 3.12",
22
20
  "Programming Language :: Python :: 3.13",
23
21
  "Programming Language :: Python :: 3.14",
22
+ "Programming Language :: Python :: 3.15",
24
23
  "Topic :: Internet :: WWW/HTTP",
25
24
  "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
26
25
  "Topic :: Software Development :: Libraries",
27
26
  "Topic :: Software Development :: Libraries :: Python Modules",
27
+ "Typing :: Typed",
28
28
  ]
29
29
 
30
30
  [project.urls]
@@ -32,14 +32,10 @@ homepage = "https://github.com/DoctorJohn/aiohttp-zip-response"
32
32
  repository = "https://github.com/DoctorJohn/aiohttp-zip-response"
33
33
  documentation = "https://github.com/DoctorJohn/aiohttp-zip-response"
34
34
 
35
- [build-system]
36
- requires = ["hatchling"]
37
- build-backend = "hatchling.build"
38
-
39
35
  [dependency-groups]
40
36
  dev = [
41
37
  "mypy>=1.15.0",
42
- "pre-commit>=4.2.0",
38
+ "prek>=0.2.29",
43
39
  "pytest>=8.3.5",
44
40
  "pytest-aiohttp>=1.1.0",
45
41
  "pytest-asyncio>=0.26.0",
@@ -48,14 +44,25 @@ dev = [
48
44
  "ruff>=0.11.6",
49
45
  ]
50
46
 
51
- [tool.hatch.build.targets.wheel]
52
- packages = ["aiohttp_zip_response"]
47
+ [build-system]
48
+ requires = ["uv_build>=0.13.4,<0.14.0"]
49
+ build-backend = "uv_build"
50
+
51
+ [tool.uv.build-backend]
52
+ module-root = ""
53
53
 
54
54
  [tool.ruff.lint]
55
- extend-select = ["I"]
55
+ extend-select = ["I", "UP"]
56
+
57
+ [tool.ruff.lint.per-file-ignores]
58
+ "tests/**" = [
59
+ # Blocking calls (e.g. os.system) are fine in async tests
60
+ "ASYNC221",
61
+ ]
56
62
 
57
63
  [tool.pytest.ini_options]
58
64
  asyncio_mode = "auto"
65
+ asyncio_default_fixture_loop_scope = "function"
59
66
  addopts = "--cov=aiohttp_zip_response --cov-report term-missing --cov-report html"
60
67
 
61
68
  [tool.mypy]
@@ -1 +0,0 @@
1
- * text=auto eol=lf
@@ -1,30 +0,0 @@
1
- name: Lint
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- pull_request:
7
- branches: [main]
8
-
9
- jobs:
10
- lint:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v4
14
-
15
- - name: Install uv
16
- uses: astral-sh/setup-uv@v5
17
- with:
18
- enable-cache: true
19
-
20
- - name: Set up Python
21
- run: uv python install
22
-
23
- - name: Install the project
24
- run: uv sync --all-extras --dev
25
-
26
- - name: Lint
27
- run: |
28
- uv run ruff check aiohttp_zip_response tests
29
- uv run ruff format --diff aiohttp_zip_response tests
30
- uv run mypy aiohttp_zip_response
@@ -1,30 +0,0 @@
1
- name: "Publish"
2
-
3
- on:
4
- push:
5
- tags:
6
- - v*
7
-
8
- jobs:
9
- run:
10
- runs-on: ubuntu-latest
11
- environment:
12
- name: pypi
13
- permissions:
14
- id-token: write
15
- contents: read
16
- steps:
17
- - name: Checkout
18
- uses: actions/checkout@v5
19
- - name: Install uv
20
- uses: astral-sh/setup-uv@v6
21
- - name: Install Python 3.13
22
- run: uv python install 3.13
23
- - name: Build
24
- run: uv build
25
- - name: Smoke test (wheel)
26
- run: uv run --isolated --no-project --with dist/*.whl tests/smoke_test.py
27
- - name: Smoke test (source distribution)
28
- run: uv run --isolated --no-project --with dist/*.tar.gz tests/smoke_test.py
29
- - name: Publish
30
- run: uv publish
@@ -1,33 +0,0 @@
1
- name: Test
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- pull_request:
7
- branches: [main]
8
-
9
- jobs:
10
- test:
11
- runs-on: ubuntu-latest
12
- strategy:
13
- matrix:
14
- python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
15
- steps:
16
- - uses: actions/checkout@v4
17
-
18
- - name: Install uv and set the python version
19
- uses: astral-sh/setup-uv@v5
20
- with:
21
- enable-cache: true
22
- python-version: ${{ matrix.python-version }}
23
-
24
- - name: Install the project
25
- run: uv sync --all-extras --dev
26
-
27
- - name: Run tests and collect coverage
28
- run: uv run pytest -vv --cov=aiohttp_zip_response --cov-report=xml
29
-
30
- - name: Upload coverage reports to Codecov with GitHub Action
31
- uses: codecov/codecov-action@v4
32
- with:
33
- token: ${{ secrets.CODECOV_TOKEN }}
@@ -1,7 +0,0 @@
1
- __pycache__
2
- .mypy_cache
3
- .pytest_cache
4
- .ruff_cache
5
- .coverage
6
- build
7
- dist
@@ -1,11 +0,0 @@
1
- repos:
2
- - repo: https://github.com/astral-sh/ruff-pre-commit
3
- rev: v0.14.1
4
- hooks:
5
- - id: ruff
6
- - id: ruff-format
7
- args: [--check]
8
- - repo: https://github.com/pre-commit/mirrors-mypy
9
- rev: v1.18.2
10
- hooks:
11
- - id: mypy
@@ -1 +0,0 @@
1
- 3.9
File without changes
@@ -1,49 +0,0 @@
1
- import pytest
2
- from aiohttp import web
3
-
4
- from aiohttp_zip_response import ZipResponse
5
-
6
-
7
- async def default_handler(request: web.Request) -> web.StreamResponse:
8
- return ZipResponse(
9
- request.query["path"],
10
- )
11
-
12
-
13
- async def custom_chunk_size_handler(request: web.Request) -> web.StreamResponse:
14
- return ZipResponse(
15
- request.query["path"],
16
- chunk_size=256 * 1024,
17
- )
18
-
19
-
20
- async def custom_status_handler(request: web.Request) -> web.StreamResponse:
21
- return ZipResponse(
22
- request.query["path"],
23
- status=418,
24
- )
25
-
26
-
27
- async def custom_reason_handler(request: web.Request) -> web.StreamResponse:
28
- return ZipResponse(
29
- request.query["path"],
30
- reason="OKAY",
31
- )
32
-
33
-
34
- async def custom_headers_handler(request: web.Request) -> web.StreamResponse:
35
- return ZipResponse(
36
- request.query["path"],
37
- headers={"X-TEST": "TEST"},
38
- )
39
-
40
-
41
- @pytest.fixture
42
- async def cli(aiohttp_client):
43
- app = web.Application()
44
- app.router.add_get("/default/", default_handler)
45
- app.router.add_get("/custom-chunk-size/", custom_chunk_size_handler)
46
- app.router.add_get("/custom-status/", custom_status_handler)
47
- app.router.add_get("/custom-reason/", custom_reason_handler)
48
- app.router.add_get("/custom-headers/", custom_headers_handler)
49
- return await aiohttp_client(app)
@@ -1,11 +0,0 @@
1
- from aiohttp import web
2
-
3
- from aiohttp_zip_response import ZipResponse
4
-
5
-
6
- async def handle_zip(request):
7
- return ZipResponse("path/to/directory")
8
-
9
-
10
- app = web.Application()
11
- app.router.add_get("/zip", handle_zip)