Skip to content

Make sure setuptools is compatible with PEP 639 #10512

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DimitriPapadopoulos
Copy link
Contributor

@DimitriPapadopoulos DimitriPapadopoulos commented Jul 7, 2025

Instead rely on project.license in pyproject.toml.

Let's see if this fixes this CI error:

         /home/runner/work/xarray/xarray/asv_bench/.asv/env/155223cc45b660fb8d622bace3e087eb/lib/python3.11/site-packages/setuptools_scm/_integration/setuptools.py:92: UserWarning: version of None already set
           warnings.warn(f"version of {dist_name} already set")
         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:
             "Apache-2.0"
   
         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"
                         ]
                     }
                 ]
             }
  • Closes #xxxx
  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst
  • New functions/methods are listed in api.rst

@DocOtak
Copy link
Contributor

DocOtak commented Jul 7, 2025

I think this error is saying that the thing in project.license needs to be an object, either:

{"text": "Apache-2.0"}

or

{"file": "LICENSE"}

which is a link to the file itself

@benbovy
Copy link
Member

benbovy commented Jul 7, 2025

@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented Jul 8, 2025

Right, requiring text = or file = means an old version of setuptools is being used. We need pypa/setuptools@fb161a2, which means seutptools ≥ 77.

However, if I understand you correctly, this is not compatible with Numpy 2.2:

"numpy": ["2.2"],

We'll probably have to partially revert #10300 and fall back to pre-PEP639 format. Wait, no, according to #10355 there's more to that.

I guess the real question is why I saw this issue surface recently in CI tests?

@DimitriPapadopoulos DimitriPapadopoulos changed the title Get rid of LICENSE file Make sure setuptools is compatible with PEP 939 Jul 8, 2025
@DimitriPapadopoulos DimitriPapadopoulos changed the title Make sure setuptools is compatible with PEP 939 Make sure setuptools is compatible with PEP 639 Jul 8, 2025
PEP 639 requires setuptools ≥ 77.

It seems customary to require setuptools ≥ 77.0.2 which irons out some
bugs related to PEP 639 support.
@DimitriPapadopoulos DimitriPapadopoulos force-pushed the LICENSE branch 2 times, most recently from 281ea27 to 7defc56 Compare July 8, 2025 05:54
@DimitriPapadopoulos DimitriPapadopoulos marked this pull request as ready for review July 8, 2025 05:55
@benbovy
Copy link
Member

benbovy commented Jul 8, 2025

I guess the real question is why I saw this issue surface recently in CI tests?

The error you mention above is from the asv benchmarks (only running CI after adding the corresponding label), for which Xarray is installed with --no-build-isolation. I tried to remove that flag in #10355 so a recent version of setutools can be picked without conflicting with numpy, but for some reason it didn't work.

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

Successfully merging this pull request may close these issues.

3 participants