From 55f547e89f219a194cb5e126670895ef47358f72 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Wed, 11 May 2022 21:24:36 +0530 Subject: [PATCH] Modify pypi PKG-INFO parse Reference: #2943 Do not return 2 PackageData objects when there are PKG-INFO files. Signed-off-by: Ayan Sinha Mahapatra --- src/packagedcode/pypi.py | 8 + .../pip-22.0.4-pypi-package-expected.json | 219 ------------------ 2 files changed, 8 insertions(+), 219 deletions(-) diff --git a/src/packagedcode/pypi.py b/src/packagedcode/pypi.py index 518a046e66f..3c83b656ba9 100644 --- a/src/packagedcode/pypi.py +++ b/src/packagedcode/pypi.py @@ -268,6 +268,14 @@ class PythonSdistPkgInfoFile(BaseExtractedPythonLayout): description = 'PyPI extracted sdist PKG-INFO' documentation_url = 'https://peps.python.org/pep-0314/' + @classmethod + def is_datafile(cls, location): + return ( + super().is_datafile(location) and + not PythonEggPkgInfoFile.is_datafile(location) and + not PythonEditableInstallationPkgInfoFile.is_datafile(location) + ) + @classmethod def parse(cls, location): yield parse_metadata( diff --git a/tests/packagedcode/data/pypi/source-package/pip-22.0.4-pypi-package-expected.json b/tests/packagedcode/data/pypi/source-package/pip-22.0.4-pypi-package-expected.json index 9fdb84eb8ae..65b456967dc 100644 --- a/tests/packagedcode/data/pypi/source-package/pip-22.0.4-pypi-package-expected.json +++ b/tests/packagedcode/data/pypi/source-package/pip-22.0.4-pypi-package-expected.json @@ -725,225 +725,6 @@ "api_data_url": "https://pypi.org/pypi/pip/22.0.4/json", "datasource_id": "pypi_editable_egg_pkginfo", "purl": "pkg:pypi/pip@22.0.4" - }, - { - "type": "pypi", - "namespace": null, - "name": "pip", - "version": "22.0.4", - "qualifiers": {}, - "subpath": null, - "primary_language": "Python", - "description": "The PyPA recommended tool for installing Python packages.\npip - The Python Package Installer\n==================================\n\n.. image:: https://img.shields.io/pypi/v/pip.svg\n :target: https://pypi.org/project/pip/\n\n.. image:: https://readthedocs.org/projects/pip/badge/?version=latest\n :target: https://pip.pypa.io/en/latest\n\npip is the `package installer`_ for Python. You can use pip to install packages from the `Python Package Index`_ and other indexes.\n\nPlease take a look at our documentation for how to install and use pip:\n\n* `Installation`_\n* `Usage`_\n\nWe release updates regularly, with a new version every 3 months. Find more details in our documentation:\n\n* `Release notes`_\n* `Release process`_\n\nIn pip 20.3, we've `made a big improvement to the heart of pip`_; `learn more`_. We want your input, so `sign up for our user experience research studies`_ to help us do it right.\n\n**Note**: pip 21.0, in January 2021, removed Python 2 support, per pip's `Python 2 support policy`_. Please migrate to Python 3.\n\nIf you find bugs, need help, or want to talk to the developers, please use our mailing lists or chat rooms:\n\n* `Issue tracking`_\n* `Discourse channel`_\n* `User IRC`_\n\nIf you want to get involved head over to GitHub to get the source code, look at our development documentation and feel free to jump on the developer mailing lists and chat rooms:\n\n* `GitHub page`_\n* `Development documentation`_\n* `Development mailing list`_\n* `Development IRC`_\n\nCode of Conduct\n---------------\n\nEveryone interacting in the pip project's codebases, issue trackers, chat\nrooms, and mailing lists is expected to follow the `PSF Code of Conduct`_.\n\n.. _package installer: https://packaging.python.org/guides/tool-recommendations/\n.. _Python Package Index: https://pypi.org\n.. _Installation: https://pip.pypa.io/en/stable/installation/\n.. _Usage: https://pip.pypa.io/en/stable/\n.. _Release notes: https://pip.pypa.io/en/stable/news.html\n.. _Release process: https://pip.pypa.io/en/latest/development/release-process/\n.. _GitHub page: https://github.com/pypa/pip\n.. _Development documentation: https://pip.pypa.io/en/latest/development\n.. _made a big improvement to the heart of pip: https://pyfound.blogspot.com/2020/11/pip-20-3-new-resolver.html\n.. _learn more: https://pip.pypa.io/en/latest/user_guide/#changes-to-the-pip-dependency-resolver-in-20-3-2020\n.. _sign up for our user experience research studies: https://pyfound.blogspot.com/2020/03/new-pip-resolver-to-roll-out-this-year.html\n.. _Python 2 support policy: https://pip.pypa.io/en/latest/development/release-process/#python-2-support\n.. _Issue tracking: https://github.com/pypa/pip/issues\n.. _Discourse channel: https://discuss.python.org/c/packaging\n.. _Development mailing list: https://mail.python.org/mailman3/lists/distutils-sig.python.org/\n.. _User IRC: https://kiwiirc.com/nextclient/#ircs://irc.libera.chat:+6697/pypa\n.. _Development IRC: https://kiwiirc.com/nextclient/#ircs://irc.libera.chat:+6697/pypa-dev\n.. _PSF Code of Conduct: https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md", - "release_date": null, - "parties": [ - { - "type": "person", - "role": "author", - "name": "The pip developers", - "email": "distutils-sig@python.org", - "url": null - } - ], - "keywords": [ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Topic :: Software Development :: Build Tools", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy" - ], - "homepage_url": "https://pip.pypa.io/", - "download_url": null, - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "bug_tracking_url": null, - "code_view_url": "Source, https://github.com/pypa/pip", - "vcs_url": null, - "copyright": null, - "license_expression": "mit AND mit", - "declared_license": { - "license": "MIT", - "classifiers": [ - "License :: OSI Approved :: MIT License" - ] - }, - "notice_text": null, - "source_packages": [], - "file_references": [ - { - "path": "AUTHORS.txt", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "LICENSE.txt", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "MANIFEST.in", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "NEWS.rst", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "README.rst", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "pyproject.toml", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "setup.cfg", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "setup.py", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "src/pip/__init__.py", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "src/pip/__main__.py", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "src/pip/py.typed", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "src/pip.egg-info/PKG-INFO", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "src/pip.egg-info/SOURCES.txt", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "src/pip.egg-info/dependency_links.txt", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "src/pip.egg-info/entry_points.txt", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "src/pip.egg-info/not-zip-safe", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - }, - { - "path": "src/pip.egg-info/top_level.txt", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "extra_data": {} - } - ], - "extra_data": { - "Documentation": "Documentation, https://pip.pypa.io", - "Changelog": "Changelog, https://pip.pypa.io/en/stable/news/" - }, - "dependencies": [], - "repository_homepage_url": "https://pypi.org/project/pip", - "repository_download_url": "https://pypi.org/packages/source/p/pip/pip-22.0.4.tar.gz", - "api_data_url": "https://pypi.org/pypi/pip/22.0.4/json", - "datasource_id": "pypi_sdist_pkginfo", - "purl": "pkg:pypi/pip@22.0.4" } ], "for_packages": [