pypa / hatch

Modern, extensible Python project management
https://hatch.pypa.io/latest/
MIT License
6.11k stars 309 forks source link

TypeError: Unable to determine the content-type based on the extension of readme file: INFO.adoc #1730

Open AllanDaemon opened 2 months ago

AllanDaemon commented 2 months ago

I'm migrating a project from Poetry to Rye. The default build in rye is hatch.

When I try to do anything in Rye with the package (like adding a dependency), it runs hatch.

But it fails due to not being able to support Asciidoc (.adoc) files in the readme property:

[project]
...
readme = "INFO.adoc"

This package is not intended to be published in PyPA or anything.

$ rye sync
Reusing already existing virtualenv
Generating production lockfile: /project/requirements.lock
error: Failed to build: `client @ file:///project/client`
  Caused by: Build backend failed to determine metadata through `prepare_metadata_for_build_editable` with exit status: 1
--- stdout:

--- stderr:
Traceback (most recent call last):
  File "<string>", line 14, in <module>
  File "/home/user/.cache/uv/builds-v0/.tmpHaowpa/lib/python3.12/site-packages/hatchling/build.py", line 142, in prepare_metadata_for_build_editable
    f.write(builder.config.core_metadata_constructor(builder.metadata, extra_dependencies=extra_dependencies))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.cache/uv/builds-v0/.tmpHaowpa/lib/python3.12/site-packages/hatchling/metadata/spec.py", line 515, in construct_metadata_file_2_3
    if metadata.core.readme:
       ^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.cache/uv/builds-v0/.tmpHaowpa/lib/python3.12/site-packages/hatchling/metadata/core.py", line 526, in readme
    raise TypeError(message)
TypeError: Unable to determine the content-type based on the extension of readme file: INFO.adoc
---
error: could not write production lockfile for workspace

Caused by:
    Failed to run uv compile /tmp/.tmpnrYKTz/requirements.txt. uv exited with status: exit status: 2

Specifying the content type with: readme = {file = "INFO.adoc", content-type = "text/asciidoc"} generates the error:

ValueError: Field `content-type` in the `project.readme` table must be one of the following: text/markdown, text/x-rst, text/plain

I tried to create a PR to add support for it but reading things around made me realize that it isn't as simple as adding the lines to support Asciidoc, but I couldn't get it from the specification it this is something totally forbidden.