Using pip-tools with pyproject.toml and setuptools

When building this blog, it wasn’t obvious how to configure pip-tools for my minimal project using pyproject.toml and plain old setuptools. Pip-tools does not pass through the full error message from the libraries it calls, and part of the error message it does show is misleading:

> python -m piptools compile -v -o requirements.txt pyproject.toml

Creating venv isolated environment...
Installing packages in isolated environment... (setuptools >= 40.8.0, wheel)
Getting dependencies for wheel...
Backend subprocess exited when trying to invoke get_requires_for_build_wheel
Failed to parse /path/to/personal-site/pyproject.toml

I didn’t find a way to turn on debug logging beyond passing -v, which helped me figure out what dependency of pip-tools was throwing the error: build. Running build separately then gave me the full error message:

> python -m build -w

* Creating venv isolated environment...
* Installing packages in isolated environment... (setuptools >= 40.8.0, wheel)
* Getting dependencies for wheel...
error: Multiple top-level packages discovered in a flat-layout: ['layout', 'script', 'static', 'content'].

To avoid accidental inclusion of unwanted files or directories,
setuptools will not proceed with this build.

...

Unlike many projects, there’s no single, top-level package. The solution is to add these lines to pyproject.toml:

[tool.setuptools]
packages = ["content", "layout", "script", "static", "test"]