Description
My Problem
I'm using pip-tools to manage the requirements of a project that I don't indend to distribute. My pyproject.toml
looks like this.
# pyproject.toml
[project]
name = "name"
version = "1.0"
dependencies = ["name==1.0"]
When I try to run pip-compile
, I get a very unhelpful error.
$ pip-compile pyproject.toml
Backend subprocess exited when trying to invoke get_requires_for_build_wheel
Failed to parse /path/to/pyproject.toml
To add to my problems, validate-pyproject
does not discover any errors either
$ validate-pyproject pyproject.toml
Valid file: pyproject.toml
The Solution
In my particular case, the solution was to add the following section to pyproject.toml
[tool.setuptools]
py-modules = []
I was able to figure this out by changing the following line to remove the stderr
argument.
# file: site-packages/pyproject_hooks/_impl.py
...
def quiet_subprocess_runner(...):
...
check_output(cmd, cwd=cwd, env=env, stderr=STDOUT)
Once I do that, I can run pip-compile
and immediately find the error:
error: Multiple top-level packages discovered in a flat-layout: ['static', 'project', 'app'].
To avoid accidental inclusion of unwanted files or directories,
setuptools will not proceed with this build.
If you are trying to create a single distribution with multiple packages
on purpose, you should not rely on automatic discovery.
Instead, consider the following options:
1. set up custom discovery (`find` directive with `include` or `exclude`)
2. use a `src-layout`
3. explicitly set `py_modules` or `packages` with a list of names
To find more information, look for "package discovery" on setuptools docs.
Future Work
I don't think we should deprive users of such a helpful message.
Right now the build
library defaults to using a quiet
subprocess runner. In a future release, build
will allow the option to specify the runner explicitly (pypa/build#566). When the next version of build
is released, we should consider changing the following lines to use pyproject_hooks.default_subprocess_runner
so that errors are also printed to the terminal.
pip-tools/piptools/scripts/compile.py
Lines 496 to 499 in 0d2d1f2