Skip to content

Conversation

threexc
Copy link
Contributor

@threexc threexc commented Jul 23, 2025

Fixes: #2689

This ensures that when a maturin wheel is built, both the MIT and Apache 2.0 license files are included with the package. For example, with a v1.9.1 build:

|tgamblin@megalith ~/workspace/baylibre/rise/maturin (tgamblin/add-license-files-metadata)$ unzip -l dist/maturin-1.9.1-py3-none-manylinux_2_39_x86_64.whl | grep license
| 1051 07-23-2025 13:47 maturin-1.9.1.dist-info/licenses/license-mit
| 10847 07-23-2025 13:47 maturin-1.9.1.dist-info/licenses/license-apache

Fixes: PyO3#2689

This ensures that when a maturin wheel is built, both the MIT and Apache
2.0 license files are included with the package. For example, with a
v1.9.1 build:

|tgamblin@megalith ~/workspace/baylibre/rise/maturin (tgamblin/add-license-files-metadata)$ unzip -l dist/maturin-1.9.1-py3-none-manylinux_2_39_x86_64.whl | grep license
|     1051  07-23-2025 13:47   maturin-1.9.1.dist-info/licenses/license-mit
|    10847  07-23-2025 13:47   maturin-1.9.1.dist-info/licenses/license-apache

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
This updates pyproject.toml to assign a string directly to the 'license'
key, avoiding errors like the following:

|DEBUG ValueError: invalid pyproject.toml config: `project.license`.
|DEBUG configuration error: `project.license` must be string

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
@threexc
Copy link
Contributor Author

threexc commented Jul 23, 2025

macos test fail looks like a network issue?

@messense messense enabled auto-merge (squash) July 24, 2025 04:43
@messense messense merged commit 7402a48 into PyO3:main Jul 24, 2025
77 of 78 checks passed
@bbhtt
Copy link

bbhtt commented Jul 28, 2025

setuptools requirement should've been bumped in pyproject.toml when this change was made.

        Traceback (most recent call last):
          File "/usr/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
            main()
          File "/usr/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in main
            json_out["return_val"] = hook(**hook_input["kwargs"])
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "/usr/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 280, in build_wheel
            return _build_backend().build_wheel(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "/usr/lib/python3.11/site-packages/setuptools/build_meta.py", line 415, in build_wheel
            return self._build_with_temp_dir(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "/usr/lib/python3.11/site-packages/setuptools/build_meta.py", line 397, in _build_with_temp_dir
            self.run_setup()
          File "/usr/lib/python3.11/site-packages/setuptools/build_meta.py", line 313, in run_setup
            exec(code, locals())
          File "<string>", line 60, in <module>
          File "/usr/lib/python3.11/site-packages/setuptools/__init__.py", line 108, in setup
            return distutils.core.setup(**attrs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "/usr/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 158, in setup
            dist.parse_config_files()
          File "/usr/lib/python3.11/site-packages/setuptools/dist.py", line 614, in parse_config_files
            pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
          File "/usr/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 70, in apply_configuration
            config = read_configuration(filepath, True, ignore_option_errors, dist)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "/usr/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 135, in read_configuration
            validate(subset, filepath)
          File "/usr/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']
        ERROR Backend subprocess exited when trying to invoke build_wheel

@threexc
Copy link
Contributor Author

threexc commented Jul 28, 2025

setuptools requirement should've been bumped in pyproject.toml when this change was made.

        Traceback (most recent call last):
          File "/usr/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
            main()
          File "/usr/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in main
            json_out["return_val"] = hook(**hook_input["kwargs"])
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "/usr/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 280, in build_wheel
            return _build_backend().build_wheel(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "/usr/lib/python3.11/site-packages/setuptools/build_meta.py", line 415, in build_wheel
            return self._build_with_temp_dir(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "/usr/lib/python3.11/site-packages/setuptools/build_meta.py", line 397, in _build_with_temp_dir
            self.run_setup()
          File "/usr/lib/python3.11/site-packages/setuptools/build_meta.py", line 313, in run_setup
            exec(code, locals())
          File "<string>", line 60, in <module>
          File "/usr/lib/python3.11/site-packages/setuptools/__init__.py", line 108, in setup
            return distutils.core.setup(**attrs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "/usr/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 158, in setup
            dist.parse_config_files()
          File "/usr/lib/python3.11/site-packages/setuptools/dist.py", line 614, in parse_config_files
            pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
          File "/usr/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 70, in apply_configuration
            config = read_configuration(filepath, True, ignore_option_errors, dist)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "/usr/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 135, in read_configuration
            validate(subset, filepath)
          File "/usr/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']
        ERROR Backend subprocess exited when trying to invoke build_wheel

My bad, thanks for pointing this out. I'll submit a new PR.

threexc added a commit to threexc/maturin that referenced this pull request Jul 28, 2025
Make sure we use setuptools 77.0.0 or newer, which ensures PEP 639
support. This should've been bumped along with the changes in 7402a48,
otherwise the user can run into errors like the following:

|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 Backend subprocess exited when trying to invoke build_wheel

See also PyO3#2690.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
messense pushed a commit that referenced this pull request Jul 30, 2025
Make sure we use setuptools 77.0.0 or newer, which ensures PEP 639
support. This should've been bumped along with the changes in 7402a48,
otherwise the user can run into errors like the following:

|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 Backend subprocess exited when trying to invoke build_wheel

See also #2690.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Aug 6, 2025
https://build.opensuse.org/request/show/1297806
by user mia + dimstar_suse
- Update to 1.9.3
  * Add support for RISC-V architecture in manylinux
    gh#PyO3/maturin#2694
  * pyproject.toml: bump setuptools for PEP 639
    gh#PyO3/maturin#2698
  * Fix PEP 639 support for source distributions
    gh#PyO3/maturin#2704
  * Fix relative README rewrite in source distributions
    gh#PyO3/maturin#2705

- Update to 1.9.2
  * Respect PEP 621 dynamic fields when merging Cargo.toml metadata
    gh#PyO3/maturin#2672
  * Only use all_features=true in sdist when local path
    dependencies exist
    gh#PyO3/maturin#2674
  * auditwheel: add manylinux_2_26 policy
    gh#PyO3/maturin#2677
  * Use user-specified library search paths in RUSTFLAGS in
    auditwheel
    gh#PyO3/maturin#2676
  * pyproject.toml: add license-files
    gh#PyO3/maturin#2690
  * Update manylinux/musllinux
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.

maturin wheels don't contain any license files
3 participants