File setup_copy_python_versioned_so_file.patch of Package python-pulsar-client

--- 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
openSUSE Build Service is sponsored by