wbarnha / kafka-python-ng

Fork for Python client for Apache Kafka
https://wbarnha.github.io/kafka-python-ng/
Apache License 2.0
67 stars 8 forks source link

botocore not included in dependencies for PyPi package #174

Closed here-abarany closed 6 months ago

here-abarany commented 6 months ago

As of version 2.1.0 a botocore dependency has been added, and is listed in requirements-dev.txt, but isn't included for the PyPi package built by setup.py. As a result you will get an ImportError when trying to use the package if you haven't manually installed the dependency.

It would be nice if the SASL component would be automatically disabled if botocore isn't present so all clients don't require the extra dependency if that feature isn't needed.

For reference, here's the import stack that leads to the error.

  File "C:\...\venv\Lib\site-packages\kafka\__init__.py", line 19, in <module>
    from kafka.admin import KafkaAdminClient
  File "C:\...\venv\Lib\site-packages\kafka\admin\__init__.py", line 2, in <module>
    from kafka.admin.client import KafkaAdminClient
  File "C:\...\venv\Lib\site-packages\kafka\admin\client.py", line 10, in <module>
    from kafka.client_async import KafkaClient, selectors
  File "C:\...\venv\Lib\site-packages\kafka\client_async.py", line 11, in <module>
    from kafka.cluster import ClusterMetadata
  File "C:\...\venv\Lib\site-packages\kafka\cluster.py", line 8, in <module>
    from kafka.conn import collect_hosts
  File "C:\...\venv\Lib\site-packages\kafka\conn.py", line 11, in <module>
  File "C:\...\venv\Lib\site-packages\kafka\sasl\__init__.py", line 3, in <module>
    from kafka.sasl import gssapi, oauthbearer, plain, scram, msk
  File "C:\...\venv\Lib\site-packages\kafka\sasl\msk.py", line 13, in <module>
    from botocore.session import Session as BotoSession  # importing it in advance is not an option apparently...
wbarnha commented 6 months ago

My apologies! Let me fix the imports so that it's not required to be installed.

here-abarany commented 6 months ago

Great, thanks!