Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/python_inspector/utils_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import attr
import packageurl
import requests
import zipfile
from bs4 import BeautifulSoup
from commoncode import fileutils
from commoncode.hash import multi_checksums
Expand Down Expand Up @@ -1698,6 +1699,21 @@ async def get(

cache_valid = os.path.exists(cached) and os.path.getsize(cached) > 0

# Validate cached wheel/egg files.
if cache_valid and not as_text:
if path_or_url.endswith((".whl", ".egg", ".zip")):
try:
cached_resolved = os.path.realpath(cached)
if not zipfile.is_zipfile(cached_resolved):
if TRACE_DEEP:
print(f" FILE CACHE INVALID (corrupted zip): {path_or_url}")
cache_valid = False
except (FileNotFoundError, OSError):
# File was deleted/modified by another task - treat as cache miss
if TRACE_DEEP:
print(f" FILE CACHE VANISHED during validation: {path_or_url}")
cache_valid = False

if force or not cache_valid:
if not cache_valid and os.path.exists(cached):
if TRACE_DEEP:
Expand Down
108 changes: 56 additions & 52 deletions tests/data/azure-devops.req-310-expected.json

Large diffs are not rendered by default.

108 changes: 56 additions & 52 deletions tests/data/azure-devops.req-312-expected.json

Large diffs are not rendered by default.

108 changes: 56 additions & 52 deletions tests/data/azure-devops.req-313-expected.json

Large diffs are not rendered by default.

108 changes: 56 additions & 52 deletions tests/data/azure-devops.req-314-expected.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions tests/data/azure-devops.req-38-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,12 @@
"type": "pypi",
"namespace": null,
"name": "certifi",
"version": "2025.10.5",
"version": "2026.1.4",
"qualifiers": {},
"subpath": null,
"primary_language": "Python",
"description": "Python package for providing Mozilla's CA Bundle.\nCertifi: Python SSL Certificates\n================================\n\nCertifi provides Mozilla's carefully curated collection of Root Certificates for\nvalidating the trustworthiness of SSL certificates while verifying the identity\nof TLS hosts. It has been extracted from the `Requests`_ project.\n\nInstallation\n------------\n\n``certifi`` is available on PyPI. Simply install it with ``pip``::\n\n $ pip install certifi\n\nUsage\n-----\n\nTo reference the installed certificate authority (CA) bundle, you can use the\nbuilt-in function::\n\n >>> import certifi\n\n >>> certifi.where()\n '/usr/local/lib/python3.7/site-packages/certifi/cacert.pem'\n\nOr from the command line::\n\n $ python -m certifi\n /usr/local/lib/python3.7/site-packages/certifi/cacert.pem\n\nEnjoy!\n\n.. _`Requests`: https://requests.readthedocs.io/en/master/\n\nAddition/Removal of Certificates\n--------------------------------\n\nCertifi does not support any addition/removal or other modification of the\nCA trust store content. This project is intended to provide a reliable and\nhighly portable root of trust to python deployments. Look to upstream projects\nfor methods to use alternate trust.",
"release_date": "2025-10-05T04:12:14",
"release_date": "2026-01-04T02:42:40",
"parties": [
{
"type": "person",
Expand All @@ -349,11 +349,11 @@
"Programming Language :: Python :: 3.9"
],
"homepage_url": "https://github.com/certifi/python-certifi",
"download_url": "https://files.pythonhosted.org/packages/e4/37/af0d2ef3967ac0d6113837b44a4f0bfe1328c2b9763bd5b1744520e5cfed/certifi-2025.10.5-py3-none-any.whl",
"size": 163286,
"download_url": "https://files.pythonhosted.org/packages/e6/ad/3cc14f097111b4de0040c83a525973216457bbeeb63739ef1ed275c1c021/certifi-2026.1.4-py3-none-any.whl",
"size": 152900,
"sha1": null,
"md5": "7b56f7121949a196441739c539fd01be",
"sha256": "0f212c2744a9bb6de0c56639a6f68afe01ecd92d91f14ae897c4fe7bbeeef0de",
"md5": "1dab98768140ad2d8dbc9be8f14a2af9",
"sha256": "9943707519e4add1115f44c2bc244f782c0249876bf51b6599fee1ffbedd685c",
"sha512": null,
"bug_tracking_url": null,
"code_view_url": "https://github.com/certifi/python-certifi",
Expand All @@ -373,9 +373,9 @@
"dependencies": [],
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": "https://pypi.org/pypi/certifi/2025.10.5/json",
"api_data_url": "https://pypi.org/pypi/certifi/2026.1.4/json",
"datasource_id": null,
"purl": "pkg:pypi/certifi@2025.10.5"
"purl": "pkg:pypi/certifi@2026.1.4"
},
{
"type": "pypi",
Expand Down Expand Up @@ -1334,7 +1334,7 @@
]
},
{
"package": "pkg:pypi/certifi@2025.10.5",
"package": "pkg:pypi/certifi@2026.1.4",
"dependencies": []
},
{
Expand Down Expand Up @@ -1369,7 +1369,7 @@
"package": "pkg:pypi/[email protected]",
"dependencies": [
"pkg:pypi/[email protected]",
"pkg:pypi/certifi@2025.10.5",
"pkg:pypi/certifi@2026.1.4",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]"
Expand All @@ -1393,7 +1393,7 @@
{
"package": "pkg:pypi/[email protected]",
"dependencies": [
"pkg:pypi/certifi@2025.10.5",
"pkg:pypi/certifi@2026.1.4",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]"
Expand Down
72 changes: 33 additions & 39 deletions tests/data/example-requirements-ignore-errors-expected.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions tests/data/hash-requirements.txt-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@
"type": "pypi",
"namespace": null,
"name": "certifi",
"version": "2025.10.5",
"version": "2026.1.4",
"qualifiers": {},
"subpath": null,
"primary_language": "Python",
"description": "Python package for providing Mozilla's CA Bundle.\nCertifi: Python SSL Certificates\n================================\n\nCertifi provides Mozilla's carefully curated collection of Root Certificates for\nvalidating the trustworthiness of SSL certificates while verifying the identity\nof TLS hosts. It has been extracted from the `Requests`_ project.\n\nInstallation\n------------\n\n``certifi`` is available on PyPI. Simply install it with ``pip``::\n\n $ pip install certifi\n\nUsage\n-----\n\nTo reference the installed certificate authority (CA) bundle, you can use the\nbuilt-in function::\n\n >>> import certifi\n\n >>> certifi.where()\n '/usr/local/lib/python3.7/site-packages/certifi/cacert.pem'\n\nOr from the command line::\n\n $ python -m certifi\n /usr/local/lib/python3.7/site-packages/certifi/cacert.pem\n\nEnjoy!\n\n.. _`Requests`: https://requests.readthedocs.io/en/master/\n\nAddition/Removal of Certificates\n--------------------------------\n\nCertifi does not support any addition/removal or other modification of the\nCA trust store content. This project is intended to provide a reliable and\nhighly portable root of trust to python deployments. Look to upstream projects\nfor methods to use alternate trust.",
"release_date": "2025-10-05T04:12:14",
"release_date": "2026-01-04T02:42:40",
"parties": [
{
"type": "person",
Expand All @@ -201,11 +201,11 @@
"Programming Language :: Python :: 3.9"
],
"homepage_url": "https://github.com/certifi/python-certifi",
"download_url": "https://files.pythonhosted.org/packages/e4/37/af0d2ef3967ac0d6113837b44a4f0bfe1328c2b9763bd5b1744520e5cfed/certifi-2025.10.5-py3-none-any.whl",
"size": 163286,
"download_url": "https://files.pythonhosted.org/packages/e6/ad/3cc14f097111b4de0040c83a525973216457bbeeb63739ef1ed275c1c021/certifi-2026.1.4-py3-none-any.whl",
"size": 152900,
"sha1": null,
"md5": "7b56f7121949a196441739c539fd01be",
"sha256": "0f212c2744a9bb6de0c56639a6f68afe01ecd92d91f14ae897c4fe7bbeeef0de",
"md5": "1dab98768140ad2d8dbc9be8f14a2af9",
"sha256": "9943707519e4add1115f44c2bc244f782c0249876bf51b6599fee1ffbedd685c",
"sha512": null,
"bug_tracking_url": null,
"code_view_url": "https://github.com/certifi/python-certifi",
Expand All @@ -225,9 +225,9 @@
"dependencies": [],
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": "https://pypi.org/pypi/certifi/2025.10.5/json",
"api_data_url": "https://pypi.org/pypi/certifi/2026.1.4/json",
"datasource_id": null,
"purl": "pkg:pypi/certifi@2025.10.5"
"purl": "pkg:pypi/certifi@2026.1.4"
},
{
"type": "pypi",
Expand Down Expand Up @@ -514,7 +514,7 @@
"dependencies": []
},
{
"package": "pkg:pypi/certifi@2025.10.5",
"package": "pkg:pypi/certifi@2026.1.4",
"dependencies": []
},
{
Expand All @@ -528,7 +528,7 @@
{
"package": "pkg:pypi/[email protected]",
"dependencies": [
"pkg:pypi/certifi@2025.10.5",
"pkg:pypi/certifi@2026.1.4",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]"
Expand Down
12 changes: 6 additions & 6 deletions tests/data/resolved_deps/flask-310-expected.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[
[
{
"package": "pkg:pypi/[email protected].0",
"package": "pkg:pypi/[email protected].1",
"dependencies": []
},
{
"package": "pkg:pypi/[email protected]",
"dependencies": [
"pkg:pypi/[email protected].0",
"pkg:pypi/[email protected].1",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected].3"
"pkg:pypi/[email protected].5"
]
},
{
Expand All @@ -28,18 +28,18 @@
"dependencies": []
},
{
"package": "pkg:pypi/[email protected].3",
"package": "pkg:pypi/[email protected].5",
"dependencies": [
"pkg:pypi/[email protected]"
]
}
],
[
"pkg:pypi/[email protected].0",
"pkg:pypi/[email protected].1",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected].3"
"pkg:pypi/[email protected].5"
]
]
12 changes: 6 additions & 6 deletions tests/data/resolved_deps/flask-310-win-expected.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
[
{
"package": "pkg:pypi/[email protected].0",
"package": "pkg:pypi/[email protected].1",
"dependencies": [
"pkg:pypi/[email protected]"
]
Expand All @@ -13,10 +13,10 @@
{
"package": "pkg:pypi/[email protected]",
"dependencies": [
"pkg:pypi/[email protected].0",
"pkg:pypi/[email protected].1",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected].3"
"pkg:pypi/[email protected].5"
]
},
{
Expand All @@ -34,19 +34,19 @@
"dependencies": []
},
{
"package": "pkg:pypi/[email protected].3",
"package": "pkg:pypi/[email protected].5",
"dependencies": [
"pkg:pypi/[email protected]"
]
}
],
[
"pkg:pypi/[email protected].0",
"pkg:pypi/[email protected].1",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected].3"
"pkg:pypi/[email protected].5"
]
]
12 changes: 6 additions & 6 deletions tests/data/resolved_deps/flask-39-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"package": "pkg:pypi/[email protected]",
"dependencies": [
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected].0",
"pkg:pypi/[email protected].1",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected].3"
"pkg:pypi/[email protected].5"
]
},
{
"package": "pkg:pypi/[email protected].0",
"package": "pkg:pypi/[email protected].1",
"dependencies": [
"pkg:pypi/[email protected]"
]
Expand All @@ -35,7 +35,7 @@
"dependencies": []
},
{
"package": "pkg:pypi/[email protected].3",
"package": "pkg:pypi/[email protected].5",
"dependencies": [
"pkg:pypi/[email protected]"
]
Expand All @@ -48,11 +48,11 @@
[
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected].0",
"pkg:pypi/[email protected].1",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected]",
"pkg:pypi/[email protected].3",
"pkg:pypi/[email protected].5",
"pkg:pypi/[email protected]"
]
]
Loading