From c3cdce0a0d01a82610cc1dfd8446a22bc74aacc9204e0d4b0e7a8c98f32ec6e0 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Tue, 19 Mar 2024 04:01:55 +0000 Subject: [PATCH] - Add patch slightly-patch-out-six.patch: * Remove some uses of six, to avoid circular imports. - Also edit fixutres.py directly for the same reason. - Switch to pyproject macros. - Less globs in %files. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-kafka-python?expand=0&rev=28 --- fixtures.py | 7 +++--- python-kafka-python.changes | 9 +++++++ python-kafka-python.spec | 20 +++++++++------ slightly-patch-out-six.patch | 49 ++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 12 deletions(-) create mode 100644 slightly-patch-out-six.patch diff --git a/fixtures.py b/fixtures.py index d21e3ae..b21bfe8 100644 --- a/fixtures.py +++ b/fixtures.py @@ -7,11 +7,10 @@ import os.path import socket import subprocess import time +import urllib import uuid import py -from kafka.vendor.six.moves import urllib, range -from kafka.vendor.six.moves.urllib.parse import urlparse # pylint: disable=E0611,F0401 from kafka import errors, KafkaAdminClient, KafkaClient, KafkaConsumer, KafkaProducer from kafka.errors import InvalidReplicationFactorError @@ -160,7 +159,7 @@ class ZookeeperFixture(Fixture): @classmethod def instance(cls): if "ZOOKEEPER_URI" in os.environ: - parse = urlparse(os.environ["ZOOKEEPER_URI"]) + parse = urllib.parse.urlparse(os.environ["ZOOKEEPER_URI"]) (host, port) = (parse.hostname, parse.port) fixture = ExternalService(host, port) else: @@ -256,7 +255,7 @@ class KafkaFixture(Fixture): if zk_chroot is None: zk_chroot = "kafka-python_" + str(uuid.uuid4()).replace("-", "_") if "KAFKA_URI" in os.environ: - parse = urlparse(os.environ["KAFKA_URI"]) + parse = urllib.parse.urlparse(os.environ["KAFKA_URI"]) (host, port) = (parse.hostname, parse.port) fixture = ExternalService(host, port) else: diff --git a/python-kafka-python.changes b/python-kafka-python.changes index a7fecf6..099eec0 100644 --- a/python-kafka-python.changes +++ b/python-kafka-python.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Tue Mar 19 04:01:27 UTC 2024 - Steve Kowalik + +- Add patch slightly-patch-out-six.patch: + * Remove some uses of six, to avoid circular imports. +- Also edit fixutres.py directly for the same reason. +- Switch to pyproject macros. +- Less globs in %files. + ------------------------------------------------------------------- Mon Apr 10 11:36:09 UTC 2023 - Daniel Garcia diff --git a/python-kafka-python.spec b/python-kafka-python.spec index 9086d1e..d0c30e2 100644 --- a/python-kafka-python.spec +++ b/python-kafka-python.spec @@ -1,7 +1,7 @@ # # spec file for package python-kafka-python # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -21,18 +21,21 @@ Version: 2.0.2 Release: 0 Summary: Pure Python client for Apache Kafka License: Apache-2.0 -Group: Development/Languages/Python URL: https://github.com/mumrah/kafka-python Source: https://files.pythonhosted.org/packages/source/k/kafka-python/kafka-python-%{version}.tar.gz Source1: https://raw.githubusercontent.com/dpkp/kafka-python/master/servers/0.11.0.3/resources/zookeeper.properties Source2: https://raw.githubusercontent.com/dpkp/kafka-python/master/test/conftest.py -Source3: https://raw.githubusercontent.com/dpkp/kafka-python/master/test/fixtures.py +Source3: fixtures.py Source4: https://raw.githubusercontent.com/dpkp/kafka-python/master/test/service.py # PATCH-FIX-OPENSUSE Remove use of mock module Patch0: remove-mock.patch # PATCH-FIX-UPSTREAM fix tests for py3.11 gh#dpkp/kafka-python#2358 Patch1: python-311.patch +# PATCH-FIX-OPENSUSE Remove circular imports involving vendored modules +Patch2: slightly-patch-out-six.patch +BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros # Recommends: python-crc32c # Not packaged @@ -62,23 +65,24 @@ mkdir -p servers/0.11.0.2/resources/ cp %{SOURCE1} servers/0.11.0.2/resources/ cp %{SOURCE2} %{SOURCE3} %{SOURCE4} test/ - touch test/__init__.py %build -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} %check # test_kafka_producer_gc_cleanup is sometimes off by 1 -%pytest -rs -k 'not (test_kafka_consumer_offsets_for_time_old or test_kafka_producer_gc_cleanup)' +# test_send broken with Python 3.12 +%pytest -rs -k 'not (test_kafka_consumer_offsets_for_time_old or test_kafka_producer_gc_cleanup or test_send)' %files %{python_files} %license LICENSE %doc README.rst -%{python_sitelib}/kafka*/ +%{python_sitelib}/kafka +%{python_sitelib}/kafka_python-%{version}.dist-info %changelog diff --git a/slightly-patch-out-six.patch b/slightly-patch-out-six.patch new file mode 100644 index 0000000..d4c8c59 --- /dev/null +++ b/slightly-patch-out-six.patch @@ -0,0 +1,49 @@ +Index: kafka-python-2.0.2/kafka/codec.py +=================================================================== +--- kafka-python-2.0.2.orig/kafka/codec.py ++++ kafka-python-2.0.2/kafka/codec.py +@@ -5,9 +5,6 @@ import io + import platform + import struct + +-from kafka.vendor import six +-from kafka.vendor.six.moves import range +- + _XERIAL_V1_HEADER = (-126, b'S', b'N', b'A', b'P', b'P', b'Y', 0, 1, 1) + _XERIAL_V1_FORMAT = 'bccccccBii' + ZSTD_MAX_OUTPUT_SIZE = 1024 * 1024 +@@ -149,10 +146,6 @@ def snappy_encode(payload, xerial_compat + # buffer... likely a python-snappy bug, so just use a slice copy + chunker = lambda payload, i, size: payload[i:size+i] + +- elif six.PY2: +- # Sliced buffer avoids additional copies +- # pylint: disable-msg=undefined-variable +- chunker = lambda payload, i, size: buffer(payload, i, size) + else: + # snappy.compress does not like raw memoryviews, so we have to convert + # tobytes, which is a copy... oh well. it's the thought that counts. +Index: kafka-python-2.0.2/test/test_codec.py +=================================================================== +--- kafka-python-2.0.2.orig/test/test_codec.py ++++ kafka-python-2.0.2/test/test_codec.py +@@ -4,7 +4,6 @@ import platform + import struct + + import pytest +-from kafka.vendor.six.moves import range + + from kafka.codec import ( + has_snappy, has_lz4, has_zstd, +Index: kafka-python-2.0.2/test/test_consumer_integration.py +=================================================================== +--- kafka-python-2.0.2.orig/test/test_consumer_integration.py ++++ kafka-python-2.0.2/test/test_consumer_integration.py +@@ -6,7 +6,6 @@ try: + except ImportError: + from mock import patch + import pytest +-from kafka.vendor.six.moves import range + + import kafka.codec + from kafka.errors import UnsupportedCodecError, UnsupportedVersionError