Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Python 3.11? #1452

Closed
2 of 7 tasks
thibaultbetremieux opened this issue Oct 25, 2022 · 26 comments
Closed
2 of 7 tasks

Support for Python 3.11? #1452

thibaultbetremieux opened this issue Oct 25, 2022 · 26 comments
Labels
investigate further It's unclear what the issue is at this time but there is enough interest to look into it MEDIUM

Comments

@thibaultbetremieux
Copy link

Description

I tried installing confluent-kafka inside a conda environment with python=3.11. It did not work. It was working previously with python=3.10.6 and I'd like to use some features from 3.11 🙂 .

How to reproduce

  1. Create conda environment with Python 3.11 (enter the commands one by one and accept prompts, this is not a script):
conda create -n test_confluent_kafka
conda activate test_confluent_kafka
conda install python=3.11 -c conda-forge
  1. Attempt to install confluent-kafka inside the enviromnent
pip install confluent-kafka
Output Collecting confluent-kafka Using cached confluent-kafka-1.9.2.tar.gz (109 kB) Preparing metadata (setup.py) ... done Building wheels for collected packages: confluent-kafka Building wheel for confluent-kafka (setup.py) ... error error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [53 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-311
creating build/lib.linux-x86_64-cpython-311/confluent_kafka
copying src/confluent_kafka/error.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka
copying src/confluent_kafka/serializing_producer.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka
copying src/confluent_kafka/deserializing_consumer.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka
copying src/confluent_kafka/init.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka
creating build/lib.linux-x86_64-cpython-311/confluent_kafka/avro
copying src/confluent_kafka/avro/error.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/avro
copying src/confluent_kafka/avro/cached_schema_registry_client.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/avro
copying src/confluent_kafka/avro/load.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/avro
copying src/confluent_kafka/avro/init.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/avro
creating build/lib.linux-x86_64-cpython-311/confluent_kafka/admin
copying src/confluent_kafka/admin/_config.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/admin
copying src/confluent_kafka/admin/_acl.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/admin
copying src/confluent_kafka/admin/_resource.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/admin
copying src/confluent_kafka/admin/init.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/admin
creating build/lib.linux-x86_64-cpython-311/confluent_kafka/kafkatest
copying src/confluent_kafka/kafkatest/verifiable_client.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/kafkatest
copying src/confluent_kafka/kafkatest/verifiable_consumer.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/kafkatest
copying src/confluent_kafka/kafkatest/verifiable_producer.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/kafkatest
copying src/confluent_kafka/kafkatest/init.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/kafkatest
creating build/lib.linux-x86_64-cpython-311/confluent_kafka/schema_registry
copying src/confluent_kafka/schema_registry/error.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/schema_registry
copying src/confluent_kafka/schema_registry/schema_registry_client.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/schema_registry
copying src/confluent_kafka/schema_registry/json_schema.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/schema_registry
copying src/confluent_kafka/schema_registry/protobuf.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/schema_registry
copying src/confluent_kafka/schema_registry/avro.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/schema_registry
copying src/confluent_kafka/schema_registry/init.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/schema_registry
creating build/lib.linux-x86_64-cpython-311/confluent_kafka/serialization
copying src/confluent_kafka/serialization/init.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/serialization
creating build/lib.linux-x86_64-cpython-311/confluent_kafka/avro/serializer
copying src/confluent_kafka/avro/serializer/message_serializer.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/avro/serializer
copying src/confluent_kafka/avro/serializer/init.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/avro/serializer
running build_ext
building 'confluent_kafka.cimpl' extension
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/tmp
creating build/temp.linux-x86_64-cpython-311/tmp/pip-install-hrf7miay
creating build/temp.linux-x86_64-cpython-311/tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5
creating build/temp.linux-x86_64-cpython-311/tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5/src
creating build/temp.linux-x86_64-cpython-311/tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5/src/confluent_kafka
creating build/temp.linux-x86_64-cpython-311/tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5/src/confluent_kafka/src
gcc -pthread -B /home/thibaultbetremieux/anaconda3/envs/test_confluent_kafka/compiler_compat -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/thibaultbetremieux/anaconda3/envs/test_confluent_kafka/include -fPIC -O2 -isystem /home/thibaultbetremieux/anaconda3/envs/test_confluent_kafka/include -fPIC -I/home/thibaultbetremieux/anaconda3/envs/test_confluent_kafka/include/python3.11 -c /tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5/src/confluent_kafka/src/Admin.c -o build/temp.linux-x86_64-cpython-311/tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5/src/confluent_kafka/src/Admin.o
In file included from /tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5/src/confluent_kafka/src/Admin.c:17:
/tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5/src/confluent_kafka/src/confluent_kafka.h:23:10: fatal error: librdkafka/rdkafka.h: No such file or directory
23 | #include <librdkafka/rdkafka.h>
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for confluent-kafka
Running setup.py clean for confluent-kafka
Failed to build confluent-kafka
Installing collected packages: confluent-kafka
Running setup.py install for confluent-kafka ... error
error: subprocess-exited-with-error

× Running setup.py install for confluent-kafka did not run successfully.
│ exit code: 1
╰─> [55 lines of output]
running install
/home/thibaultbetremieux/anaconda3/envs/test_confluent_kafka/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-311
creating build/lib.linux-x86_64-cpython-311/confluent_kafka
copying src/confluent_kafka/error.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka
copying src/confluent_kafka/serializing_producer.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka
copying src/confluent_kafka/deserializing_consumer.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka
copying src/confluent_kafka/init.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka
creating build/lib.linux-x86_64-cpython-311/confluent_kafka/avro
copying src/confluent_kafka/avro/error.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/avro
copying src/confluent_kafka/avro/cached_schema_registry_client.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/avro
copying src/confluent_kafka/avro/load.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/avro
copying src/confluent_kafka/avro/init.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/avro
creating build/lib.linux-x86_64-cpython-311/confluent_kafka/admin
copying src/confluent_kafka/admin/_config.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/admin
copying src/confluent_kafka/admin/_acl.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/admin
copying src/confluent_kafka/admin/_resource.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/admin
copying src/confluent_kafka/admin/init.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/admin
creating build/lib.linux-x86_64-cpython-311/confluent_kafka/kafkatest
copying src/confluent_kafka/kafkatest/verifiable_client.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/kafkatest
copying src/confluent_kafka/kafkatest/verifiable_consumer.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/kafkatest
copying src/confluent_kafka/kafkatest/verifiable_producer.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/kafkatest
copying src/confluent_kafka/kafkatest/init.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/kafkatest
creating build/lib.linux-x86_64-cpython-311/confluent_kafka/schema_registry
copying src/confluent_kafka/schema_registry/error.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/schema_registry
copying src/confluent_kafka/schema_registry/schema_registry_client.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/schema_registry
copying src/confluent_kafka/schema_registry/json_schema.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/schema_registry
copying src/confluent_kafka/schema_registry/protobuf.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/schema_registry
copying src/confluent_kafka/schema_registry/avro.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/schema_registry
copying src/confluent_kafka/schema_registry/init.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/schema_registry
creating build/lib.linux-x86_64-cpython-311/confluent_kafka/serialization
copying src/confluent_kafka/serialization/init.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/serialization
creating build/lib.linux-x86_64-cpython-311/confluent_kafka/avro/serializer
copying src/confluent_kafka/avro/serializer/message_serializer.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/avro/serializer
copying src/confluent_kafka/avro/serializer/init.py -> build/lib.linux-x86_64-cpython-311/confluent_kafka/avro/serializer
running build_ext
building 'confluent_kafka.cimpl' extension
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/tmp
creating build/temp.linux-x86_64-cpython-311/tmp/pip-install-hrf7miay
creating build/temp.linux-x86_64-cpython-311/tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5
creating build/temp.linux-x86_64-cpython-311/tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5/src
creating build/temp.linux-x86_64-cpython-311/tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5/src/confluent_kafka
creating build/temp.linux-x86_64-cpython-311/tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5/src/confluent_kafka/src
gcc -pthread -B /home/thibaultbetremieux/anaconda3/envs/test_confluent_kafka/compiler_compat -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/thibaultbetremieux/anaconda3/envs/test_confluent_kafka/include -fPIC -O2 -isystem /home/thibaultbetremieux/anaconda3/envs/test_confluent_kafka/include -fPIC -I/home/thibaultbetremieux/anaconda3/envs/test_confluent_kafka/include/python3.11 -c /tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5/src/confluent_kafka/src/Admin.c -o build/temp.linux-x86_64-cpython-311/tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5/src/confluent_kafka/src/Admin.o
In file included from /tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5/src/confluent_kafka/src/Admin.c:17:
/tmp/pip-install-hrf7miay/confluent-kafka_24487a6a36c04ac3bd52ab375f05fcd5/src/confluent_kafka/src/confluent_kafka.h:23:10: fatal error: librdkafka/rdkafka.h: No such file or directory
23 | #include <librdkafka/rdkafka.h>
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> confluent-kafka

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

Checklist

Please provide the following information:

  • confluent-kafka-python and librdkafka version (confluent_kafka.version() and confluent_kafka.libversion()): confluent-kafka-=1.9.2, librdkafka=?
  • Apache Kafka broker version: ?
  • Client configuration: {...}
  • Operating system: Pop!_OS 22.04 LTS
  • Provide client logs (with 'debug': '..' as necessary)
  • Provide broker log excerpts
  • Critical issue
@mhowlett mhowlett added investigate further It's unclear what the issue is at this time but there is enough interest to look into it MEDIUM labels Oct 25, 2022
@ermakov-oleg
Copy link

For python 3.10 you used wheel and did not need to compile from source.
Wheels for python 3.11 are not ready yet and you need to install librdkafka v1.9.0 or later and try to install it again.

@edenhill can you build a wheel for python 3.11?

@Gr1N
Copy link

Gr1N commented Oct 31, 2022

Hey!

Any plans for a wheel release for Python 3.11?

@pranavrth
Copy link
Member

We are planning to add a 3.11 wheel for our next release which is about a month out

@Hawax
Copy link

Hawax commented Nov 3, 2022

apt-get install -y --no-install-recommends gcc git libssl-dev g++ make && cd /tmp && git clone https://github.com/edenhill/librdkafka.git && cd librdkafka && ./configure --prefix=/usr && make && make install

works for me on 3.11 on ubuntu 18.04 😄

@RichardDally
Copy link

apt-get install -y --no-install-recommends gcc git libssl-dev g++ make && cd /tmp && git clone https://github.com/edenhill/librdkafka.git && cd librdkafka && ./configure --prefix=/usr && make && make install

works for me on 3.11 on ubuntu 18.04 😄

I've tried same steps in RH8 but repository is still using an old librdkafka so I had to compile it too. I would be very interested to compile confluent kafka wheel with a static version of librdkafka 1.9.0

@nitin-karolla
Copy link

Waiting for the 3.11 wheel release 🚀

@maciejfic
Copy link

Hello, do you have any estimate on when we can expect python 3.11 wheel? Thakns in advance!

Additional question: I was trying to build one myself, but no matter which version of librdkafka I used I got error cimpl.cpython-311-x86_64-linux-gnu.so: undefined symbol: rd_kafka_AclBinding_destroy. Any tips what I'm doing wrong?

@reupugi
Copy link

reupugi commented Nov 21, 2022

apt-get install -y --no-install-recommends gcc git libssl-dev g++ make && cd /tmp && git clone https://github.com/edenhill/librdkafka.git && cd librdkafka && ./configure --prefix=/usr && make && make install

works for me on 3.11 on ubuntu 18.04 smile

I tried your method - still get ModuleNotFoundError when I try to import confluent_kafka - Any suggestions?

@Hawax
Copy link

Hawax commented Nov 21, 2022

apt-get install -y --no-install-recommends gcc git libssl-dev g++ make && cd /tmp && git clone https://github.com/edenhill/librdkafka.git && cd librdkafka && ./configure --prefix=/usr && make && make install
works for me on 3.11 on ubuntu 18.04 smile

I tried your method - still get ModuleNotFoundError when I try to import confluent_kafka - Any suggestions?

Have you tried to install Kafka with pip after these steps?

@reupugi
Copy link

reupugi commented Nov 21, 2022

apt-get install -y --no-install-recommends gcc git libssl-dev g++ make && cd /tmp && git clone https://github.com/edenhill/librdkafka.git && cd librdkafka && ./configure --prefix=/usr && make && make install
works for me on 3.11 on ubuntu 18.04 smile

I tried your method - still get ModuleNotFoundError when I try to import confluent_kafka - Any suggestions?

Have you tried to install Kafka with pip after these steps?

yes I did this now and it works

@sbv-csis
Copy link

#1467 <--- getting there 👍

@agates4
Copy link

agates4 commented Nov 28, 2022

Does the merge of #1467 mean this will be in the next release?

@nitin-karolla
Copy link

When is the next release? When can we expect the wheel for 3.11 to be available?

@wbarnha
Copy link

wbarnha commented Dec 2, 2022

I've been running this in python:3.11-slim-bullseye while waiting for Confluent to release an update:

RUN apt-get update -y && apt-get install -y --no-install-recommends gcc git libssl-dev g++ make && cd /tmp && git clone https://github.com/edenhill/librdkafka.git && cd librdkafka && ./configure --prefix=/usr && make && make install
RUN python -m pip install --upgrade 'confluent-kafka @ git+https://github.com/confluentinc/confluent-kafka-python'

Hopefully this makes someone's life more convenient. It'll make the image size increase by 300-400 MB but if you're just verifying your code for Python 3.11, it'll do.

@TheHenrick
Copy link

I've been running this in python:3.11-slim-bullseye while waiting for Confluent to release an update:

RUN apt-get update -y && apt-get install -y --no-install-recommends gcc git libssl-dev g++ make && cd /tmp && git clone https://github.com/edenhill/librdkafka.git && cd librdkafka && ./configure --prefix=/usr && make && make install
RUN python -m pip install --upgrade 'confluent-kafka @ git+https://github.com/confluentinc/confluent-kafka-python'

Hopefully this makes someone's life more convenient. It'll make the image size increase by 300-400 MB but if you're just verifying your code for Python 3.11, it'll do.

Thanks, great for testing in the meantime.

@giacomomiolo
Copy link

Any updates on this? Thanks for the great work!

@y3ti
Copy link

y3ti commented Jan 2, 2023

If you want to build *.whl file:

Makefile:

.PHONY: build
build:
	DOCKER_BUILDKIT=1 docker build --output type=local,dest=./wheels .

Dockerfile:

###############################################################################
# BUILDER
###############################################################################
FROM quay.io/pypa/manylinux_2_24_x86_64 AS builder

ARG CONFLUENT_KAFKA_VERSION=1.9.2
ARG LIBRDKAFKA_VERSION=1.9.2
ENV PYBIN=/opt/python/cp311-cp311/bin/

RUN set -ex \
    &&  apt-get update \
    &&  apt-get install --no-install-recommends --yes \
            build-essential \
            git \
            libsasl2-dev \
            libssl-dev \
            libzstd-dev

# build and install librdkafka
WORKDIR /tmp/librdkafka
RUN set -ex \
    &&  git clone --branch v${LIBRDKAFKA_VERSION} https://github.com/edenhill/librdkafka.git . \
    &&  ./configure --prefix=/usr \
    &&  make \
    &&  make install


# build confluent-kafka python wheel
WORKDIR /tmp/confluent-kafka-python
RUN set -ex \
    &&  git clone --branch v${CONFLUENT_KAFKA_VERSION} https://github.com/confluentinc/confluent-kafka-python.git . \
    &&  mkdir -p dist /wheels \
    &&  ${PYBIN}/python3.11 setup.py bdist_wheel -d dist \
    &&  auditwheel repair dist/*.whl -w /wheels

###############################################################################
# WHEELS
###############################################################################
FROM scratch AS wheels

COPY --from=builder /wheels/*.whl .

Build the python wheel for 3.11:

$ make build
...
$ ls wheels/
confluent_kafka-1.9.2-cp311-cp311-manylinux_2_24_x86_64.whl

The wheel includes all required shared libraries:

$ unzip -l wheels/confluent_kafka-1.9.2-cp311-cp311-manylinux_2_24_x86_64.whl 
Archive:  wheels/confluent_kafka-1.9.2-cp311-cp311-manylinux_2_24_x86_64.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
...
   113257  2023-01-02 11:51   confluent_kafka.libs/libsasl2-4427c928.so.2.0.25
   483537  2023-01-02 11:51   confluent_kafka.libs/libssl-6db5df62.so.1.1
 10700473  2023-01-02 11:51   confluent_kafka.libs/librdkafka-ddc374ef.so.1
  2833457  2023-01-02 11:51   confluent_kafka.libs/libcrypto-f5871c65.so.1.1

@rdasari5
Copy link

rdasari5 commented Jan 3, 2023

Hi Team,

I am getting below error while trying to install locust plugins, please check if its related to this issue.

C:\Users\532720\AppData\Local\Temp\pip-install-xs29pl_m\confluent-kafka_5fb7b110405e498a8ff4d4598602445f\src\confluent_kafka\src\confluent_kafka.h(23): fatal error C1083: Cannot open include file: 'librdkafka/rdkafka.h': No such file or directory

error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.34.31933\bin\HostX86\x64\cl.exe' failed with exit code 2
[end of output]

@stegayet
Copy link

stegayet commented Jan 7, 2023

@pranavrth Do you have an ETA regarding next release by any chance ? Thanks a lot 👍

@pranavrth
Copy link
Member

We are planning to have the next release after librdkafka is released. So around end of January or early February.

@stegayet
Copy link

stegayet commented Jan 9, 2023

Thanks for the follow-up 👍

pridhi-arora added a commit to pridhi-arora/opentelemetry-python-contrib that referenced this issue Jan 18, 2023
    ; // FIXME: Enable support for python 3.11 when confluentinc/confluent-kafka-python#1452 is fixed
This line was wrongly commented
@ehn-lpbezerra
Copy link

If you want to build *.whl file:

Makefile:

.PHONY: build
build:
	DOCKER_BUILDKIT=1 docker build --output type=local,dest=./wheels .

Dockerfile:

###############################################################################
# BUILDER
###############################################################################
FROM quay.io/pypa/manylinux_2_24_x86_64 AS builder

ARG CONFLUENT_KAFKA_VERSION=1.9.2
ARG LIBRDKAFKA_VERSION=1.9.2
ENV PYBIN=/opt/python/cp311-cp311/bin/

RUN set -ex \
    &&  apt-get update \
    &&  apt-get install --no-install-recommends --yes \
            build-essential \
            git \
            libsasl2-dev \
            libssl-dev \
            libzstd-dev

# build and install librdkafka
WORKDIR /tmp/librdkafka
RUN set -ex \
    &&  git clone --branch v${LIBRDKAFKA_VERSION} https://github.com/edenhill/librdkafka.git . \
    &&  ./configure --prefix=/usr \
    &&  make \
    &&  make install


# build confluent-kafka python wheel
WORKDIR /tmp/confluent-kafka-python
RUN set -ex \
    &&  git clone --branch v${CONFLUENT_KAFKA_VERSION} https://github.com/confluentinc/confluent-kafka-python.git . \
    &&  mkdir -p dist /wheels \
    &&  ${PYBIN}/python3.11 setup.py bdist_wheel -d dist \
    &&  auditwheel repair dist/*.whl -w /wheels

###############################################################################
# WHEELS
###############################################################################
FROM scratch AS wheels

COPY --from=builder /wheels/*.whl .

Build the python wheel for 3.11:

$ make build
...
$ ls wheels/
confluent_kafka-1.9.2-cp311-cp311-manylinux_2_24_x86_64.whl

The wheel includes all required shared libraries:

$ unzip -l wheels/confluent_kafka-1.9.2-cp311-cp311-manylinux_2_24_x86_64.whl 
Archive:  wheels/confluent_kafka-1.9.2-cp311-cp311-manylinux_2_24_x86_64.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
...
   113257  2023-01-02 11:51   confluent_kafka.libs/libsasl2-4427c928.so.2.0.25
   483537  2023-01-02 11:51   confluent_kafka.libs/libssl-6db5df62.so.1.1
 10700473  2023-01-02 11:51   confluent_kafka.libs/librdkafka-ddc374ef.so.1
  2833457  2023-01-02 11:51   confluent_kafka.libs/libcrypto-f5871c65.so.1.1

How do I use this wheel file? I've managed to build the wheel following your instructions, but I don't know what to do with it. Any help would be much appreciated.

Thanks in advance!

@y3ti
Copy link

y3ti commented Jan 19, 2023

@ehn-lpbezerra just install it via pip3 install --no-index wheels/confluent_kafka-1.9.2-cp311-cp311-manylinux_2_24_x86_64.whl

@pranavrth
Copy link
Member

We have released v2.0.2 with Python 3.11 wheels included.

@RichardDally
Copy link

OpenSSL 3 is required to use this wheel, right ?

@axgkl
Copy link

axgkl commented Sep 4, 2023

On conda (micromamba) a micromamba install librdkafka before installing this with pip did the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate further It's unclear what the issue is at this time but there is enough interest to look into it MEDIUM
Projects
None yet
Development

No branches or pull requests