Skip to content

Conversation

MichaReiser
Copy link
Member

Reverts #19499

@AlexWaygood brought to light that the same change caused a lot of churn for typing_extensions users:

Just as an FYI, we received a lot of confused bug reports at typing_extensions after we made a similar change, due to some tooling not yet supporting PEP 639

Given that this causes significant churn without a very clear benefit for users, we decided to wait with this change until the ecosystem is further along.

@MichaReiser MichaReiser force-pushed the revert-19499-PEP639 branch from 6d09750 to 6a01c4d Compare July 28, 2025 13:57
@MichaReiser MichaReiser requested a review from konstin July 28, 2025 13:58
@AlexWaygood AlexWaygood changed the title Revert "Use PEP 639 license information for Ruff itself instead of classifier" Add license classifier back to pyproject.toml Jul 28, 2025
Co-authored-by: Alex Waygood <[email protected]>
@MichaReiser MichaReiser merged commit 4016aff into main Jul 28, 2025
53 checks passed
@MichaReiser MichaReiser deleted the revert-19499-PEP639 branch July 28, 2025 19:58
@vivodi
Copy link

vivodi commented Jul 31, 2025

Given that this causes significant churn without a very clear benefit for users, we decided to wait with this change until the ecosystem is further along.

However, typing_extensions has not reverted this change.

PEP 639 explicitly recommends removing the license classifier. Ruff should lead by example in adopting PEP 639 and encourage tools such as pip-license to follow suit.

Given its wide adoption, Ruff, like typing_extensions, bears a responsibility to help advance the Python ecosystem. @MichaReiser @AlexWaygood

@DimitriPapadopoulos
Copy link
Contributor

@AlexWaygood I understand the typing_extensions issues are caused by pip-licenses missing support for PEP 639 (raimon49/pip-licenses#225 and raimon49/pip-licenses#213), aren't they?

But then the Test Plan in #19624 (comment) seems to suggest that uv build --sdist might not add the LICENSE file to the package. @ntBre Could you shed some light on the actual problem with #19499?

@MichaReiser
Copy link
Member Author

But then the Test Plan in #19624 (comment) seems to suggest that uv build --sdist might not add the LICENSE file to the package. @ntBre Could you shed some light on the actual problem with #19499?

This is the reason why we reverted the entire change and it requires a fix to maturin first.

@DimitriPapadopoulos
Copy link
Contributor

DimitriPapadopoulos commented Jul 31, 2025

Are you certain this is an issue with maturin? In theory, maturin ≥ 1.9 is supposed to support PEP 639:
https://www.maturin.rs/changelog.html

As far as I can understand, this is an issue with pip-licenses which is unable to find the licensing information in package metadata. Are you really implying the licensing information is missing from package metadata?

According to https://github.com/raimon49/pip-licenses/blob/master/README.md#option-from:

this tool finds the license from Trove Classifiers or package Metadata.

Change #19499 does two things:

  1. Removing the classifier, which means pip-licenses will be unable to find licensing information in classifiers and should fall back to package metatdata.
  2. Modifying licensing declaration in pyproject.toml which modifies package metadata. I must admit I don't know which exact changes are applied by maturin, but see below the changes applied by setuptools.

Using setuptools, a pyproject.toml file looking like this:

license = {text = "GPL-3.0-or-later"}
classifiers = [
    "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
]

yields a PKG-INFO like this one, with the LICENSE file found without explicit declaration:

License: GPL-3.0-or-later
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
License-File: LICENSE

while such a pyproject.toml file:

license = "GPL-3.0-or-later"

yields a PKG-INFO like this one:

License-Expression: GPL-3.0-or-later
License-File: LICENSE

I believe pip-licences does not support the switch from License to License-Expression in package metadata, which is caused by the switch from license = {text = "..."} to license = "..." in pyproject.toml. However, this could be mitigated by keeping the Trove classifier for compatibility. How does this sound?

@zanieb
Copy link
Member

zanieb commented Jul 31, 2025

A maturin maintainer identified it as a bug https://github.com/PyO3/maturin/compare/konsti/add-license-files-to-sdist

@DimitriPapadopoulos
Copy link
Contributor

DimitriPapadopoulos commented Aug 1, 2025

Once the maturin bug is fixed, hopefully in release 1.9.3, perhaps #19499 can be reconsidered as #19661.

It turns out pip-licences is not much maintained and has been forked into pip-licenses-cli which does support PEP 639. Not sure it's worth taking it into account.

dcreager added a commit that referenced this pull request Aug 1, 2025
* main: (24 commits)
  Add `Checker::context` method, deduplicate Unicode checks (#19609)
  [`flake8-pyi`] Preserve inline comment in ellipsis removal (`PYI013`) (#19399)
  [ty] Add flow diagram for import resolution
  [ty] Add comments to some core resolver functions
  [ty] Add missing ticks and use consistent quoting
  [ty] Reflow some long lines
  [ty] Unexport helper function
  [ty] Remove offset from `CompletionTargetTokens::Unknown`
  [`pyupgrade`] Fix `UP030` to avoid modifying double curly braces in format strings (#19378)
  [ty] fix a typo  (#19621)
  [ty] synthesize `__replace__` for dataclasses (>=3.13) (#19545)
  [ty] Discard `Definition`s when normalizing `Signature`s (#19615)
  [ty] Fix empty spans following a line terminator and unprintable character spans in diagnostics (#19535)
  Add `LinterContext::settings` to avoid passing separate settings (#19608)
  Support `.pyi` files in ruff analyze graph (#19611)
  [ty] Sync vendored typeshed stubs (#19607)
  [ty] Bump docstring-adder pin (#19606)
  [`perflint`] Ignore rule if target is `global` or `nonlocal` (`PERF401`) (#19539)
  Add license classifier back to pyproject.toml (#19599)
  [ty] Add stub mapping support to signature help (#19570)
  ...
@konstin
Copy link
Member

konstin commented Aug 4, 2025

Maturin 1.9.3 with the fix for source dist license file inclusions is out

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.

6 participants