`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 于 4 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
aboutcode-org/python-inspector#259 · 1 条评论 ·
-
InconsistentCandidate: Pre-Release not allow可能已有人在做 @Anurag-S1ngh 于 4 天前认领。 未关闭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 于 5 天前认领。 未关闭
难度 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 于 4 天前认领。 未关闭
难度 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
-
factory
难度 2/5 1-3 小时 新手友好度 78/100
Arize-ai/phoenix#17420 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
FireDynamics/LEDSmokeAnalysis#176 ·
维护者通常 1 天内回复
-
PC
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
dependencies
难度 2/5 1-3 小时 新手友好度 68/100
dlt-contrib/dlt-filesystem#51 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复