`packaging` is imported at runtime but not declared as a dependency

未关闭 适合新手
#804 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
86/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
build-system

调研方向

阅读 faust/transport/drivers/aiokafka.py 第 52 行附近,确认 Version 来自 packaging.version 且是唯一使用处,然后添加一行 packaging(例如 packaging>=20.0)到 requirements/requirements.txt;仅检查 requirements/dist.txt 以了解为何之前假定它已存在。要验证,请从编辑后的 requirements 安装到一个新的 virtualenv 中,并带上 aiokafka==0.15.0,然后运行 python -c "import faust.transport.drivers.aiokafka"。完成意味着该 import 成功,且 packaging 不是由另一个包引入的。

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

描述

Summary

faust/transport/drivers/aiokafka.py line 52 does an unconditional from packaging.version import Version. packaging is not listed in requirements/requirements.txt, so it is not in the published Requires-Dist. It only appears in requirements/dist.txt, which is build tooling.

Until now this worked by accident, because aiokafka pulled packaging in. aiokafka 0.15.0 dropped packaging (and async-timeout) from its dependencies. Its requires_dist is now only typing-extensions; python_version<"3.12". A clean install of faust-streaming with aiokafka 0.15.0 therefore has no packaging, and the Kafka transport fails to import.

Versions

  • faust-streaming 0.15.4 (latest on PyPI); also checked on master at ca53750
  • aiokafka 0.15.0
  • Python 3.12

Steps to reproduce

python -m venv /tmp/venv && . /tmp/venv/bin/activate
pip install "faust-streaming==0.15.4" "aiokafka==0.15.0"
pip uninstall -y packaging   # only needed if something else in the env pulled it in
python -c "import faust.transport.drivers.aiokafka"

Actual

ModuleNotFoundError: No module named 'packaging'

Expected

The import succeeds, because packaging is installed as a declared dependency of faust-streaming.

Suggested fix

Add packaging to requirements/requirements.txt. It is used only for Version(aiokafka.__version__) comparisons, so a lower bound such as packaging>=20.0 should be enough.

Workaround

Pin packaging explicitly in the application's own requirements.

主要语言
Python
星标
1.9k
派生
205
平均合并
2 小时 2 分钟
30 天内合并 PR
1

环境准备

从这里开始

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

faust-streaming/faust 的其他 Issue

查看 faust-streaming/faust 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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