Skip to content

packaging is imported at runtime but not declared as a dependency #804

Backlog

Description

@paxw-panevo

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions