Skip to content

Add linux ARM64 wheels block in Semaphore #1496

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

Merged
merged 1 commit into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ global_job_config:
value: v2.0.2
prologue:
commands:
- export HOME=$WORKSPACE
- mkdir $WORKSPACE/confluent-kafka-python
- cd $WORKSPACE/confluent-kafka-python
Comment on lines -12 to -14
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 commands can be removed, as semaphore provided command checkout does all of this.

- checkout
blocks:
- name: "Wheels: OSX x64"
Expand Down Expand Up @@ -54,7 +51,7 @@ blocks:
- PIP_INSTALL_OPTIONS="--user" tools/wheels/build-wheels.sh "${LIBRDKAFKA_VERSION#v}" wheelhouse
- tar -czf wheelhouse-macOS-${ARCH}.tgz wheelhouse
- artifact push workflow wheelhouse-macOS-${ARCH}.tgz

- name: Source package verification with Python 3 (OSX x64) +docs
dependencies: []
task:
Expand Down Expand Up @@ -83,3 +80,22 @@ blocks:
# install confluent-kafka
- python setup.py build && python setup.py install
- make docs
- name: "Wheels: Linux arm64"
run:
when: "tag =~ '.*'"
dependencies: []
task:
agent:
machine:
type: s1-prod-ubuntu20-04-arm64-1
env_vars:
- name: OS_NAME
value: linux
- name: ARCH
value: arm64
jobs:
- name: Build
commands:
- ./tools/build-manylinux.sh "${LIBRDKAFKA_VERSION#v}"
- tar -czf wheelhouse-linux-${ARCH}.tgz wheelhouse
- artifact push workflow wheelhouse-linux-${ARCH}.tgz
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Added `set_sasl_credentials`. This new method (on the Producer, Consumer, and AdminClient) allows modifying the stored
SASL PLAIN/SCRAM credentials that will be used for subsequent (new) connections to a broker (#1511).
- Wheels for Linux / arm64 (#1496).


## v2.0.2
Expand Down
4 changes: 4 additions & 0 deletions src/confluent_kafka/src/confluent_kafka.c
Original file line number Diff line number Diff line change
Expand Up @@ -2758,7 +2758,11 @@ static struct PyModuleDef cimpl_moduledef = {
static PyObject *_init_cimpl (void) {
PyObject *m;

/* PyEval_InitThreads became deprecated in Python 3.9 and will be removed in Python 3.11.
* Prior to Python 3.7, this call was required to initialize the GIL. */
#if PY_VERSION_HEX < 0x03090000
PyEval_InitThreads();
#endif

if (PyType_Ready(&KafkaErrorType) < 0)
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion tools/bootstrap-librdkafka.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mkdir -p "$BUILDDIR/librdkafka"
pushd "$BUILDDIR/librdkafka"

test -f configure ||
curl -q -L "https://github.com/edenhill/librdkafka/archive/${VERSION}.tar.gz" | \
curl -q -L "https://github.com/confluentinc/librdkafka/archive/refs/tags/${VERSION}.tar.gz" | \
tar -xz --strip-components=1 -f -

./configure --clean
Expand Down
18 changes: 12 additions & 6 deletions tools/build-manylinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ if [[ ! -f /.dockerenv ]]; then
exit 1
fi

docker run -t -v $(pwd):/io quay.io/pypa/manylinux2010_x86_64:latest /io/tools/build-manylinux.sh "$LIBRDKAFKA_VERSION"
if [[ $ARCH == arm64* ]]; then
docker_image=quay.io/pypa/manylinux_2_28_aarch64:latest
else
docker_image=quay.io/pypa/manylinux_2_28_x86_64:latest
fi

docker run -t -v $(pwd):/io $docker_image /io/tools/build-manylinux.sh "v${LIBRDKAFKA_VERSION}"

exit $?
fi
Expand All @@ -44,14 +50,14 @@ fi
#

echo "# Installing basic system dependencies"
yum install -y zlib-devel gcc-c++
yum install -y zlib-devel gcc-c++ python3 curl-devel perl-IPC-Cmd perl-Pod-Html

echo "# Building librdkafka ${LIBRDKAFKA_VERSION}"
$(dirname $0)/bootstrap-librdkafka.sh --require-ssl ${LIBRDKAFKA_VERSION} /usr

# Compile wheels
echo "# Compile"
for PYBIN in /opt/python/*/bin; do
for PYBIN in /opt/python/cp*/bin; do
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To only build wheels using CPython

echo "## Compiling $PYBIN"
CFLAGS="-Werror -Wno-strict-aliasing -Wno-parentheses" \
"${PYBIN}/pip" wheel /io/ -w unrepaired-wheelhouse/
Expand All @@ -73,13 +79,13 @@ done

# Install packages and test
echo "# Installing wheels"
for PYBIN in /opt/python/*/bin/; do
for PYBIN in /opt/python/cp*/bin/; do
echo "## Installing $PYBIN"
"${PYBIN}/pip" install confluent_kafka -f /io/wheelhouse
"${PYBIN}/python" -c 'import confluent_kafka; print(confluent_kafka.libversion())'
"${PYBIN}/pip" install -r /io/tests/requirements.txt
"${PYBIN}/pytest" /io/tests/test_Producer.py
echo "## Uninstalling $PYBIN"
"${PYBIN}/pip" uninstall -y confluent_kafka
done
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a new line at the end of the files to adhere to the styling followed in the repo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check other files in the PR as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.




6 changes: 5 additions & 1 deletion tools/wheels/install-librdkafka.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ if [[ $OSTYPE == linux* ]]; then
# Linux

# Copy the librdkafka build with least dependencies to librdkafka.so.1
cp -v runtimes/linux-$ARCH/native/{centos6-librdkafka.so,librdkafka.so.1}
if [[ $ARCH == arm64* ]]; then
cp -v runtimes/linux-$ARCH/native/{librdkafka.so,librdkafka.so.1}
else
cp -v runtimes/linux-$ARCH/native/{centos6-librdkafka.so,librdkafka.so.1}
fi
ldd runtimes/linux-$ARCH/native/librdkafka.so.1

elif [[ $OSTYPE == darwin* ]]; then
Expand Down