Skip to content

Commit 55f547e

Browse files
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 <ayansmahapatra@gmail.com>
1 parent ca7fb71 commit 55f547e

2 files changed

Lines changed: 8 additions & 219 deletions

File tree

src/packagedcode/pypi.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,14 @@ class PythonSdistPkgInfoFile(BaseExtractedPythonLayout):
268268
description = 'PyPI extracted sdist PKG-INFO'
269269
documentation_url = 'https://peps.python.org/pep-0314/'
270270

271+
@classmethod
272+
def is_datafile(cls, location):
273+
return (
274+
super().is_datafile(location) and
275+
not PythonEggPkgInfoFile.is_datafile(location) and
276+
not PythonEditableInstallationPkgInfoFile.is_datafile(location)
277+
)
278+
271279
@classmethod
272280
def parse(cls, location):
273281
yield parse_metadata(

tests/packagedcode/data/pypi/source-package/pip-22.0.4-pypi-package-expected.json

Lines changed: 0 additions & 219 deletions
Original file line numberDiff line numberDiff line change
@@ -725,225 +725,6 @@
725725
"api_data_url": "https://pypi.org/pypi/pip/22.0.4/json",
726726
"datasource_id": "pypi_editable_egg_pkginfo",
727727
"purl": "pkg:pypi/pip@22.0.4"
728-
},
729-
{
730-
"type": "pypi",
731-
"namespace": null,
732-
"name": "pip",
733-
"version": "22.0.4",
734-
"qualifiers": {},
735-
"subpath": null,
736-
"primary_language": "Python",
737-
"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",
738-
"release_date": null,
739-
"parties": [
740-
{
741-
"type": "person",
742-
"role": "author",
743-
"name": "The pip developers",
744-
"email": "distutils-sig@python.org",
745-
"url": null
746-
}
747-
],
748-
"keywords": [
749-
"Development Status :: 5 - Production/Stable",
750-
"Intended Audience :: Developers",
751-
"Topic :: Software Development :: Build Tools",
752-
"Programming Language :: Python",
753-
"Programming Language :: Python :: 3",
754-
"Programming Language :: Python :: 3 :: Only",
755-
"Programming Language :: Python :: 3.7",
756-
"Programming Language :: Python :: 3.8",
757-
"Programming Language :: Python :: 3.9",
758-
"Programming Language :: Python :: 3.10",
759-
"Programming Language :: Python :: Implementation :: CPython",
760-
"Programming Language :: Python :: Implementation :: PyPy"
761-
],
762-
"homepage_url": "https://pip.pypa.io/",
763-
"download_url": null,
764-
"size": null,
765-
"sha1": null,
766-
"md5": null,
767-
"sha256": null,
768-
"sha512": null,
769-
"bug_tracking_url": null,
770-
"code_view_url": "Source, https://github.com/pypa/pip",
771-
"vcs_url": null,
772-
"copyright": null,
773-
"license_expression": "mit AND mit",
774-
"declared_license": {
775-
"license": "MIT",
776-
"classifiers": [
777-
"License :: OSI Approved :: MIT License"
778-
]
779-
},
780-
"notice_text": null,
781-
"source_packages": [],
782-
"file_references": [
783-
{
784-
"path": "AUTHORS.txt",
785-
"size": null,
786-
"sha1": null,
787-
"md5": null,
788-
"sha256": null,
789-
"sha512": null,
790-
"extra_data": {}
791-
},
792-
{
793-
"path": "LICENSE.txt",
794-
"size": null,
795-
"sha1": null,
796-
"md5": null,
797-
"sha256": null,
798-
"sha512": null,
799-
"extra_data": {}
800-
},
801-
{
802-
"path": "MANIFEST.in",
803-
"size": null,
804-
"sha1": null,
805-
"md5": null,
806-
"sha256": null,
807-
"sha512": null,
808-
"extra_data": {}
809-
},
810-
{
811-
"path": "NEWS.rst",
812-
"size": null,
813-
"sha1": null,
814-
"md5": null,
815-
"sha256": null,
816-
"sha512": null,
817-
"extra_data": {}
818-
},
819-
{
820-
"path": "README.rst",
821-
"size": null,
822-
"sha1": null,
823-
"md5": null,
824-
"sha256": null,
825-
"sha512": null,
826-
"extra_data": {}
827-
},
828-
{
829-
"path": "pyproject.toml",
830-
"size": null,
831-
"sha1": null,
832-
"md5": null,
833-
"sha256": null,
834-
"sha512": null,
835-
"extra_data": {}
836-
},
837-
{
838-
"path": "setup.cfg",
839-
"size": null,
840-
"sha1": null,
841-
"md5": null,
842-
"sha256": null,
843-
"sha512": null,
844-
"extra_data": {}
845-
},
846-
{
847-
"path": "setup.py",
848-
"size": null,
849-
"sha1": null,
850-
"md5": null,
851-
"sha256": null,
852-
"sha512": null,
853-
"extra_data": {}
854-
},
855-
{
856-
"path": "src/pip/__init__.py",
857-
"size": null,
858-
"sha1": null,
859-
"md5": null,
860-
"sha256": null,
861-
"sha512": null,
862-
"extra_data": {}
863-
},
864-
{
865-
"path": "src/pip/__main__.py",
866-
"size": null,
867-
"sha1": null,
868-
"md5": null,
869-
"sha256": null,
870-
"sha512": null,
871-
"extra_data": {}
872-
},
873-
{
874-
"path": "src/pip/py.typed",
875-
"size": null,
876-
"sha1": null,
877-
"md5": null,
878-
"sha256": null,
879-
"sha512": null,
880-
"extra_data": {}
881-
},
882-
{
883-
"path": "src/pip.egg-info/PKG-INFO",
884-
"size": null,
885-
"sha1": null,
886-
"md5": null,
887-
"sha256": null,
888-
"sha512": null,
889-
"extra_data": {}
890-
},
891-
{
892-
"path": "src/pip.egg-info/SOURCES.txt",
893-
"size": null,
894-
"sha1": null,
895-
"md5": null,
896-
"sha256": null,
897-
"sha512": null,
898-
"extra_data": {}
899-
},
900-
{
901-
"path": "src/pip.egg-info/dependency_links.txt",
902-
"size": null,
903-
"sha1": null,
904-
"md5": null,
905-
"sha256": null,
906-
"sha512": null,
907-
"extra_data": {}
908-
},
909-
{
910-
"path": "src/pip.egg-info/entry_points.txt",
911-
"size": null,
912-
"sha1": null,
913-
"md5": null,
914-
"sha256": null,
915-
"sha512": null,
916-
"extra_data": {}
917-
},
918-
{
919-
"path": "src/pip.egg-info/not-zip-safe",
920-
"size": null,
921-
"sha1": null,
922-
"md5": null,
923-
"sha256": null,
924-
"sha512": null,
925-
"extra_data": {}
926-
},
927-
{
928-
"path": "src/pip.egg-info/top_level.txt",
929-
"size": null,
930-
"sha1": null,
931-
"md5": null,
932-
"sha256": null,
933-
"sha512": null,
934-
"extra_data": {}
935-
}
936-
],
937-
"extra_data": {
938-
"Documentation": "Documentation, https://pip.pypa.io",
939-
"Changelog": "Changelog, https://pip.pypa.io/en/stable/news/"
940-
},
941-
"dependencies": [],
942-
"repository_homepage_url": "https://pypi.org/project/pip",
943-
"repository_download_url": "https://pypi.org/packages/source/p/pip/pip-22.0.4.tar.gz",
944-
"api_data_url": "https://pypi.org/pypi/pip/22.0.4/json",
945-
"datasource_id": "pypi_sdist_pkginfo",
946-
"purl": "pkg:pypi/pip@22.0.4"
947728
}
948729
],
949730
"for_packages": [

0 commit comments

Comments
 (0)