Skip to content

Fix License in pyproject.toml #8891

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

Closed
wants to merge 1 commit into from
Closed

Conversation

eylenburg
Copy link

I'm maintaining a Flatpak program that depends on pillow and with the update to version 11.2.1 the Flathub build bot gave me an error.

ValueError: invalid pyproject.toml config: `project.license`.
  configuration error: `project.license` must be valid exactly by one definition (2 matches found):

I think the cause is this commit which adds another license reference so that the license is now referenced as a file and as a text and at least the Flathub builder only allows one.

So my pull request should hopefully fix this problem for Flatpak projects depending on Pillow.

@radarhere
Copy link
Member

Hi. Would you be able to determine what version of setuptools you are using?

@eylenburg
Copy link
Author

I don't know. I just maintain a Flatpak app that has pillow as a dependency and the Flathub bot wanted to update it from 11.1.0 to 11.2.1 but this resulted in a build error because it found two definition of the project license for pillow.

This is the relevant pull request:
https://github.com/flathub/net.puddletag.puddletag/pull/20/files

@hugovk
Copy link
Member

hugovk commented Apr 14, 2025

Flathub build bot gave me an error.

The error:

========================================================================
Building module python3-pillow in /srv/buildbot/worker/build-x86_64-4/build/.flatpak-builder/build/python3-pillow-1
========================================================================
�]2;flatpak-builder: Building python3-pillow��]2;flatpak-builder: Installing python3-pillow�Running: pip3 install --verbose --exists-action=i --no-index --find-links="file://${PWD}" --prefix=${FLATPAK_DEST} "pillow" --no-build-isolation
FB: Running 'flatpak build --die-with-parent --env=FLATPAK_BUILDER_BUILDDIR=/run/build/python3-pillow --nofilesystem=host:reset --filesystem=/srv/buildbot/worker/build-x86_64-4/build/.flatpak-builder/build/python3-pillow-1 --bind-mount=/run/build/python3-pillow=/srv/buildbot/worker/build-x86_64-4/build/.flatpak-builder/build/python3-pillow-1 --build-dir=/run/build/python3-pillow --bind-mount=/run/ccache=/srv/buildbot/worker/build-x86_64-4/build/.flatpak-builder/ccache --unshare=network --env=SOURCE_DATE_EPOCH=1744483774 '--env=CFLAGS=-O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' '--env=CXXFLAGS=-O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' '--env=LDFLAGS=-L/app/lib -Wl,-z,relro,-z,now -Wl,--as-needed ' --env=BASEAPP_REMOVE_WEBENGINE=1 --env=CCACHE_DIR=/run/ccache/disabled --env=PATH=/app/bin:/usr/bin --env=LD_LIBRARY_PATH=/app/lib --env=PKG_CONFIG_PATH=/app/lib/pkgconfig:/app/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig --env=FLATPAK_BUILDER_N_JOBS=64 /srv/buildbot/worker/build-x86_64-4/build/.flatpak-builder/rofiles/rofiles-YxhGiX /bin/sh -c 'pip3 install --verbose --exists-action=i --no-index --find-links="file://${PWD}" --prefix=${FLATPAK_DEST} "pillow" --no-build-isolation'' on host
Using pip 25.0.1 from /usr/lib/python3.12/site-packages/pip (python 3.12)
Looking in links: file:///run/build/python3-pillow
Processing ./pillow-11.2.1.tar.gz
  Running command Preparing metadata (pyproject.toml)
  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-CMU"
  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"
                  ]
              }
          ]
      }
  Traceback (most recent call last):
    File "/usr/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
      main()
    File "/usr/lib/python3.12/site-packages/pip/_vendor/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/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 175, in prepare_metadata_for_build_wheel
      return hook(metadata_directory, config_settings)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.12/site-packages/setuptools/build_meta.py", line 377, in prepare_metadata_for_build_wheel
      self.run_setup()
    File "/usr/lib/python3.12/site-packages/setuptools/build_meta.py", line 320, in run_setup
      exec(code, locals())
    File "<string>", line 1053, in <module>
    File "/usr/lib/python3.12/site-packages/setuptools/__init__.py", line 117, in setup
      return distutils.core.setup(**attrs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 160, in setup
      dist.parse_config_files()
    File "/usr/lib/python3.12/site-packages/setuptools/dist.py", line 652, in parse_config_files
      pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
    File "/usr/lib/python3.12/site-packages/setuptools/config/pyprojecttoml.py", line 72, in apply_configuration
      config = read_configuration(filepath, True, ignore_option_errors, dist)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.12/site-packages/setuptools/config/pyprojecttoml.py", line 140, in read_configuration
      validate(subset, filepath)
    File "/usr/lib/python3.12/site-packages/setuptools/config/pyprojecttoml.py", line 61, 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']
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /usr/bin/python /usr/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmptk08hvfu
  cwd: /tmp/pip-install-9z6io9hx/pillow_046586ea5fbd47d4b26f9c8d6fcdd86b
  Preparing metadata (pyproject.toml) ... �[?25l�[?25herror
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.

I think the cause is this commit which adds another license reference so that the license is now referenced as a file and as a text and at least the Flathub builder only allows one.

That commit adds PEP 639 licence metadata: https://peps.python.org/pep-0639/

I think the likely cause is Flathub builder, or something it calls, doesn't support PEP 639 metadata yet.

@radarhere
Copy link
Member

radarhere commented Apr 14, 2025

Testing, https://buildbot.flathub.org/#/builders/9/builds/18241 showed that it is currently using setuptools 76.0.0.post20250313, rather than >= 77 as cda26be added to the requirements.

March 13 was relatively recent, more recent than any changes to the base https://github.com/flathub/com.riverbankcomputing.PyQt.BaseApp, so I suspect it will update by itself in this corner of the flatpak ecosystem at some point in the near future.

@radarhere
Copy link
Member

flathub/com.riverbankcomputing.PyQt.BaseApp#458 was merged. This apparently triggered a setuptools update, and your problem is now resolved.

I created flathub/net.puddletag.puddletag#24 to demonstrate, and you can see that it passed - https://github.com/flathub-infra/vorarbeiter/actions/runs/14653373037

@radarhere radarhere closed this Apr 25, 2025
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

Successfully merging this pull request may close these issues.

3 participants