Skip to content
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

Added '--from=all' option #86

Merged
merged 2 commits into from
Dec 28, 2020
Merged

Added '--from=all' option #86

merged 2 commits into from
Dec 28, 2020

Conversation

cdce8p
Copy link
Contributor

@cdce8p cdce8p commented Dec 20, 2020

At the moment pip-licenses can only output either the metadata or the classifier license information.
This PR adds the --from=all option that displays both license information at the same time .

Background
PEP 639 specified how Python packages are supposed to define license information going forward. The preferred way is to use the license metadata field with SPDX license expression syntax. Although not officially deprecated, the trove classifiers will slowly be phased out and won't receive any more updates.
Since the PEP is only from Aug-2019, most packages still use the trove class and/or have outdated/invalid metadata license information. With the proposed option, it will be easier to compare the used licenses.

Going forward

  • --from=mixed still prefers the classifier over metadata information. Changing this would be a big breaking change and probably confuse many users. Therefore I'm not sure if it will be worth it. At least not for now.
  • Update the metadata license information for pip-licenses to just MIT to conform with the SPDX identifier.
  • Try parsing the metadata license field and extracting SPDX identifiers.

Ideas

  • Add option to auto-convert classifier to SPDX identifier (when possible, eg. only in simple cases)
  • Parse SPDX license expression to better evaluate fail / allow
  • Add license pinning, would be useful for CI integrations to require manual approval if license for specific package changes. This would probably work best with a config file.

--

Next steps for this PR

  • Finalize implementation details
  • Add test case(s)

* list both metadata and classifier license information
@codecov
Copy link

codecov bot commented Dec 20, 2020

Codecov Report

Merging #86 (45098f7) into master (5ae0255) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #86      +/-   ##
==========================================
+ Coverage   98.86%   98.87%   +0.01%     
==========================================
  Files           1        1              
  Lines         353      357       +4     
==========================================
+ Hits          349      353       +4     
  Misses          4        4              
Impacted Files Coverage Δ
piplicenses.py 98.87% <100.00%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ae0255...45098f7. Read the comment docs.

@raimon49
Copy link
Owner

@cdce8p Thanks for the info on PEP 639. I will review and feedback on your branch at a later date.

  • Update the metadata license information for pip-licenses to just MIT to conform with the SPDX identifier.

Yes, this will be a task I will tackle when I release the next version 😉

@raimon49
Copy link
Owner

This discussion is also related to issue #72 .

license_from_classifier = ', '.join(licenses)

return license_from_classifier
return licenses
Copy link
Owner

Choose a reason for hiding this comment

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

Just my little opinion, the return value of the function find_license_from_classifier was changed from str to list, which made other implementation and test codes more complicated.

But it's not important enough to oppose the merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right that it made the commit a bit more complicated. However I believe this is the better solution here. Changing the responsibility of this function to only extract the license classifier might make the work down the line a bit easier.

@raimon49
Copy link
Owner

@cdce8p I've checked your patch. I'm glad you worked with attention to compatibility.

I am positive that I will merge this patch. I hope to move on to the next step.

@cdce8p
Copy link
Contributor Author

cdce8p commented Dec 27, 2020

Thanks for taking the time to review my changes. I went ahead and added a test case for the change.
The PR should be good on my part now. Let me know if there is anything else I should do.

Copy link
Owner

@raimon49 raimon49 left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution.

This feature will be in the next release, 3.2.0.

@raimon49 raimon49 merged commit 1aaf796 into raimon49:master Dec 28, 2020
@raimon49
Copy link
Owner

Version 3.2.0 has just been released!
https://pypi.org/project/pip-licenses/3.2.0/

@cdce8p cdce8p deleted the from-all branch December 28, 2020 06:24
@cdce8p cdce8p mentioned this pull request Jan 20, 2021
@cdce8p cdce8p mentioned this pull request Feb 26, 2021
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.

2 participants