`packages` is empty when using a non-pypi.org simple index (e.g. Sonatype Nexus)
還沒有人認領這個 Issue。
評估
研究方向
檢查 src/python_inspector/package_data.py 中的 get_pypi_data_from_purl(約在第 65–77 行),這裡會建立中繼資料 URL,且失敗時不會回傳資料。使用提供的兩個 python-inspector ... --json-pdt 指令(預設索引和一個 simple-index URL)重現問題,以確認 packages 為空的行為。追蹤回傳的中繼資料如何加入輸出,並透過檢查 jq '.packages[].name' 來驗證成功:確認非 pypi.org 索引中存在套件名稱。
由索引模型根據 Issue 內容生成。
描述
Currently the metadata fetch requires the pypi.org-specific JSON API. (See also #260 )
When PYINSP_INDEX_URL points at a non-pypi.org simple index (Sonatype Nexus PyPI in my case), python-inspector resolves dependencies but the packages array in the output is empty - package metadata is never fetched.
For example: PYINSP_INDEX_URL=https://my-nexus-pypi.com/repository/pypi/simple:
root@2ae255f06ad8:/project# python-inspector -p3.13 -rrequirements.txt -olinux --json-pdt /tmp/test.json --verbose
...
retrieve package data from pypi:
retrieved package 'pkg:pypi/[email protected]'
retrieved package 'pkg:pypi/[email protected]'
done!
root@2ae255f06ad8:/project# jq '.packages[].name' /tmp/test.json
# (no output - packages is [])
Note the verbose log claims retrieved package ..., yet packages is empty - the retrieval silently failed.
Without the index (default pypi.org) it works:
root@2ae255f06ad8:/project# env -u PYINSP_INDEX_URL python-inspector -p3.13 -rrequirements.txt -olinux --json-pdt /tmp/test.json --verbose
...
root@2ae255f06ad8:/project# jq '.packages[].name' /tmp/test.json
"cx-oracle"
"redis"
Root cause is the get_pypi_data_from_purl builds the metadata URL from the index base and queries the pypi.org-specific JSON API, then returns None on any non-200:
With a Nexus index this resolves to https://my-nexus-pypi.com/repository/pypi/pypi/redis/2.10.6/json, which 404s - Nexus's PyPI format implements the simple index (PEP 503), not the /pypi/<pkg>/<ver>/json API - so the function bails out and no PackageData is produced.
I initially assumed --use-pypi-json-api was the toggle for this. It doesn't help here: in its default (off) position get_pypi_data_from_purl still unconditionally queries the JSON API, and in the on position the help states --index-url is ignored (i.e. pypi.org), so it can't reach a private index either way.
I'm not sure what the correct approach would be, I feel like --use-pypi-json-api option should be fixed that way we download the selected sdist/wheel and parse its PKG-INFO for License / Home-page / Author / Requires-Dist. The simple index already provides the file list + digests, so the JSON API's urls are largely redundant; its unique value is the rich info block, which PKG-INFO also carries.
While searching for solution I've also stumbled upon PEP 691 https://packaging.python.org/en/latest/specifications/simple-repository-api/#json-based-simple-api-for-python-package-indexes
Which might be better than parsing of PKG-INFO (pkginfo package exists though, so it would be easy)
Either way, would like to hear the maintainers thoughts on that. If it something that should be fixed - I would try.
- 主要語言
- Python
- 星號
- 23
- 分支
- 29
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
aboutcode-org/python-inspector 的其他 Issue
-
Add support for pylock.toml可能已有人在做 @Anurag-S1ngh 於 6 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 35/100
aboutcode-org/python-inspector#259 · 1 則留言 ·
-
InconsistentCandidate: Pre-Release not allow可能已有人在做 @Anurag-S1ngh 於 6 天前認領。 未關閉bug design nice-to-have
難度 4/5 3-5 天 新手友好度 35/100
aboutcode-org/python-inspector#257 · 1 則留言 ·
-
Feature request: Mask repository credentials in --verbose output可能已有人在做 @Rajeshwari2857 於 7 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 58/100
aboutcode-org/python-inspector#254 · 4 則留言 · 4 個 reaction ·
-
Python Inspector version 0.15.0 contains the wrong version string可能已有人在做 @Anurag-S1ngh 於 6 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 45/100
aboutcode-org/python-inspector#253 · 1 則留言 ·
-
難度 3/5 1-2 天 新手友好度 52/100
aboutcode-org/python-inspector#246 · 2 則留言 · 2 個 reaction ·
查看 aboutcode-org/python-inspector 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
namespace operations
難度 1/5 1 小時以內 新手友好度 65/100
EclipseFdn/open-vsx.org#15057 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
FinanceFlash/unvibecode#349 ·
-
Mission statement: why this is free, in the README, Why This Exists and the wiki Home可能已有人在做 @ChiefGyk3D 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
ChiefGyk3D/Clouds-Against-Humanity#348 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 74/100
vllm-project/vime#508 ·
維護者通常 4 天內回覆