Skip to content

Commit

Permalink
Merge branch 'release/0.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
stumpylog committed Dec 11, 2024
2 parents 50d6e00 + 05a2970 commit 7c32237
Show file tree
Hide file tree
Showing 29 changed files with 674 additions and 236 deletions.
60 changes: 21 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,11 @@ jobs:
strategy:
fail-fast: false
matrix:
# No pikepdf wheels for pypy3.8
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy3.9', 'pypy3.10']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', 'pypy3.9', 'pypy3.10']

steps:
-
uses: actions/checkout@v4
-
name: Start containers
run: |
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test.yml pull --quiet
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test.yml up --detach
echo "Wait for container to be started"
sleep 5
docker inspect gotenberg-client-test-server
-
name: Install poppler-utils
run: |
Expand All @@ -83,34 +74,38 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
-
name: Pull Docker images
run: |
docker compose --file tests/docker/docker-compose.ci-test-edge.yml pull --quiet
docker compose --file tests/docker/docker-compose.ci-test.yml pull --quiet
-
name: Install Hatch
run: |
pip3 --quiet install --upgrade hatch uv
hatch --version
uv --version
-
name: Show environment
run: |
hatch test --show --python ${{ matrix.python-version }}
name: Show environment
run: |
hatch test --show --python ${{ matrix.python-version }}
-
name: Run tests
run: |
hatch test --cover --python ${{ matrix.python-version }}
ls -ahl .
hatch test --cover --junitxml=junit.xml -o junit_family=legacy --python ${{ matrix.python-version }}
-
name: Upload coverage to Codecov
if: matrix.python-version == '3.10'
uses: codecov/codecov-action@v4
if: matrix.python-version == '3.11'
uses: codecov/codecov-action@v5
with:
# not required for public repos, but intermittently fails otherwise
token: ${{ secrets.CODECOV_TOKEN }}
-
name: Stop containers
if: always()
run: |
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test.yml logs
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test.yml down
name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ${{ matrix.python-version }}

test-edge:
name: Test Gotenberg :edge
Expand All @@ -119,17 +114,11 @@ jobs:
contents: read
needs:
- lint
env:
GOTENBERG_CLIENT_EDGE_TEST: 1
steps:
-
uses: actions/checkout@v4
-
name: Start containers
run: |
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test-edge.yml pull --quiet
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test-edge.yml up --detach
echo "Wait for container to be started"
sleep 5
docker inspect gotenberg-client-test-edge-server
-
name: Install poppler-utils
run: |
Expand All @@ -154,13 +143,6 @@ jobs:
name: Run tests
run: |
hatch test --cover --python 3.11
ls -ahl .
-
name: Stop containers
if: always()
run: |
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test-edge.yml logs
docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test-edge.yml down
build:
name: Build
Expand Down Expand Up @@ -297,4 +279,4 @@ jobs:
path: dist
-
name: Publish build to PyPI
uses: pypa/gh-action-pypi-publish@v1.10.2
uses: pypa/gh-action-pypi-publish@v1.12.2
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
- id: detect-private-key
# See https://github.com/prettier/prettier/issues/15742 for the fork reason
- repo: https://github.com/rbubley/mirrors-prettier
rev: "v3.3.3"
rev: "v3.4.2"
hooks:
- id: prettier
types_or:
Expand All @@ -45,13 +45,13 @@ repos:
- id: codespell
# Python hooks
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.6.9'
rev: 'v0.8.2'
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "2.2.4"
rev: "v2.5.0"
hooks:
- id: pyproject-fmt
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.0] - 2024-12-11

### Breaking Change

- Dropped support for Python 3.8 ([#43](https://github.com/stumpylog/gotenberg-client/pull/43))

### Added

- Official support and testing for Python 3.13 ([#25](https://github.com/stumpylog/gotenberg-client/pull/25))
- Support for setting PDF metadata ([#42](https://github.com/stumpylog/gotenberg-client/pull/42))
- Initial work by @spechtx in ([#40](https://github.com/stumpylog/gotenberg-client/pull/40))
- Integrated Codecov test analytics ([#44](https://github.com/stumpylog/gotenberg-client/pull/44))

### Changed

- Use `pytest-docker` to manage Docker image services ([#36](https://github.com/stumpylog/gotenberg-client/pull/36))
- Bump Bump pypa/gh-action-pypi-publish from 1.10.2 to 1.12.2 by @dependabot ([#41](https://github.com/stumpylog/gotenberg-client/pull/41))
- Bump codecov/codecov-action from 4 to 5 by @dependabot ([#41](https://github.com/stumpylog/gotenberg-client/pull/41))

## [0.7.0] - 2024-10-08

### Fixed
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,35 @@ with GotenbergClient("http://localhost:3000") as client:
response.to_file(Path("my-world.pdf"))
```

Adding metadata to a PDF:

This example shows how to add metadata to your generated PDF. All metadata fields are optional and include:

- Document info (title, author, subject, keywords)
- Dates (creation, modification)
- Technical details (pdf version, creator, producer)
- PDF standards (trapped status, marked status)

```python
from gotenberg_client import GotenbergClient
from datetime import datetime

with GotenbergClient("http://localhost:3000") as client:
with client.chromium.html_to_pdf() as route:
response = (route
.index("my-index.html")
.metadata(
title="My Document",
author="John Doe",
subject="Example PDF",
keywords=["sample", "document", "test"],
creation_date=datetime.now(),
trapped="Unknown"
)
.run())
response.to_file(Path("my-index.pdf"))
```

To ensure the proper clean up of all used resources, both the client and the route(s) should be
used as context manager. If for some reason you cannot, you should `.close` the client and any
routes:
Expand Down
11 changes: 1 addition & 10 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
# Roadmap

## Custom Response Class

Currently, the response returned is a basic httpx.Response. It could be useful to abstract this in some manner, especially for responses which return a zip file.

- Ability to iterate through the zip file contents in some way
- Ability to write the response to some given output location?

## Missing Routes/Options

- Missing the configuration of the units of page size, currently it is always inches
While I'm sure there's something out there, nothing is currently on the roadmap.
38 changes: 36 additions & 2 deletions docs/routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,45 @@ These options are not yet implemented
| `pdfa` | `.pdf_format()` | `PdfAFormat` | |
| `pdfua` | <ul><li>`enable_universal_access()`<li>`disable_universal_access()`</li></ul> | N/A | |

#### Metadata
#### PDF Metadata Support

[Gotenberg Documentation](https://gotenberg.dev/docs/routes#metadata-chromium)

These options are not yet implemented
Add metadata to your PDFs:

```python
from gotenberg_client import GotenbergClient
from datetime import datetime

with GotenbergClient("http://localhost:3000") as client:
with client.chromium.html_to_pdf() as route:
response = (route
.index("my-index.html")
.metadata(
title="My Document",
author="John Doe",
creation_date=datetime.now(),
keywords=["sample", "document"],
subject="Sample PDF Generation",
trapped="Unknown"
)
.run())
```

Supported metadata fields:

- `title`: Document title
- `author`: Document author
- `subject`: Document subject
- `keywords`: List of keywords
- `creator`: Creating application
- `creation_date`: Creation datetime
- `modification_date`: Last modification datetime
- `producer`: PDF producer
- `trapped`: Trapping status ('True', 'False', 'Unknown')
- `copyright`: Copyright information
- `marked`: PDF marked status
- `pdf_version`: PDF version number

## LibreOffice

Expand Down
26 changes: 14 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ license = "MPL-2.0"
authors = [
{ name = "Trenton H", email = "[email protected]" },
]
requires-python = ">=3.8"
requires-python = ">=3.9"
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
Expand All @@ -25,18 +25,17 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"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",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dynamic = [ "version" ]
dependencies = [
"httpx[http2]~=0.24; python_version<'3.9'",
"httpx[http2]~=0.27; python_version>='3.9'",
"httpx[http2]~=0.28",
"typing-extensions; python_version<'3.11'",
]

Expand Down Expand Up @@ -64,7 +63,7 @@ installer = "uv"

[tool.hatch.envs.hatch-static-analysis]
# https://hatch.pypa.io/latest/config/internal/static-analysis/
dependencies = [ "ruff ~= 0.6" ]
dependencies = [ "ruff ~= 0.8" ]
config-path = "none"

[tool.hatch.envs.hatch-test]
Expand All @@ -74,7 +73,6 @@ randomize = true
dependencies = [
"coverage-enable-subprocess == 1.0",
"coverage[toml] ~= 7.6",
"pytest < 8.0; python_version < '3.9'",
"pytest ~= 8.3; python_version >= '3.9'",
"pytest-mock ~= 3.14",
"pytest-randomly ~= 3.15",
Expand All @@ -83,10 +81,10 @@ dependencies = [
]
extra-dependencies = [
"pytest-sugar",
"pytest-httpx == 0.30.0; python_version >= '3.9'",
"pytest-httpx ~= 0.22; python_version < '3.9'",
"pytest-httpx ~= 0.35",
"pikepdf",
"python-magic",
"pytest-docker ~= 3.1",
]
extra-args = [ "--maxprocesses=8", "--pythonwarnings=all" ]

Expand All @@ -109,19 +107,19 @@ cov-report = [
]

[[tool.hatch.envs.hatch-test.matrix]]
python = [ "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10" ]
python = [ "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10" ]

#
# Custom Environments
#
[tool.hatch.envs.typing]
detached = true
dependencies = [
"mypy ~= 1.11",
"mypy ~= 1.13",
"httpx",
"pytest",
"pikepdf",
"pytest-httpx == 0.30.0",
"pytest-httpx ~= 0.35",
]

[tool.hatch.envs.typing.scripts]
Expand Down Expand Up @@ -168,7 +166,7 @@ deploy = [
#

[tool.ruff]
target-version = "py38"
target-version = "py39"
line-length = 120

# https://docs.astral.sh/ruff/settings/
Expand Down Expand Up @@ -244,13 +242,17 @@ lint.ignore = [
]
# Tests can use magic values, assertions, and relative imports
lint.per-file-ignores."tests/**/*" = [ "PLR2004", "S101", "TID252" ]
lint.per-file-ignores."tests/utils.py" = [ "S603" ]
# No relative imports
lint.flake8-tidy-imports.ban-relative-imports = "all"
# One import per line
lint.isort.force-single-line = true
# Recognize us please
lint.isort.known-first-party = [ "gotenberg_client" ]

[tool.pyproject-fmt]
max_supported_python = "3.13"

[tool.pytest.ini_options]
minversion = "7.0"
testpaths = [ "tests" ]
Expand Down
2 changes: 1 addition & 1 deletion src/gotenberg_client/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2023-present Trenton H <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0
__version__ = "0.7.0"
__version__ = "0.8.0"
Loading

0 comments on commit 7c32237

Please sign in to comment.