pdm-project / pdm-backend

The build backend used by PDM that supports latest packaging standards.
https://backend.pdm-project.org
MIT License
70 stars 36 forks source link

PEP621ValidationError #83

Closed DanLipsitt closed 1 year ago

DanLipsitt commented 2 years ago

I accidentally put a source-includes field in the [project] section of my pyproject.toml instead of [tool.pdm]. For versions of pdm-pep517 prior to 0.11.2 this was fine, but 0.12.0 up to the current 0.12.3, PDM gives the error below.

Would it be possible to print line number and offending line (on stdout instead of in the log) when this happens? Even better, if we know that a field is correct but in the wrong section, the error could mention that.

Collecting pdm-pep517
  Using cached pdm_pep517-0.12.3-py3-none-any.whl (302 kB)
Installing collected packages: pdm-pep517
Successfully installed pdm-pep517-0.12.3
Traceback (most recent call last):
  File "/Users/dlipsitt/Library/Application Support/pdm/venv/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 363, in <module>
    main()
  File "/Users/dlipsitt/Library/Application Support/pdm/venv/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 345, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/Users/dlipsitt/Library/Application Support/pdm/venv/lib/python3.9/site-packages/pep517/in_process/_in_process.py", line 283, in build_editable
    return hook(wheel_directory, config_settings, metadata_directory)
  File "/var/folders/m9/d2t2rmwx7rz10l9dvlsb35540000gq/T/pdm-build-env-eluxduco-shared/lib/python3.9/site-packages/pdm/pep517/api.py", line 97, in build_editable
    with EditableBuilder(Path.cwd(), config_settings) as builder:
  File "/var/folders/m9/d2t2rmwx7rz10l9dvlsb35540000gq/T/pdm-build-env-eluxduco-shared/lib/python3.9/site-packages/pdm/pep517/editable.py", line 75, in __init__
    to_filename(self.meta.project_name), self.location.as_posix()
  File "/var/folders/m9/d2t2rmwx7rz10l9dvlsb35540000gq/T/pdm-build-env-eluxduco-shared/lib/python3.9/site-packages/pdm/pep517/base.py", line 144, in meta
    self._meta.validate(True)
  File "/var/folders/m9/d2t2rmwx7rz10l9dvlsb35540000gq/T/pdm-build-env-eluxduco-shared/lib/python3.9/site-packages/pdm/pep517/metadata.py", line 87, in validate
    return validate_pep621(self._metadata, raising)
  File "/var/folders/m9/d2t2rmwx7rz10l9dvlsb35540000gq/T/pdm-build-env-eluxduco-shared/lib/python3.9/site-packages/pdm/pep517/validator.py", line 85, in validate_pep621
    raise PEP621ValidationError(validator.errors)
pdm.pep517.exceptions.PEP621ValidationError: {'source-includes': ['unknown field']}
DanLipsitt commented 2 years ago

Apologies if this bug should be filed in the PDM project instead of here. The behavior differs between pdm-pep517 versions and I filed it before I knew the cause.

frostming commented 1 year ago

We have rewritten the build backend in a way that it uses validate-pyproject as the validator. It is still in alpha stage, please have a try.