Skip to content

Move the command line and HTTP service dependencies into extras - #46

Merged
ericof merged 2 commits into
mainfrom
issue-45
Oct 27, 2026
Merged

ericof merged 2 commits into
mainfrom
issue-45

Conversation

@ericof

@ericof ericof commented Oct 27, 2026

Copy link
Copy Markdown
Member

collective.html2blocks is mostly used as a library: html_to_blocks(), markdown_to_blocks() and volto_blocks() need only beautifulsoup4, markdown-it-py and python-slugify. Installing it still pulled in typer and fastapi[standard] (with uvicorn, starlette, httpx, jinja2 and the FastAPI CLI), which only the html2blocks command and the HTTP service use. Projects that depend on the converter, such as the optional markdown extra in plone-client, got a web framework they never import.

This PR moves those dependencies into extras:

  • collective.html2blocks[cli] installs typer for the html2blocks command.
  • collective.html2blocks[server] adds fastapi[standard] for html2blocks server and the HTTP service.
  • collective.html2blocks[all] installs both.

The base install now carries only the converter's dependencies. When an extra is missing, html2blocks prints a short message naming the extra to install instead of failing with an ImportError. The container image and the documentation install collective.html2blocks[server].

This changes the installation for anyone who uses the command or the service from a plain pip install collective.html2blocks. They now need the matching extra, and the changelog says so.

The all extra uses a self-reference, collective.html2blocks[cli,server]; uv and the built wheel both accept it. The command module moved to cli_app.py, because a top-level typer import cannot be guarded from inside the module that the console script loads. cli.py now checks for typer and loads cli_app, and cli.app still resolves. The server command imports uvicorn when it runs, so a cli install still runs convert and info. The Makefile installs all extras, so the test suite runs unchanged.

Closes #45

The base install now carries only the converter's dependencies:
beautifulsoup4, markdown-it-py and python-slugify.

typer moves to the cli extra, and typer with fastapi[standard] moves to
the server extra. The all extra installs both.

When typer is missing, html2blocks prints one line naming the cli extra
and exits with status 1. When fastapi or uvicorn is missing, the server
command prints the same line for the server extra. The converter modules
do not import any of these packages, so the base install still converts
and needs no web framework.

The Makefile installs all extras, the container image installs the server
extra, and the documentation environment installs the all extra.

Refs #45
The new tests run the converter and the html2blocks command in child
interpreters. pytest-cov exports COV_CORE_* variables, so each child
started its own coverage run and wrote a data file that could not be
combined with the parent's, which failed make test-coverage in CI.

The child environment now drops the COV_CORE_* variables.

Refs #45
@ericof
ericof merged commit d8094b0 into main Oct 27, 2026
14 checks passed
@ericof
ericof deleted the issue-45 branch October 27, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move the command line and HTTP service dependencies into extras

1 participant