Analysis with 0.9.7 fails with `cannot import name 'Feature' from 'setuptools'`

未关闭
#133 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python
领域
tooling

调研方向

使用提供的命令和链接的 requirements.txt 重现该失败。从 resolution.py 中的 get_reqs_insecurely 和 parse_reqs_from_setup_py_insecurely 开始,然后跟进 setup_py_live_eval.py 和 iter_requirements,traceback 显示导入失败发生在这里。完成的标准是:项目能够使用 python-inspector 0.9.7 成功分析,同时 0.9.6 的行为仍然有效。

由索引模型根据 Issue 内容生成。

描述

Running the python-inspector on this requirements.txt, fails with the following error.

The same project can successfully be analyzed using python-inspector 0.9.6.

The command I used is:

python-inspector --python-version 310 --operating-system linux --json-pdt result.json --analyze-setup-py-insecurely --requirement requirements.txt --verbose
Warning: ambiguous setup provider in /Volumes/src/oss/ort/plugins/package-managers/python/src/funTest/assets/projects/synthetic/python-inspector/.cache/python_inspector/extracted_sdists/itsdangerous-0.24/itsdangerous-0.24/setup.py: candidates are ['setuptools', 'distutils.core']defaulting to 'distutils.core'.
Traceback (most recent call last):
  File "/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/python_inspector/resolve_cli.py", line 247, in resolve_dependencies
    resolution_result: Dict = resolver_api(
  File "/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/python_inspector/api.py", line 263, in resolve_dependencies
    resolution, purls = resolve(
  File "/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/python_inspector/api.py", line 322, in resolve
    resolved_dependencies, packages = get_resolved_dependencies(
  File "/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/python_inspector/api.py", line 360, in get_resolved_dependencies
    resolver_results = resolver.resolve(requirements=requirements, max_rounds=max_rounds)
  File "/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/resolvelib/resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/resolvelib/resolvers.py", line 427, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
  File "/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/resolvelib/resolvers.py", line 239, in _attempt_to_pin_criterion
    criteria = self._get_updated_criteria(candidate)
  File "/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/resolvelib/resolvers.py", line 229, in _get_updated_criteria
    for requirement in self._p.get_dependencies(candidate=candidate):
  File "/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/python_inspector/resolution.py", line 644, in get_dependencies
    return list(self._iter_dependencies(candidate))
  File "/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/python_inspector/resolution.py", line 635, in _iter_dependencies
    for r in self.get_requirements_for_package(purl=purl, candidate=candidate):
  File "/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/python_inspector/resolution.py", line 497, in get_requirements_for_package_from_pypi_simple
    yield from get_reqs_insecurely(
  File "/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/python_inspector/resolution.py", line 277, in get_reqs_insecurely
    yield from parse_reqs_from_setup_py_insecurely(setup_py=setup_py_location)
  File "/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/python_inspector/resolution.py", line 128, in parse_reqs_from_setup_py_insecurely
    for req in iter_requirements(level="", extras=[], setup_file=setup_py):
  File "/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/python_inspector/setup_py_live_eval.py", line 117, in iter_requirements
    exec(file_contents, g)
  File "<string>", line 6, in <module>
ImportError: cannot import name 'Feature' from 'setuptools' (/Users/bom1wa3/Library/Python/3.9/lib/python/site-packages/setuptools/__init__.py)
主要语言
Python
星标
23
派生
29
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

aboutcode-org/python-inspector 的其他 Issue

查看 aboutcode-org/python-inspector 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。