Skip to content

Add --package-summary post-scan CLI flag for package-level summaries - #5390

Closed
aryan1234-l wants to merge 1 commit into
aboutcode-org:developfrom
aryan1234-l:package-summary
Closed

aryan1234-l wants to merge 1 commit into
aboutcode-org:developfrom
aryan1234-l:package-summary

Conversation

@aryan1234-l

Copy link
Copy Markdown

Summary

This PR implements the --package-summary post-scan CLI flag to compute package-level summaries, addressing #3802 and #3287.

Previously, scancode provided codebase-level summary and license clarity scoring via --summary / --license-clarity-score, but did not compute license clarity scores or summarized origin attributes for individual package instances.

Key Changes

  1. PackageSummary Post-Scan Plugin (src/packagedcode/plugin_package.py):

    • Registered package-summary plugin (scancode_post_scan entrypoint) running after PackageScanner.
    • Requires --package and --classify.
    • Iterates over codebase packages, associates them with their constituent files/resources, and computes package-level license_clarity_score and summary attributes (copyright, holder, notice_text, other_license_expression, and other_license_expression_spdx).
  2. Scoring Logic (src/summarycode/score.py):

    • Added get_field_values_from_resources() to directly work on Resource objects (using getattr(resource, 'is_key_file', False)), addressing previous review feedback on PR Improve License Clarity at Top Package Level #3792.
    • Refactored compute_license_score() to accept either codebase or resources while preserving its 2-tuple return (scoring_elements, declared_license_expression).
  3. Package Model Compatibility (src/packagedcode/models.py):

    • Added license_clarity_score attribute to Package(PackageData).
    • Conditionally included in Package.to_dict(package_summary=False) to prevent breaking or churning existing package scan fixtures across the codebase.
  4. Tests & Documentation:

    • Added end-to-end and unit tests in tests/packagedcode/test_package_summary.py covering npm, python wheels, rubygems, rust packages, and mock key file classification.
    • Updated CLI help fixtures (help.txt, help_linux.txt).
    • Added changelog entry in CHANGELOG.rst and author credit in AUTHORS.rst.

Fixes #3802
Fixes #3287

Signed-off-by: Aryan Gupta arynrav11@gmail.com

- Implement PackageSummary PostScanPlugin triggered by --package-summary
  requiring --package and --classify.
- Compute license_clarity_score and summarize copyright, holder, notice text,
  and other detected license expressions for each package instance from its
  key files and other files.
- Preserve backward compatibility of compute_license_score and avoid fixture
  churn across existing package scan tests by only returning license_clarity_score
  on packages when --package-summary is enabled.
- Add comprehensive test suite in tests/packagedcode/test_package_summary.py
  and update CLI help fixtures and documentation.

Resolves aboutcode-org#3802
Resolves aboutcode-org#3287

Signed-off-by: Aryan Gupta <arynrav11@gmail.com>
@AyanSinhaMahapatra

AyanSinhaMahapatra commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

If you're copying code from #3792 please use the original commits to show your specific changes, and what you're copying and what changes you've made yourself (and why you're creating a new PR).
Otherwise this is just plagiarism and spam.
Please reopen after using the original commits.

@aryan1234-l

Copy link
Copy Markdown
Author

If you're copying code from #3792 please use the original commits to show your specific changes, and what you're copying and what changes you've made yourself (and why you're creating a new PR).
Otherwise this is just plagiarism and spam.
Please reopen after using the original commits.

Ohh, ok, I'll leave s summary too of my and existing changes, I shall be working on this and once all CI checks pass then consider it. Thankyou for the feedback.

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.

Post Scan option --package-summary Compute summary and clarity for EACH package in a codebase

2 participants