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 · 4 comments
Open

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.

@GregoryLand
Copy link

I am also seeing this behavior with a project that previously worked. I am currently trying to track down the issue.

@ofek
Copy link
Collaborator

ofek commented Nov 21, 2024

Please upgrade Hatchling

@GregoryLand
Copy link

So I am doing this inside a docker container using ubuntu:24.04. The project gets built using

pipx run hatch build
pipx run hatch run projectName

Manually running pipx run hatch --version returns Hatch, verison 1.13.0. I believe that hatchling is also current. Bashing into the docker container and running pipx install hatch results in a site packages directory for hatch using hatchling-1.26.3

Here is a ls of the site packages directory after a pipx install hatch

_cffi_backend.cpython-312-x86_64-linux-gnu.so
anyio
anyio-4.6.2.post1.dist-info
certifi
certifi-2024.8.30.dist-info
cffi
cffi-1.17.1.dist-info
click
click-8.1.7.dist-info
cryptography
cryptography-43.0.3.dist-info
distlib
distlib-0.3.9.dist-info
filelock
filelock-3.16.1.dist-info
h11
h11-0.14.0.dist-info
hatch
hatch-1.13.0.dist-info
hatchling
hatchling-1.26.3.dist-info
httpcore
httpcore-1.0.7.dist-info
httpx
httpx-0.27.2.dist-info
hyperlink
hyperlink-21.0.0.dist-info
idna
idna-3.10.dist-info
jaraco
jaraco.classes-3.4.0.dist-info
jaraco.context-6.0.1.dist-info
jaraco.functools-4.1.0.dist-info
jeepney
jeepney-0.8.0.dist-info
keyring
keyring-25.5.0.dist-info
markdown_it
markdown_it_py-3.0.0.dist-info
mdurl
mdurl-0.1.2.dist-info
more_itertools
more_itertools-10.5.0.dist-info
packaging
packaging-24.2.dist-info
pathspec
pathspec-0.12.1.dist-info
pexpect
pexpect-4.9.0.dist-info
pipx_shared.pth
platformdirs
platformdirs-4.3.6.dist-info
pluggy
pluggy-1.5.0.dist-info
ptyprocess
ptyprocess-0.7.0.dist-info
pycparser
pycparser-2.22.dist-info
pygments
pygments-2.18.0.dist-info
rich
rich-13.9.4.dist-info
secretstorage
shellingham
shellingham-1.5.4.dist-info
sniffio
sniffio-1.3.1.dist-info
tomli_w
tomli_w-1.1.0.dist-info
tomlkit
tomlkit-0.13.2.dist-info
trove_classifiers
trove_classifiers-2024.10.21.16.dist-info
userpath
userpath-1.9.2.dist-info
uv
uv-0.5.4.dist-info
virtualenv
virtualenv-20.27.1.dist-info
zstandard
zstandard-0.23.0.dist-info```

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

3 participants