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

Hatchling v1.26.1 not allow string-value to license key in pyproject.toml #1799

Open
digitronik opened this issue Nov 11, 2024 · 1 comment

Comments

@digitronik
Copy link

digitronik commented Nov 11, 2024

I am encountering an error when setting the license field to an string-value (license = "something") in the pyproject.toml file, using Hatchling v1.26.1.

[project]
name = "foo-bar"
readme = "README.rst"
license = "MIT OR GPL-2.0-or-later OR (FSFUL AND BSD-2-Clause)"

I think as per PEP 639, setting the license field to an string is completely valid. However, Hatchling is throwing the following error during the build process:

  Preparing editable metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing editable metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [21 lines of output]
      Traceback (most recent call last):
        File "/home/ndhandre/RedHat/iqe/.iqe_env/lib64/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/ndhandre/RedHat/iqe/.iqe_env/lib64/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/ndhandre/RedHat/iqe/.iqe_env/lib64/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 176, in prepare_metadata_for_build_editable
          whl_basename = build_hook(metadata_directory, config_settings)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-exmmg97_/overlay/lib/python3.11/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-exmmg97_/overlay/lib/python3.11/site-packages/hatchling/builders/plugin/interface.py", line 90, in build
          self.metadata.validate_fields()
        File "/tmp/pip-build-env-exmmg97_/overlay/lib/python3.11/site-packages/hatchling/metadata/core.py", line 266, in validate_fields
          self.core.validate_fields()
        File "/tmp/pip-build-env-exmmg97_/overlay/lib/python3.11/site-packages/hatchling/metadata/core.py", line 1366, in validate_fields
          getattr(self, attribute)
        File "/tmp/pip-build-env-exmmg97_/overlay/lib/python3.11/site-packages/hatchling/metadata/core.py", line 683, in license
          raise ValueError(message) from None
      ValueError: Error parsing field `project.license` - Invalid license expression: ''
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
@digitronik digitronik changed the title Hatchling v1.26.1 not allow empty string License in pyproject.toml Hatchling v1.26.1 not allow string License in pyproject.toml Nov 11, 2024
@digitronik digitronik changed the title Hatchling v1.26.1 not allow string License in pyproject.toml Hatchling v1.26.1 not allow string-value to license key in pyproject.toml Nov 11, 2024
@ofek
Copy link
Collaborator

ofek commented Nov 12, 2024

Please show me something so that I can reproduce, I can't from your example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants