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

Đang mở Phù hợp với người mới
#804 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
86/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
build-system

Hướng nghiên cứu

Đọc faust/transport/drivers/aiokafka.py quanh dòng 52 để xác nhận Version từ packaging.version là cách sử dụng duy nhất, sau đó thêm một dòng packaging (ví dụ: packaging>=20.0) vào requirements/requirements.txt; chỉ kiểm tra requirements/dist.txt để xem vì sao trước đây nó được cho là đã có. Để xác minh, hãy cài đặt từ requirements đã chỉnh sửa vào một virtualenv mới với aiokafka==0.15.0 và chạy python -c "import faust.transport.drivers.aiokafka". Hoàn tất nghĩa là lần import đó thành công mà packaging không bị một gói khác kéo vào.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
1.9k
Fork
205
Merge trung bình
2 giờ 2 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của faust-streaming/faust

Tất cả issue của faust-streaming/faust

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.