Skip to content

Invalid pyproject.toml config after configuring license #4993

@jaraco

Description

@jaraco

Since merging jaraco/skeleton#171 into jaraco.itertools and zipp, I've started to encounter an error when attempting to build_editable (by way of running tox), but only on Python 3.11 and earlier, and only when running on my mac:

 zipp main 🐚 tox -e py311
.pkg-cpython311: install_requires> python -I -m pip install coherent.licensed
.pkg-cpython311: _optional_hooks> python '/Users/jaraco/Library/Application Support/pipx/venvs/tox/lib/python3.13/site-packages/pyproject_api/_backend.py' True setuptools.build_meta
.pkg-cpython311: get_requires_for_build_editable> python '/Users/jaraco/Library/Application Support/pipx/venvs/tox/lib/python3.13/site-packages/pyproject_api/_backend.py' True setuptools.build_meta
py311: packaging backend failed (code=1), with ValueError: invalid pyproject.toml config: `project.license`.
configuration error: `project.license` must be valid exactly by one definition (2 matches found):

    - keys:
        'file': {type: string}
      required: ['file']
    - keys:
        'text': {type: string}
      required: ['text']

Traceback (most recent call last):
  File "/Users/jaraco/Library/Application Support/pipx/venvs/tox/lib/python3.13/site-packages/pyproject_api/_backend.py", line 93, in run
    outcome = backend_proxy(parsed_message["cmd"], **parsed_message["kwargs"])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/Library/Application Support/pipx/venvs/tox/lib/python3.13/site-packages/pyproject_api/_backend.py", line 34, in __call__
    return getattr(on_object, name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jaraco/zipp/.tox/.pkg-cpython311/lib/python3.11/site-packages/setuptools/build_meta.py", line 458, in get_requires_for_build_editable
    return self.get_requires_for_build_wheel(config_settings)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jaraco/zipp/.tox/.pkg-cpython311/lib/python3.11/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=[])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jaraco/zipp/.tox/.pkg-cpython311/lib/python3.11/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires
    self.run_setup()
  File "/Users/jaraco/code/jaraco/zipp/.tox/.pkg-cpython311/lib/python3.11/site-packages/setuptools/build_meta.py", line 313, in run_setup
    exec(code, locals())
  File "<string>", line 1, in <module>
  File "/Users/jaraco/code/jaraco/zipp/.tox/.pkg-cpython311/lib/python3.11/site-packages/setuptools/__init__.py", line 108, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jaraco/zipp/.tox/.pkg-cpython311/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 158, in setup
    dist.parse_config_files()
  File "/Users/jaraco/code/jaraco/zipp/.tox/.pkg-cpython311/lib/python3.11/site-packages/_virtualenv.py", line 22, in parse_config_files
    result = old_parse_config_files(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jaraco/zipp/.tox/.pkg-cpython311/lib/python3.11/site-packages/setuptools/dist.py", line 603, in parse_config_files
    pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
  File "/Users/jaraco/code/jaraco/zipp/.tox/.pkg-cpython311/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 70, in apply_configuration
    config = read_configuration(filepath, True, ignore_option_errors, dist)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jaraco/zipp/.tox/.pkg-cpython311/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 135, in read_configuration
    validate(subset, filepath)
  File "/Users/jaraco/code/jaraco/zipp/.tox/.pkg-cpython311/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 59, in validate
    raise ValueError(f"{error}\n{summary}") from None
ValueError: invalid pyproject.toml config: `project.license`.
configuration error: `project.license` must be valid exactly by one definition (2 matches found):

    - keys:
        'file': {type: string}
      required: ['file']
    - keys:
        'text': {type: string}
      required: ['text']

Backend: run command get_requires_for_build_editable with args {'config_settings': None}
configuration error: `project.license` must be valid exactly by one definition (2 matches found):

    - keys:
        'file': {type: string}
      required: ['file']
    - keys:
        'text': {type: string}
      required: ['text']

DESCRIPTION:
    `Project license <https://peps.python.org/pep-0621/#license>`_.

GIVEN VALUE:
    "MIT"

OFFENDING RULE: 'oneOf'

DEFINITION:
    {
        "oneOf": [
            {
                "properties": {
                    "file": {
                        "type": "string",
                        "$$description": [
                            "Relative path to the file (UTF-8) which contains the license for the",
                            "project."
                        ]
                    }
                },
                "required": [
                    "file"
                ]
            },
            {
                "properties": {
                    "text": {
                        "type": "string",
                        "$$description": [
                            "The license of the project whose meaning is that of the",
                            "`License field from the core metadata",
                            "<https://packaging.python.org/specifications/core-metadata/#license>`_."
                        ]
                    }
                },
                "required": [
                    "text"
                ]
            }
        ]
    }
Backend: Wrote response {'code': 1, 'exc_type': 'ValueError', 'exc_msg': "invalid pyproject.toml config: `project.license`.\nconfiguration error: `project.license` must be valid exactly by one definition (2 matches found):\n\n    - keys:\n        'file': {type: string}\n      required: ['file']\n    - keys:\n        'text': {type: string}\n      required: ['text']\n"} to /var/folders/f2/2plv6q2n7l932m2x004jlw340000gn/T/pep517_get_requires_for_build_editable-gldgf321.json
  py311: FAIL code 1 (1.34 seconds)
  evaluation failed :( (1.39 seconds)

I don't see this error in the CI, where tests on macOS on Python 3.9 without any problem. If I comment out the license = "MIT" line (and also the "coherent.licensed" dependency, which relies on it), the project builds fine (removing just "coherent.licensed" has no effect).

What's weird about that error is it seems to be indicating that in pyproject.toml, "project.license" should match with the core metadata "License", but that's wrong. It should be expecting "License-Expression".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions