Skip to content

Support for License-Expression field#465

Merged
gaborbernat merged 4 commits intotox-dev:mainfrom
PalmtopTiger:license-expression-support
Mar 24, 2025
Merged

Support for License-Expression field#465
gaborbernat merged 4 commits intotox-dev:mainfrom
PalmtopTiger:license-expression-support

Conversation

@PalmtopTiger
Copy link
Copy Markdown
Contributor

Allows to display a license for projects with a new License-Expression field. For example, pipdeptree itself.

https://peps.python.org/pep-0639/#add-license-expression-field

@gaborbernat gaborbernat requested a review from kemzeb March 20, 2025 14:44
Copy link
Copy Markdown
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to add test for your change 👍

@PalmtopTiger
Copy link
Copy Markdown
Contributor Author

Done

Copy link
Copy Markdown
Collaborator

@kemzeb kemzeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! The implementation and tests appear fine, but from testing I did notice the following:

pipdeptree --license -d 0
. . .
tox==4.24.1 (MIT, MIT License)
. . .

We have both the License-Expression and a Classifier field that represent the same license. I'm not sure if this is fine.

I think we could just use the License-Expression field if there are license classifiers also defined. Otherwise use the license classifiers.

Reading this section in the PEP, it explains that "if the License-Expression field is present, build tools MAY raise an error if one or more license classifiers is included in a Classifier field". Not too big of a fan of the use of "MAY", but in my opinion it is the responsibility of project maintainers to define their licenses correctly in their project metadata. To me it would be weird if some licenses were defined in one place and some in another.

@PalmtopTiger
Copy link
Copy Markdown
Contributor Author

No, it's not fine, judging by the fact that setuptools v77 doesn't allow you to install a package where license expression and license classifier are specified at the same time.

I also think that only license expression should be returned if it is available. That's why I placed the code for getting it above the old code. Since you think the same, I've reworked the code.

Copy link
Copy Markdown
Collaborator

@kemzeb kemzeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gaborbernat gaborbernat merged commit 549743a into tox-dev:main Mar 24, 2025
20 of 21 checks passed
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