From cb50cc165577ffb8ed3058052904aab8bc895484d156310000a1e23c99d33241 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Tue, 26 Nov 2024 16:53:53 +0000 Subject: [PATCH] Accepting request 1226585 from home:fmccarthy:branches:devel:languages:python Updated to address pytest excluded tests specification feedback and fix build issues identified by test runs when building for multiple Python versions. OBS-URL: https://build.opensuse.org/request/show/1226585 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pulsar-client?expand=0&rev=1 --- .gitattributes | 23 +++ .gitignore | 1 + _multibuild | 3 + _service | 20 ++ cmake_use_specific_python_version.patch | 26 +++ pulsar-client-python-3.5.0.tar.xz | 3 + python-pulsar-client.changes | 18 ++ python-pulsar-client.spec | 234 ++++++++++++++++++++++ setup_copy_python_versioned_so_file.patch | 33 +++ 9 files changed, 361 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 _multibuild create mode 100644 _service create mode 100644 cmake_use_specific_python_version.patch create mode 100644 pulsar-client-python-3.5.0.tar.xz create mode 100644 python-pulsar-client.changes create mode 100644 python-pulsar-client.spec create mode 100644 setup_copy_python_versioned_so_file.patch diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/_multibuild b/_multibuild new file mode 100644 index 0000000..fcc7b97 --- /dev/null +++ b/_multibuild @@ -0,0 +1,3 @@ + + test + diff --git a/_service b/_service new file mode 100644 index 0000000..7340be0 --- /dev/null +++ b/_service @@ -0,0 +1,20 @@ + + + git + https://github.com/apache/pulsar-client-python.git + v3.5.0 + v* + @PARENT_TAG@ + v(.*) + + pybind11 + + + *.tar + xz + + + pulsar-client-python + python-pulsar-client.spec + + diff --git a/cmake_use_specific_python_version.patch b/cmake_use_specific_python_version.patch new file mode 100644 index 0000000..f242e26 --- /dev/null +++ b/cmake_use_specific_python_version.patch @@ -0,0 +1,26 @@ +diff -pru pulsar-client-python-3.5.0.orig/CMakeLists.txt pulsar-client-python-3.5.0.new/CMakeLists.txt +--- pulsar-client-python-3.5.0.orig/CMakeLists.txt 2024-04-02 02:38:10.000000000 -0400 ++++ pulsar-client-python-3.5.0.new/CMakeLists.txt 2024-11-19 08:07:09.147620062 -0500 +@@ -51,7 +51,11 @@ message(STATUS "PULSAR_INCLUDE: ${PULSAR + + SET(CMAKE_CXX_STANDARD 11) + +-find_package (Python3 REQUIRED COMPONENTS Development.Module) ++if (DEFINED USE_PYTHON_VERSION) ++ set(PYTHON_VERSION_REQUIREMENT ${USE_PYTHON_VERSION} EXACT) ++ message(STATUS "Using Python version: " ${USE_PYTHON_VERSION}) ++endif() ++find_package (Python3 ${PYTHON_VERSION_REQUIREMENT} REQUIRED COMPONENTS Development.Module) + MESSAGE(STATUS "PYTHON: " ${Python3_VERSION} " - " ${Python3_INCLUDE_DIRS}) + + find_path(PYBIND11_INCLUDE_DIRS NAMES "pybind11/pybind11.h") +@@ -81,6 +85,9 @@ set(PYTHON_WRAPPER_LIBS + ${PULSAR_LIBRARY} + ) + set(PYTHON_WRAPPER_LIBS ${PYTHON_WRAPPER_LIBS} Python3::Module) ++if (DEFINED USE_PYTHON_VERSION) ++ set(PYTHON_WRAPPER_LIBS ${PYTHON_WRAPPER_LIBS} ${LIB_INSTALL_DIR}/libpython${USE_PYTHON_VERSION}.so) ++endif() + + message(STATUS "All libraries: ${PYTHON_WRAPPER_LIBS}") + diff --git a/pulsar-client-python-3.5.0.tar.xz b/pulsar-client-python-3.5.0.tar.xz new file mode 100644 index 0000000..0462f24 --- /dev/null +++ b/pulsar-client-python-3.5.0.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:72e473c4f4a8f29487c45fb0941e285dcfb486c0254ad5651474e6aed0fdf7f3 +size 87720 diff --git a/python-pulsar-client.changes b/python-pulsar-client.changes new file mode 100644 index 0000000..520cac5 --- /dev/null +++ b/python-pulsar-client.changes @@ -0,0 +1,18 @@ +------------------------------------------------------------------- +Tue Nov 26 15:41:54 UTC 2024 - Fergal Mc Carthy + +- Fix build step to ensure the appropriate externally built library + file is used by the python build step when building for multiple + Python versions. + +------------------------------------------------------------------- +Fri Nov 22 22:57:02 UTC 2024 - Fergal Mc Carthy + +- Update disabled test specification to use the test class name + rather than file name. Also re-enable 3 tests that can safely + run that were inadvertently being disabled. + +------------------------------------------------------------------- +Fri Nov 1 21:35:47 UTC 2024 - Fergal Mc Carthy - 3.5.0 + +- Initial release based upon v3.5.0 diff --git a/python-pulsar-client.spec b/python-pulsar-client.spec new file mode 100644 index 0000000..d1f9800 --- /dev/null +++ b/python-pulsar-client.spec @@ -0,0 +1,234 @@ +# +# spec file for package python-pulsar-client +# +# 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 +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + +%global flavor @BUILD_FLAVOR@%{nil} +%if "%{flavor}" == "test" +%define psuffix -test +%bcond_without test +%else +%define psuffix %{nil} +%bcond_with test +%endif + +# pulsar-client-cpp doesn't build for 32bit architectures +ExcludeArch: %{ix86} %{arm32} + +%{?sle15_python_module_pythons} +Name: python-pulsar-client%{psuffix} +Version: 3.5.0 +Release: 0 +Group: Development/Libraries/Python +Summary: Apache Pulsar Python client library +License: Apache-2.0 +URL: https://github.com/apache/pulsar-client-python +Source: https://github.com/apache/pulsar-client-python/archive/refs/tags/v3.5.0.tar.xz#/pulsar-client-python-3.5.0.tar.xz +# PATCH-FIX-OPENSUSE cmake_use_specific_python_version.patch +Patch0: cmake_use_specific_python_version.patch +# PATCH-FIX-OPENSUSE setup_copy_python_versioned_so_file.patch +Patch1: setup_copy_python_versioned_so_file.patch +Requires: %{python_flavor}-certifi +Recommends: %{python_flavor}-apache-bookkeeper-client >= 4.16.1 +Recommends: %{python_flavor}-fastavro >= 1.9.2 +Recommends: %{python_flavor}-grpcio >= 1.60.0 +Recommends: %{python_flavor}-prometheus-client +Recommends: %{python_flavor}-protobuf >= 3.6.1 +Recommends: %{python_flavor}-ratelimit +BuildRequires: c++_compiler +BuildRequires: cmake +BuildRequires: fdupes +BuildRequires: protobuf-devel +BuildRequires: pulsar-client-cpp-devel +BuildRequires: %{python_module pip} +BuildRequires: %{python_module pybind11-devel} +BuildRequires: %{python_module pybind11} +BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} +%if %{with test} +# SECTION test requirements +BuildRequires: %{python_module fastavro >= 1.9.7} +BuildRequires: %{python_module pytest-xdist} +BuildRequires: %{python_module pytest} +BuildRequires: %{python_module pulsar-client = %{version}} +BuildRequires: %{python_module requests} +# /SECTION +%endif + +%python_subpackages + +%description +Pulsar Python clients support a variety of Pulsar features to enable +building applications connecting to your Pulsar cluster. + +%prep +%autosetup -p1 -n pulsar-client-python-%{version} + +%build +%if %{without test} +%{python_expand # this will expand the following steps +%cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DUSE_PYTHON_VERSION=%{$python_version} \ +%{nil} + +%cmake_build + +# the python setup.py build step below expects to find +# an appropriately named library file in the top level +# directory so copy the built lib_pulsar.so to a python +# versioned name so that the correct file is used when +# building for multiple python versions. +cp lib_pulsar.so ../lib_pulsar%{$python_version}.so + +cd .. +} +%python_build +%endif + +%install +%if %{without test} +%python_install +%python_expand %fdupes %{buildroot}%{$python_sitearch} +%endif + +%check +%if %{with test} +# disable tests that fail due to lack of network connectivity +donttest="(AsyncioTest and test_batch_send) or " +donttest+="(AsyncioTest and test_close_producer) or " +donttest+="(AsyncioTest and test_create_producer_failure) or " +donttest+="(AsyncioTest and test_send_failure) or " +donttest+="(CustomLoggingTest and test_async_func_with_custom_logger) or " +donttest+="(InterruptedTest and test_sigint) or " +donttest+="(Oauth2Test and test_base64) or " +donttest+="(Oauth2Test and test_invalid_private_key) or " +donttest+="(Oauth2Test and test_key_file) or " +donttest+="(Oauth2Test and test_wrong_secret) or " +donttest+="(SchemaTest and test_avro_enum) or " +donttest+="(SchemaTest and test_avro_map_array) or " +donttest+="(SchemaTest and test_avro_required_default) or " +donttest+="(SchemaTest and test_avro_schema) or " +donttest+="(SchemaTest and test_bytes_schema) or " +donttest+="(SchemaTest and test_default_value) or " +donttest+="(SchemaTest and test_json_enum) or " +donttest+="(SchemaTest and test_json_schema) or " +donttest+="(SchemaTest and test_produce_and_consume_complex_schema_data) or " +donttest+="(SchemaTest and test_schema_evolve) or " +donttest+="(SchemaTest and test_schema_type_promotion) or " +donttest+="(SchemaTest and test_schema_version) or " +donttest+="(SchemaTest and test_string_schema) or " +donttest+="(ReaderTest and test_has_message_available_after_seek) or " +donttest+="(ReaderTest and test_seek_latest_message_id) or " +donttest+="(PulsarTest and test_acknowledge_failed) or " +donttest+="(PulsarTest and test_basic_auth) or " +donttest+="(PulsarTest and test_basic_auth_method) or " +donttest+="(PulsarTest and test_batch_index_ack) or " +donttest+="(PulsarTest and test_batch_receive) or " +donttest+="(PulsarTest and test_chunking) or " +donttest+="(PulsarTest and test_client_reference_deleted) or " +donttest+="(PulsarTest and test_configure_log_level) or " +donttest+="(PulsarTest and test_configure_log_to_file) or " +donttest+="(PulsarTest and test_connect_timeout) or " +donttest+="(PulsarTest and test_consumer_initial_position) or " +donttest+="(PulsarTest and test_consumer_is_connected) or " +donttest+="(PulsarTest and test_consumer_name) or " +donttest+="(PulsarTest and test_consumer_queue_size_is_zero) or " +donttest+="(PulsarTest and test_dead_letter_policy) or " +donttest+="(PulsarTest and test_deliver_after) or " +donttest+="(PulsarTest and test_deliver_at) or " +donttest+="(PulsarTest and test_encryption) or " +donttest+="(PulsarTest and test_get_last_message_id) or " +donttest+="(PulsarTest and test_get_partitioned_topic_name) or " +donttest+="(PulsarTest and test_get_topic_name) or " +donttest+="(PulsarTest and test_get_topics_partitions) or " +donttest+="(PulsarTest and test_invalid_basic_auth) or " +donttest+="(PulsarTest and test_keyshared_autosplit) or " +donttest+="(PulsarTest and test_logger_thread_leaks) or " +donttest+="(PulsarTest and test_message_argument_errors) or " +donttest+="(PulsarTest and test_message_listener) or " +donttest+="(PulsarTest and test_message_properties) or " +donttest+="(PulsarTest and test_negative_acks) or " +donttest+="(PulsarTest and test_ordering_key) or " +donttest+="(PulsarTest and test_producer_access_mode_exclusive) or " +donttest+="(PulsarTest and test_producer_access_mode_exclusive_with_fencing) or " +donttest+="(PulsarTest and test_producer_access_mode_wait_exclusive) or " +donttest+="(PulsarTest and test_producer_consumer) or " +donttest+="(PulsarTest and test_producer_consumer_zstd) or " +donttest+="(PulsarTest and test_producer_deduplication) or " +donttest+="(PulsarTest and test_producer_is_connected) or " +donttest+="(PulsarTest and test_producer_routing_mode) or " +donttest+="(PulsarTest and test_producer_send) or " +donttest+="(PulsarTest and test_producer_send_async) or " +donttest+="(PulsarTest and test_producer_sequence_after_reconnection) or " +donttest+="(PulsarTest and test_publish_compact_and_consume) or " +donttest+="(PulsarTest and test_reader_argument_errors) or " +donttest+="(PulsarTest and test_reader_has_message_available) or " +donttest+="(PulsarTest and test_reader_is_connected) or " +donttest+="(PulsarTest and test_reader_on_last_message) or " +donttest+="(PulsarTest and test_reader_on_partitioned_topic) or " +donttest+="(PulsarTest and test_reader_on_specific_message) or " +donttest+="(PulsarTest and test_reader_on_specific_message_with_batches) or " +donttest+="(PulsarTest and test_reader_seek_for_message_id) or " +donttest+="(PulsarTest and test_reader_simple) or " +donttest+="(PulsarTest and test_redelivery_count) or " +donttest+="(PulsarTest and test_regex_subscription) or " +donttest+="(PulsarTest and test_seek) or " +donttest+="(PulsarTest and test_seek_inclusive) or " +donttest+="(PulsarTest and test_send_async_no_deadlock) or " +donttest+="(PulsarTest and test_shutdown_client) or " +donttest+="(PulsarTest and test_simple_producer) or " +donttest+="(PulsarTest and test_sticky_autosplit) or " +donttest+="(PulsarTest and test_tls_auth) or " +donttest+="(PulsarTest and test_tls_auth2) or " +donttest+="(PulsarTest and test_tls_auth3) or " +donttest+="(PulsarTest and test_token_auth) or " +donttest+="(PulsarTest and test_token_auth_supplier) or " +donttest+="(PulsarTest and test_topics_consumer) or " +donttest+="(PulsarTest and test_topics_pattern_consumer) or " +donttest+="(PulsarTest and test_v2_topics) or " +donttest+="(PulsarTest and test_v2_topics_http) or " +donttest+="(ReaderTest and test_has_message_available_after_seek) or " +donttest+="(ReaderTest and test_seek_latest_message_id) or " +donttest+="(SchemaTest and test_avro_enum) or " +donttest+="(SchemaTest and test_avro_map_array) or " +donttest+="(SchemaTest and test_avro_required_default) or " +donttest+="(SchemaTest and test_avro_schema) or " +donttest+="(SchemaTest and test_bytes_schema) or " +donttest+="(SchemaTest and test_default_value) or " +donttest+="(SchemaTest and test_json_enum) or " +donttest+="(SchemaTest and test_json_schema) or " +donttest+="(SchemaTest and test_produce_and_consume_complex_schema_data) or " +donttest+="(SchemaTest and test_schema_evolve) or " +donttest+="(SchemaTest and test_schema_type_promotion) or " +donttest+="(SchemaTest and test_schema_version) or " +donttest+="(SchemaTest and test_string_schema)" +# reenable tests that can safely run, which may have been inadvertently +# disabled by the above donttest patterns +dotest+="or (PulsarTest and test_dead_letter_policy_config) " +dotest+="or (SchemaTest and test_json_schema_encode_remove_reserved_key)" +%pytest -v -k "not ($donttest) ${dotest}" +%endif + +%if %{without test} +%files %{python_files} +%license LICENSE +%doc README.md +%{python_sitearch}/_pulsar*.so +%{python_sitearch}/pulsar +%{python_sitearch}/pulsar_client-%{version}*-info +%endif + +%changelog diff --git a/setup_copy_python_versioned_so_file.patch b/setup_copy_python_versioned_so_file.patch new file mode 100644 index 0000000..53ef42f --- /dev/null +++ b/setup_copy_python_versioned_so_file.patch @@ -0,0 +1,33 @@ +--- pulsar-client-python-3.5.0.orig/setup.py 2024-04-02 02:38:10.000000000 -0400 ++++ pulsar-client-python-3.5.0.new/setup.py 2024-11-26 10:35:12.536508228 -0500 +@@ -63,10 +63,26 @@ class my_build_ext(build_ext.build_ext): + if 'Windows' in platform.platform(): + shutil.copyfile('_pulsar.pyd', self.get_ext_fullpath(ext.name)) + else: +- try: +- shutil.copyfile('_pulsar.so', self.get_ext_fullpath(ext.name)) +- except FileNotFoundError: +- shutil.copyfile('lib_pulsar.so', self.get_ext_fullpath(ext.name)) ++ # construct list of pre-compiled pulsar library files ++ # to search for in preferred order. ++ pyver = '.'.join(platform.python_version_tuple()[0:2]) ++ so_files = [ ++ '_pulsar' + pyver + '.so', ++ 'lib_pulsar' + pyver + '.so', ++ '_pulsar.so', ++ 'lib_pulsar.so' ++ ] ++ # check for all but the last library file in order ++ for so_file in so_files[0:-1]: ++ ++ try: ++ shutil.copyfile(so_file, self.get_ext_fullpath(ext.name)) ++ break ++ except FileNotFoundError: ++ continue ++ else: ++ # check last library file, raising an exception if not found ++ shutil.copyfile(so_files[-1], self.get_ext_fullpath(ext.name)) + + + # Core Client dependencies