Closed Calvin-L closed 2 weeks ago
Recent changes in pyproject-hooks
(1.2, released Sep 29) have worsened the situation. pip install --editable
now fails if license-files
is not an array:
Obtaining file:///home/joe/src/t-doc/common
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Installing backend dependencies ... done
Preparing editable metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing editable metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
Traceback (most recent call last):
File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 195, in prepare_metadata_for_build_editable
hook = backend.prepare_metadata_for_build_editable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'hatchling.build' has no attribute 'prepare_metadata_for_build_editable'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
main()
File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in main
json_out["return_val"] = hook(**hook_input["kwargs"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 204, in prepare_metadata_for_build_editable
whl_basename = build_hook(metadata_directory, config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-s3zdoiys/overlay/lib/python3.12/site-packages/hatchling/build.py", line 83, in build_editable
return os.path.basename(next(builder.build(directory=wheel_directory, versions=['editable'])))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-s3zdoiys/overlay/lib/python3.12/site-packages/hatchling/builders/plugin/interface.py", line 90, in build
self.metadata.validate_fields()
File "/tmp/pip-build-env-s3zdoiys/overlay/lib/python3.12/site-packages/hatchling/metadata/core.py", line 266, in validate_fields
self.core.validate_fields()
File "/tmp/pip-build-env-s3zdoiys/overlay/lib/python3.12/site-packages/hatchling/metadata/core.py", line 1363, in validate_fields
getattr(self, attribute)
File "/tmp/pip-build-env-s3zdoiys/overlay/lib/python3.12/site-packages/hatchling/metadata/core.py", line 753, in license_files
raise TypeError(message)
TypeError: Field `project.license-files` must be an array
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
At the same time, hatchling fails builds if it is an array.
* Getting build dependencies for sdist...
* Building sdist...
Traceback (most recent call last):
File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
main()
File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in main
json_out["return_val"] = hook(**hook_input["kwargs"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in build_sdist
return backend.build_sdist(sdist_directory, config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/hatchling/build.py", line 34, in build_sdist
return os.path.basename(next(builder.build(directory=sdist_directory, versions=['standard'])))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/hatchling/builders/plugin/interface.py", line 90, in build
self.metadata.validate_fields()
File "/usr/lib/python3.12/site-packages/hatchling/metadata/core.py", line 266, in validate_fields
self.core.validate_fields()
File "/usr/lib/python3.12/site-packages/hatchling/metadata/core.py", line 1376, in validate_fields
getattr(self, attribute)
File "/usr/lib/python3.12/site-packages/hatchling/metadata/core.py", line 750, in license_files
raise TypeError(message)
TypeError: Field `project.license-files` must be a table
ERROR Backend subprocess exited when trying to invoke build_sdist
So license-files
is currently unusable.
The array is supported since last night https://github.com/pypa/hatch/pull/1790
The docs say:
That links to PEP 639, which gives this example for
license-files
:However, hatchling doesn't accept this, throwing
Reading the relevant code it looks like hatchling wants
license-files.globs = [...]
instead, but I don't see anything in the the hatchling docs about that, and it disagrees with the PEP. I think hatchling should accept the simpler officiallicense-files = list-of-globs
format.