Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display pyproject.toml's metatada parsing errors in verbose mode #1979

Merged
merged 12 commits into from Sep 5, 2023

Conversation

szobov
Copy link
Contributor

@szobov szobov commented Sep 3, 2023

Fixes #1711.

Before the changes implemented in this PR, the execution of pip-compile was silent about an error in pyproject.toml file.
If the user made a mistake in the configuration file, the output of the command was:

Backend subprocess exited when trying to invoke prepare_metadata_for_build_wheel

Now, the output is the following (the error is in the "licence" field for demonstration):

<truncated traceback>
ValueError: invalid pyproject.toml config: `project.license`.
configuration error: `project.license` must be valid exactly by one definition (2 matches found):

    - keys:
        'file': {type: string}
      required: ['file']
    - keys:
        'text': {type: string}
      required: ['text']

Backend subprocess exited when trying to invoke get_requires_for_build_wheel

There are several issues already mentioned on GitHub:
#1711
#1794

The changes implemented in this PR are possible only because of the new build version release:
pypa/build#615 (comment)
The particular change is this: pypa/build#566.

Please pay attention that in case of an error, the traceback is huge, but unfortunately, the error is captured and printed inside build.ProjectBuilder, and it's currently impossible to capture it and show only a short error description. On the other hand, the traceback gives the user an extra debug information.

Contributor checklist
  • Included tests for the changes.
  • PR title is short, clear, and ready to be included in the user-facing changelog.
Maintainer checklist
  • Verified one of these labels is present: backwards incompatible, feature, enhancement, deprecation, bug, dependency, docs or skip-changelog as they determine changelog listing.
  • Assign the PR to an existing or new milestone for the target version (following Semantic Versioning).

Copy link
Member

@atugushev atugushev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I've left a few comments below.

piptools/scripts/compile.py Outdated Show resolved Hide resolved
tests/test_cli_compile.py Outdated Show resolved Hide resolved
tests/test_cli_compile.py Outdated Show resolved Hide resolved
Copy link
Member

@atugushev atugushev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for considering my suggestions! Here are the final adjustments I believe should improve code readability.

piptools/scripts/compile.py Outdated Show resolved Hide resolved
tests/test_cli_compile.py Outdated Show resolved Hide resolved
tests/test_cli_compile.py Outdated Show resolved Hide resolved
tests/test_cli_compile.py Outdated Show resolved Hide resolved
@szobov szobov force-pushed the gh-1711-use-default-subprocess-runner branch 2 times, most recently from 59faba9 to 0209101 Compare September 5, 2023 12:02
Copy link
Member

@atugushev atugushev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@szobov
Copy link
Contributor Author

szobov commented Sep 5, 2023

I'm wondering how I can restart ci checks since they're failed due to a timeout error (most likely a network hiccup)

@atugushev
Copy link
Member

I've restarted failed jobs.

@szobov
Copy link
Contributor Author

szobov commented Sep 5, 2023

Thanks, @atugushev, for your help and patience!
I think PR can now be merged since the only failing job is docs build, which you'll probably fix soon by merging #1983
But now it's your turn to take an action! :)

@theryanwalker theryanwalker added the bug Something is not working label Sep 5, 2023
szobov and others added 11 commits September 5, 2023 16:57
Since version "1.0.0" is released on PyPI we can pass a type of
subprocess runner to "build.ProjectBuilder".
Before the type was hardcoded insude "ProjectBuilder" and was not
available to user. Therefore, whenever the error on parsing
pyproject.toml file happened, user seen only short and non-informative
`Backend subprocess exited when trying to invoke
get_requires_for_build_wheel`.
Now we can select `pyproject_hooks.default_subprocess_runner` from
`pyproject_hooks` library. This runner will throw the error directly
from toml parsing library.
In order to show user the error from toml's parsing library instead of
`Backend subprocess exited when trying to invoke
get_requires_for_build_wheel`.
* No more dependencies on flit
* No network connection required
* Test verbose and non-verbose modes
Co-authored-by: Albert Tugushev <albert@tugushev.ru>
Co-authored-by: Albert Tugushev <albert@tugushev.ru>
Co-authored-by: Albert Tugushev <albert@tugushev.ru>
To check only one action: either run in verbose or non-verbose mode
@szobov szobov force-pushed the gh-1711-use-default-subprocess-runner branch from 0209101 to 4557e7f Compare September 5, 2023 14:58
@szobov
Copy link
Contributor Author

szobov commented Sep 5, 2023

rebased on the fresh main branch

@atugushev atugushev changed the title Show pyproject.toml parsing error Display pyproject.toml's metatada parsing errors in verbose mode Sep 5, 2023
@atugushev atugushev enabled auto-merge (squash) September 5, 2023 15:23
@atugushev atugushev added the pyproject.toml Related to pyproject.toml support label Sep 5, 2023
@atugushev atugushev added this to the 7.3.1 milestone Sep 5, 2023
@atugushev atugushev mentioned this pull request Sep 5, 2023
4 tasks
@atugushev atugushev merged commit e272f65 into jazzband:main Sep 5, 2023
36 checks passed
@atugushev atugushev modified the milestones: 7.3.1, 7.4.0 Feb 16, 2024
github-merge-queue bot pushed a commit to bazelbuild/rules_python that referenced this pull request Apr 18, 2024
Bump pip_tools to >= 7.4.0 so that we can make use of better
`pyproject.toml` parsing error messages during compiling.

Specifically: jazzband/pip-tools#1979
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working pyproject.toml Related to pyproject.toml support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mysterious error with optional dependencies in pyproject.toml
3 participants