Skip to content

Show License-Expression if present in package metadata#13145

Merged
pfmoore merged 1 commit into
pypa:mainfrom
befeleme:pip-show-pep639
Jan 21, 2025
Merged

Show License-Expression if present in package metadata#13145
pfmoore merged 1 commit into
pypa:mainfrom
befeleme:pip-show-pep639

Conversation

@befeleme

@befeleme befeleme commented Jan 7, 2025

Copy link
Copy Markdown
Contributor

With Core Metadata 2.4 a new field, License-Expression, has been added. If it's present, favor it over the deprecated (with PEP 639) legacy unstructured License field.

Closes: #13112

@pfmoore

pfmoore commented Jan 7, 2025

Copy link
Copy Markdown
Member

Could you add a test for the new output? Thanks.

@ichard26

ichard26 commented Jan 8, 2025

Copy link
Copy Markdown
Member

Also, it looks like CI is failing as the ubuntu-latest worker is now running Ubuntu 24.04 LTS which doesn't ship with subversion. We'll take a look when we can.

@befeleme

befeleme commented Jan 9, 2025

Copy link
Copy Markdown
Contributor Author

Could you add a test for the new output? Thanks.

I'm trying to, but have a hard time with simulating the data - do I have to create a package with new metadata in order to make pip "install" it and then assert the output? Any pointers will be appreciated.

One more thing is, when pip itself moves to PEP 639 & setuptools supports it, this won't be true anymore:
https://github.com/pypa/pip/blob/main/tests/functional/test_show.py#L229
I may make test future-proof and assert the expected key per the version of metadata and existence of the field.
Or just wait for the moment to happen and then make a single change in the code.

@pfmoore

pfmoore commented Jan 9, 2025

Copy link
Copy Markdown
Member

I'm trying to, but have a hard time with simulating the data - do I have to create a package with new metadata in order to make pip "install" it and then assert the output? Any pointers will be appreciated.

You might have to - there's some examples in test_show.py which install a pre-built wheel and show it. See test_show_with_files_from_wheel for an example. Alternatively, you could write a unit test that just exercises print_results with artificial inputs - there's no need to get too clever here.

@notatallshaw

Copy link
Copy Markdown
Member

FYI, CI should be working again, if you merge from main.

With Core Metadata 2.4 a new field, License-Expression, has been added.
If it's present, favor it over the deprecated (with PEP 639) legacy
unstructured License field.

Closes: pypa#13112
@befeleme

Copy link
Copy Markdown
Contributor Author

Took me a while, but there are two tests added.

@pfmoore pfmoore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@pfmoore
pfmoore merged commit c7fb1e1 into pypa:main Jan 21, 2025
@pfmoore

pfmoore commented Jan 21, 2025

Copy link
Copy Markdown
Member

Thanks for the contribution!

@befeleme
befeleme deleted the pip-show-pep639 branch January 21, 2025 18:03
@ichard26

Copy link
Copy Markdown
Member

Thank you indeed. Congratulations on the PEP! 🎉

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Feb 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pip show displays License metadata field - switch to License-Expression?

4 participants