Enhancement: parse `install_requires` and `python_requires` in `setup.py`

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
python, typescript
领域
backend, devtools

调研方向

Start with the Python scanner in src/core-open/scanners/python-scanner.ts, especially PYTHON_MANIFEST_FILES and the scan loop around lines 1344–1363, then inspect nearby parser tests. Add coverage in test/python-setup-py.test.ts using literal setup.py inputs; never execute the file as Python. Done means literals are extracted with the stated precedence and optional dependency behavior, while dynamic values are skipped without failing the scan.

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

描述

enhancement help wanted
  • Difficulty: medium
  • Area: Python scanner
Problem

setup.py is in PYTHON_MANIFEST_FILES (src/core-open/scanners/python-scanner.ts, around lines 1251–1260), so a directory that contains only setup.py is treated as a Python project. The scan loop (around lines 1344–1363) parses pyproject.toml, setup.cfg, Pipfile, and requirements files only. There is no parseSetupPy, and no test mentions setup.py as a dependency source.

A setuptools project that has not migrated to pyproject.toml / setup.cfg is discovered, then reported with no dependencies and no runtime, even when the file is a straightforward literal:

setup(
    name="demo",
    python_requires=">=3.11",
    install_requires=[
        "requests>=2.31",
        "flask>=3.0",
    ],
    extras_require={"dev": ["pytest>=7"]},
)

Do not execute setup.py.

Expected behaviour

A conservative, literal reader (regex / small AST of string lists only — no exec, no import of the project) extracts name, python_requires, install_requires, and optionally extras_require when they are string literals or lists of string literals, including the setuptools.setup(...) and from setuptools import setup forms. Dynamic values (install_requires=read_requirements(), computed lists) are skipped, not guessed. python_requires is a runtime fallback, with the same precedence as setup.cfg (pyproject.toml still wins when both exist). Extras are optionalDependencies. A package already in install_requires stays production.

Acceptance
  • A setup.py-only project with literal install_requires and python_requires reports those packages and the Python runtime.
  • extras_require literals are optional rows.
  • A setup.py that only builds its requirements dynamically reports no invented packages and does not fail the scan.
  • pyproject.toml / setup.cfg in the same directory still win for name, runtime, and duplicate package sections.
  • Tests live in a new test/python-setup-py.test.ts. Never run the file as Python.

主要语言
TypeScript
星标
4
派生
3
平均合并
1 天 22 小时
30 天内合并 PR
76

环境准备

从这里开始

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

vibgrate/cli 的其他 Issue

查看 vibgrate/cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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