Skip to content

Commit ccaa5b8

Browse files
authored
Hotfix: use system-provided cyrus-sasl/libsasl2 at runtime (#10)
- Hotfix: use system-provided cyrus-sasl/libsasl2 at runtime - revert previous approach for universal build that is now obsoleted by G-Research/librdkafka#9 - use `librdkafka.redist` version `2.11.0.1-RC1` - CI: build linux arm64 wheels too - CI: check version consistency - Bump version to `2.11.0.1-RC1+gr`
1 parent 0b72e75 commit ccaa5b8

File tree

9 files changed

+36
-88
lines changed

9 files changed

+36
-88
lines changed

.github/workflows/package.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,23 @@ on:
66
push:
77

88
env:
9-
LIBRDKAFKA_VERSION: v2.11.0-gr
9+
LIBRDKAFKA_VERSION: v2.11.0.1-RC1
1010

1111
jobs:
1212

13-
build-linux-x64:
14-
name: Build wheels for Linux x64
15-
runs-on: ubuntu-latest
13+
build-linux:
14+
name: Build wheels for Linux ${{ matrix.arch }}
15+
strategy:
16+
matrix:
17+
include:
18+
- arch: x64
19+
runner: ubuntu-24.04
20+
- arch: arm64
21+
runner: ubuntu-24.04-arm
22+
runs-on: ${{ matrix.runner }}
1623
env:
1724
OS_NAME: linux
18-
ARCH: x64
25+
ARCH: ${{ matrix.arch }}
1926
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2027
steps:
2128
- uses: actions/checkout@v4
@@ -55,9 +62,19 @@ jobs:
5562
create_release_artifacts:
5663
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
5764
name: Create release artifacts
58-
needs: [build-linux-x64, build-windows]
65+
needs: [build-linux, build-windows]
5966
runs-on: ubuntu-latest
6067
steps:
68+
- uses: actions/checkout@v4
69+
- uses: astral-sh/setup-uv@v6
70+
- name: Check version consistency
71+
run: |
72+
tag_version=${GITHUB_REF/refs\/tags\/v/}
73+
proj_version=$(uv run --no-project --with poetry poetry version -s)
74+
if [ "$tag_version" != "$proj_version" ]; then
75+
echo "::error title=Version mismatch::Tag version \"$tag_version\" does not match project version \"$proj_version\"."
76+
exit 1
77+
fi
6178
- uses: actions/download-artifact@v4
6279
with:
6380
path: artifacts

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "confluent-kafka"
7-
version = "2.11.0+gr.2"
7+
version = "2.11.0.1rc1+gr"
88
description = "Confluent's Python client for Apache Kafka"
99
classifiers = [
1010
"Development Status :: 5 - Production/Stable",

setup.py

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22

3-
import ctypes.util
43
import os
54
from setuptools import setup
65
from setuptools import Extension
@@ -17,44 +16,13 @@
1716
else:
1817
librdkafka_libname = 'rdkafka'
1918

20-
# Define the default module to build, without external dependencies.
21-
module_defs = [
22-
{
23-
'name': 'confluent_kafka.cimpl.nodeps.cimpl',
24-
'libname': librdkafka_libname,
25-
}
26-
]
19+
module = Extension('confluent_kafka.cimpl',
20+
libraries=[librdkafka_libname],
21+
sources=[os.path.join(ext_dir, 'confluent_kafka.c'),
22+
os.path.join(ext_dir, 'Producer.c'),
23+
os.path.join(ext_dir, 'Consumer.c'),
24+
os.path.join(ext_dir, 'Metadata.c'),
25+
os.path.join(ext_dir, 'AdminTypes.c'),
26+
os.path.join(ext_dir, 'Admin.c')])
2727

28-
# Check for GSSAPI support and add the appropriate module definitions.
29-
if ctypes.util.find_library('rdkafka_sasl2_2'):
30-
module_defs.append(
31-
{
32-
'name': 'confluent_kafka.cimpl.sasl2_2.cimpl',
33-
'libname': 'rdkafka_sasl2_2',
34-
}
35-
)
36-
if ctypes.util.find_library('rdkafka_sasl2_3'):
37-
module_defs.append(
38-
{
39-
'name': 'confluent_kafka.cimpl.sasl2_3.cimpl',
40-
'libname': 'rdkafka_sasl2_3',
41-
}
42-
)
43-
44-
setup(
45-
ext_modules=[
46-
Extension(
47-
mod_def['name'],
48-
libraries=[mod_def['libname']],
49-
sources=[
50-
os.path.join(ext_dir, 'confluent_kafka.c'),
51-
os.path.join(ext_dir, 'Producer.c'),
52-
os.path.join(ext_dir, 'Consumer.c'),
53-
os.path.join(ext_dir, 'Metadata.c'),
54-
os.path.join(ext_dir, 'AdminTypes.c'),
55-
os.path.join(ext_dir, 'Admin.c'),
56-
],
57-
)
58-
for mod_def in module_defs
59-
]
60-
)
28+
setup(ext_modules=[module])

src/confluent_kafka/cimpl/__init__.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/confluent_kafka/cimpl/nodeps/__init__.py

Whitespace-only changes.

src/confluent_kafka/cimpl/sasl2_2/__init__.py

Whitespace-only changes.

src/confluent_kafka/cimpl/sasl2_3/__init__.py

Whitespace-only changes.

tools/wheels/build-wheels.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ case $OSTYPE in
3535
# Need to set up env vars (in docker) so that cibuildwheel finds librdkafka.
3636
lib_dir=dest/runtimes/linux-$ARCH/native
3737
export CIBW_ENVIRONMENT="CFLAGS=-I\$PWD/dest/build/native/include LDFLAGS=-L\$PWD/$lib_dir LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$PWD/$lib_dir"
38-
# Do not include libsasl2 and its dependencies in the resulting wheel.
39-
export CIBW_REPAIR_WHEEL_COMMAND="auditwheel repair --exclude libsasl2.so.2 --exclude libsasl2.so.3 -w {dest_dir} {wheel}"
4038
;;
4139
darwin*)
4240
os=macos

tools/wheels/install-librdkafka.sh

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,9 @@ ARCH=${ARCH:-x64}
3939

4040
if [[ $OSTYPE == linux* ]]; then
4141
# Linux
42-
LIBDIR=runtimes/linux-$ARCH/native
43-
44-
# Copy the librdkafka build with least dependencies to librdkafka.so.1
45-
if [[ $ARCH == arm64* ]]; then
46-
cp -v $LIBDIR/{librdkafka.so,librdkafka.so.1}
47-
else
48-
cp -v $LIBDIR/{centos8-librdkafka.so,librdkafka.so.1}
49-
# Copy the librdkafka build with sasl2 support to 2 versions:
50-
# librdkafka_sasl2_2.so.1 for debian-based distros
51-
# librdkafka_sasl2_3.so.1 for rpm-based distros
52-
patchelf --set-soname librdkafka_sasl2_2.so.1 --output $LIBDIR/{librdkafka_sasl2_2.so.1,librdkafka.so}
53-
patchelf --replace-needed libsasl2.so.3 libsasl2.so.2 $LIBDIR/librdkafka_sasl2_2.so.1
54-
ln -s librdkafka_sasl2_2.so.1 $LIBDIR/librdkafka_sasl2_2.so
55-
patchelf --set-soname librdkafka_sasl2_3.so.1 --output $LIBDIR/{librdkafka_sasl2_3.so.1,librdkafka.so}
56-
ln -s librdkafka_sasl2_3.so.1 $LIBDIR/librdkafka_sasl2_3.so
57-
fi
58-
for lib in $LIBDIR/librdkafka*.so.1; do
59-
echo $lib
60-
ldd $lib
61-
done
42+
43+
cp -v runtimes/linux-$ARCH/native/{librdkafka.so,librdkafka.so.1}
44+
ldd runtimes/linux-$ARCH/native/librdkafka.so.1
6245

6346
elif [[ $OSTYPE == darwin* ]]; then
6447
# MacOS X

0 commit comments

Comments
 (0)