Misleading license finding in PKG-INFO in case of --package option

Open
#5,454 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start by tracing how the --package option processes PKG-INFO and how license findings get their source line; the issue gives a reproducer and sample input but names no files or tests. Run the listed ScanCode command against the supplied PKG-INFO content and inspect the finding at line 1. Done means the reported license match points to text that actually contains the license, with a regression check for this case.

Written by the indexing model from the issue text.

Description

bug
Description

when the --package option is used in a Python package the ScanCode results show a finding in the 1st line of "PKG-INFO", however the first line does not contain any text about licenses.

How To Reproduce
pip download openai==2.41.1 --no-binary :all: --no-deps -d ./oai-sdist
tar -xzf ./oai-sdist/openai-2.41.1.tar.gz openai-2.41.1/PKG-INFO
scancode --license --copyright --license-score 90 --license-text --package --processes 4 --verbose --json-pp result.json openai-2.41.1/PKG-INFO

The result will contain

            {
              "license_expression": "apache-2.0",
              "license_expression_spdx": "Apache-2.0",
              "from_file": "PKG-INFO",
              "start_line": 1,
              "end_line": 1,
              "matcher": "1-hash",
              "score": 100.0,
              "matched_length": 3,
              "match_coverage": 100.0,
              "rule_relevance": 100,
              "rule_identifier": "spdx_license_id_apache-2.0_for_apache-2.0.RULE",
              "rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/spdx_license_id_apache-2.0_for_apache-2.0.RULE",
              "matched_text": "Apache-2.0"
            }

Even if the PKG-INFO content is

Metadata-Version: 2.3
Name: openai
Version: 2.41.1
Summary: The official Python library for the openai API
Project-URL: Homepage, https://github.com/openai/openai-python
Project-URL: Repository, https://github.com/openai/openai-python
Author-email: OpenAI <[email protected]>
License: Apache-2.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: MacOS

System configuration
    {
      "tool_name": "scancode-toolkit",
      "tool_version": "32.3.3",
      "options": {
        "input": [
          "openai-2.41.1/PKG-INFO"
        ],
        "--copyright": true,
        "--json-pp": "result.json",
        "--license": true,
        "--license-score": "90",
        "--license-text": true,
        "--package": true,
        "--processes": "4",
        "--verbose": true
      },
      "output_format_version": "4.0.0",
      "duration": 3.8503596782684326,
      "extra_data": {
        "system_environment": {
          "operating_system": "linux",
          "cpu_architecture": "64",
          "platform": "Linux-6.18.33.2-microsoft-standard-WSL2-x86_64-with-glibc2.43",
          "platform_version": "#1 SMP PREEMPT_DYNAMIC Thu Jun 18 21:54:43 UTC 2026",
          "python_version": "3.12.10 (main, Jul 28 2026, 10:06:18) [GCC 15.2.0]"
        },
        "spdx_license_list_version": "3.26",
        "files_count": 1
      }
    }

I've installed ScanCode with pip from a local source tree.

Dominant language
Python
Stars
2.7k
Forks
871
Avg merge
1d 10h
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aboutcode-org/scancode-toolkit

All issues in aboutcode-org/scancode-toolkit

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.