kafka-python icon indicating copy to clipboard operation
kafka-python copied to clipboard

Parallel packages (kafka-python & kafka) can cause unexpected behavior

Open vartec opened this issue 8 years ago • 2 comments

I know this stems from #82, but the solution with having parallel copies of the same package can lead to unexpected behavior. Whichever package is installed later overwrites the one installed previously.

$ mkvirtualenv kafka-versions
$ pip install kafka-python==1.3.5
$ pip install kafka==1.0.0  # this emulates some 3rd party package requiring it
$ python -c 'import kafka; print(kafka.__version__)'
1.0.0

$ virtualenv --clear 
$ pip install kafka==1.0.0  # this emulates some 3rd party package requiring it
$ pip install kafka-python==1.3.5
$ python -c 'import kafka; print(kafka.__version__)'
1.3.5

$ pip freeze
kafka==1.0.0
kafka-python==1.3.5
six==1.11.0

Maybe a solution would be to convert kafka package into a shim package with no code, only setup.py with kafka-python in the install_requires?

vartec avatar Oct 09 '17 23:10 vartec

barebones proof of concept setup.py

from setuptools import setup
import warnings

warnings.warn("this package is deprecated, use kafka-python instead", DeprecationWarning)

version = '1.3.5'

setup(
    name='kafka',
    version=version,
    install_requires='kafka-python=={version}'.format(version=version)
)
Processing /private/tmp/kafka-shim
Collecting kafka-python==1.3.5 (from kafka==1.3.5)
  Using cached kafka_python-1.3.5-py2.py3-none-any.whl
Building wheels for collected packages: kafka
  Running setup.py bdist_wheel for kafka ... done
  Stored in directory: /Users/bartek/Library/Caches/pip/wheels/61/79/eb/01e5235a844199a647254626b0649f12b2c065bca6b69c4426
Successfully built kafka
Installing collected packages: kafka-python, kafka
  Found existing installation: kafka 1.0.0
    Uninstalling kafka-1.0.0:
      Successfully uninstalled kafka-1.0.0
Successfully installed kafka-1.3.5 kafka-python-1.3.5

$ python -c 'import kafka; print(kafka.__version__)'
1.3.5

vartec avatar Oct 10 '17 00:10 vartec

related https://github.com/dpkp/kafka-python/issues/1726

jeffwidman avatar Feb 12 '20 21:02 jeffwidman