forked from pool/python-Yapsy
Accepting request 1160626 from devel:languages:python
- Clean up the SPEC file - Fix build on Python 3.12 with replace-deprecated-apis.patch OBS-URL: https://build.opensuse.org/request/show/1160626 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-Yapsy?expand=0&rev=7
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 22 10:43:29 UTC 2024 - Matej Cepl <mcepl@cepl.eu>
|
||||
|
||||
- Clean up the SPEC file
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Mar 21 09:44:18 UTC 2024 - Markéta Machová <mmachova@suse.com>
|
||||
|
||||
- Fix build on Python 3.12 with replace-deprecated-apis.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Aug 30 07:58:36 UTC 2021 - pgajdos@suse.com
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-Yapsy
|
||||
#
|
||||
# Copyright (c) 2021 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
|
||||
@@ -16,15 +16,19 @@
|
||||
#
|
||||
|
||||
|
||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||
Name: python-Yapsy
|
||||
Version: 1.12.2
|
||||
Release: 0
|
||||
Summary: Yet another plugin system
|
||||
License: BSD-2-Clause
|
||||
URL: http://yapsy.sourceforge.net
|
||||
URL: https://yapsy.sourceforge.net
|
||||
Source: https://files.pythonhosted.org/packages/source/Y/Yapsy/Yapsy-%{version}.tar.gz
|
||||
# PATCH-FIX-UPSTREAM https://github.com/tibonihoo/yapsy/pull/11 Replace Deprecated API's
|
||||
Patch0: replace-deprecated-apis.patch
|
||||
BuildRequires: %{python_module packaging}
|
||||
BuildRequires: %{python_module pip}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: %{python_module wheel}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
Provides: python-yapsy
|
||||
@@ -41,21 +45,22 @@ least version 2.3) and to implement only the basic functionalities
|
||||
needed to detect, load and keep track of several plugins.
|
||||
|
||||
%prep
|
||||
%setup -q -n Yapsy-%{version}
|
||||
%autosetup -p1 -n Yapsy-%{version}
|
||||
|
||||
%build
|
||||
%python_build
|
||||
%pyproject_wheel
|
||||
find yapsy/ -name "*.py" -exec sed -i -e '/^#!\s\?\/usr\/bin\/\(env\s\)\?python$/d' {} ';'
|
||||
|
||||
%install
|
||||
%python_install
|
||||
%pyproject_install
|
||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||
|
||||
%check
|
||||
%pyunittest discover -v
|
||||
|
||||
%files %{python_files}
|
||||
%{python_sitelib}/*
|
||||
%{python_sitelib}/yapsy
|
||||
%{python_sitelib}/Yapsy-%{version}*-info
|
||||
%doc CHANGELOG.txt README.txt
|
||||
%license LICENSE.txt
|
||||
|
||||
|
||||
174
replace-deprecated-apis.patch
Normal file
174
replace-deprecated-apis.patch
Normal file
@@ -0,0 +1,174 @@
|
||||
From 29286320673f9e853559cf20aeb3456e541afbd4 Mon Sep 17 00:00:00 2001
|
||||
From: Ameya Vikram Singh <ameya.v.singh@gmail.com>
|
||||
Date: Mon, 6 Feb 2023 13:31:23 +0530
|
||||
Subject: [PATCH 1/2] Remove Deprecated API's
|
||||
|
||||
* Replaced packaging.version instead of distutils.version
|
||||
* Replaced imp module to importlib
|
||||
|
||||
**Note:** Probably Deprecates Python 2.7 supports, and maybe some initial versions of Python 3.x.
|
||||
|
||||
Signed-off-by: Ameya Vikram Singh <ameya.v.singh@gmail.com>
|
||||
---
|
||||
package/test/test_PluginInfo.py | 3 ++-
|
||||
package/yapsy/PluginInfo.py | 6 +++---
|
||||
package/yapsy/PluginManager.py | 17 ++++++++++-------
|
||||
package/yapsy/VersionedPluginManager.py | 8 ++++----
|
||||
4 files changed, 19 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/test/test_PluginInfo.py b/test/test_PluginInfo.py
|
||||
index 0863671..29c736a 100644
|
||||
--- a/test/test_PluginInfo.py
|
||||
+++ b/test/test_PluginInfo.py
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
|
||||
from yapsy.PluginInfo import PluginInfo
|
||||
+from packaging.version import Version
|
||||
|
||||
|
||||
class PluginInfoTest(unittest.TestCase):
|
||||
@@ -20,7 +21,7 @@ def testDefaultValuesAndAccessors(self):
|
||||
self.assertEqual(None,pi.plugin_object)
|
||||
self.assertEqual([],pi.categories)
|
||||
self.assertEqual(None,pi.error)
|
||||
- self.assertEqual("0.0",pi.version)
|
||||
+ self.assertEqual(Version("0.0"),pi.version)
|
||||
self.assertEqual("Unknown",pi.author)
|
||||
self.assertEqual("Unknown",pi.copyright)
|
||||
self.assertEqual("None",pi.website)
|
||||
diff --git a/yapsy/PluginInfo.py b/yapsy/PluginInfo.py
|
||||
index 69d220e..700374e 100644
|
||||
--- a/yapsy/PluginInfo.py
|
||||
+++ b/yapsy/PluginInfo.py
|
||||
@@ -12,7 +12,7 @@
|
||||
"""
|
||||
|
||||
from yapsy.compat import ConfigParser
|
||||
-from distutils.version import StrictVersion
|
||||
+from packaging.version import Version
|
||||
|
||||
|
||||
class PluginInfo(object):
|
||||
@@ -105,7 +105,7 @@ def __setPath(self,path):
|
||||
|
||||
|
||||
def __getVersion(self):
|
||||
- return StrictVersion(self.details.get("Documentation","Version"))
|
||||
+ return Version(self.details.get("Documentation","Version"))
|
||||
|
||||
def setVersion(self, vstring):
|
||||
"""
|
||||
@@ -114,7 +114,7 @@ def setVersion(self, vstring):
|
||||
Used by subclasses to provide different handling of the
|
||||
version number.
|
||||
"""
|
||||
- if isinstance(vstring,StrictVersion):
|
||||
+ if isinstance(vstring,Version):
|
||||
vstring = str(vstring)
|
||||
if not self.details.has_section("Documentation"):
|
||||
self.details.add_section("Documentation")
|
||||
diff --git a/yapsy/PluginManager.py b/yapsy/PluginManager.py
|
||||
index 81a7c2b..b72de93 100644
|
||||
--- a/yapsy/PluginManager.py
|
||||
+++ b/yapsy/PluginManager.py
|
||||
@@ -128,10 +128,7 @@
|
||||
|
||||
import sys
|
||||
import os
|
||||
-try:
|
||||
- import importlib.abc.Loader as imp
|
||||
-except ImportError:
|
||||
- import imp
|
||||
+import importlib
|
||||
|
||||
from yapsy import log
|
||||
from yapsy import NormalizePluginNameForModuleName
|
||||
@@ -577,11 +574,17 @@ def _importModule(plugin_module_name, candidate_filepath):
|
||||
.. note:: Isolated and provided to be reused, but not to be reimplemented !
|
||||
"""
|
||||
# use imp to correctly load the plugin as a module
|
||||
+ candidate_module = None
|
||||
if os.path.isdir(candidate_filepath):
|
||||
- candidate_module = imp.load_module(plugin_module_name,None,candidate_filepath,("py","r",imp.PKG_DIRECTORY))
|
||||
+ if (spec := importlib.util.spec_from_file_location(candidate_filepath.split('/')[-1], candidate_filepath + "/__init__.py")) is not None:
|
||||
+ candidate_module = importlib.util.module_from_spec(spec)
|
||||
+ sys.modules[plugin_module_name] = candidate_module
|
||||
+ spec.loader.exec_module(candidate_module)
|
||||
else:
|
||||
- with open(candidate_filepath+".py","r") as plugin_file:
|
||||
- candidate_module = imp.load_module(plugin_module_name,plugin_file,candidate_filepath+".py",("py","r",imp.PY_SOURCE))
|
||||
+ if (spec := importlib.util.spec_from_file_location(candidate_filepath.split('/')[-1], candidate_filepath + ".py")) is not None:
|
||||
+ candidate_module = importlib.util.module_from_spec(spec)
|
||||
+ sys.modules[plugin_module_name] = candidate_module
|
||||
+ spec.loader.exec_module(candidate_module)
|
||||
return candidate_module
|
||||
|
||||
def instanciateElementWithImportInfo(self, element, element_name,
|
||||
diff --git a/yapsy/VersionedPluginManager.py b/yapsy/VersionedPluginManager.py
|
||||
index 83ad4fd..686a52a 100644
|
||||
--- a/yapsy/VersionedPluginManager.py
|
||||
+++ b/yapsy/VersionedPluginManager.py
|
||||
@@ -12,7 +12,7 @@
|
||||
"""
|
||||
|
||||
|
||||
-from distutils.version import StrictVersion
|
||||
+from packaging.version import Version
|
||||
|
||||
from yapsy.PluginInfo import PluginInfo
|
||||
from yapsy.IPlugin import IPlugin
|
||||
@@ -27,11 +27,11 @@ class VersionedPluginInfo(PluginInfo):
|
||||
|
||||
def __init__(self, plugin_name, plugin_path):
|
||||
PluginInfo.__init__(self, plugin_name, plugin_path)
|
||||
- # version number is now required to be a StrictVersion object
|
||||
- self.version = StrictVersion("0.0")
|
||||
+ # version number is now required to be a Version object
|
||||
+ self.version = Version("0.0")
|
||||
|
||||
def setVersion(self, vstring):
|
||||
- self.version = StrictVersion(vstring)
|
||||
+ self.version = Version(vstring)
|
||||
|
||||
|
||||
class VersionedPluginManager(PluginManagerDecorator):
|
||||
|
||||
From 6be89ef3ae923fc344579175f886b9967b834c88 Mon Sep 17 00:00:00 2001
|
||||
From: Ameya Vikram Singh <ameya.v.singh@gmail.com>
|
||||
Date: Sat, 18 Mar 2023 10:43:24 +0530
|
||||
Subject: [PATCH 2/2] Simplify implementation based on the PR comments
|
||||
|
||||
---
|
||||
package/yapsy/PluginManager.py | 16 ++++++++--------
|
||||
1 file changed, 8 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/yapsy/PluginManager.py b/yapsy/PluginManager.py
|
||||
index b72de93..9b82187 100644
|
||||
--- a/yapsy/PluginManager.py
|
||||
+++ b/yapsy/PluginManager.py
|
||||
@@ -575,16 +575,16 @@ def _importModule(plugin_module_name, candidate_filepath):
|
||||
"""
|
||||
# use imp to correctly load the plugin as a module
|
||||
candidate_module = None
|
||||
+ filepath_base = candidate_filepath.split('/')[-1]
|
||||
if os.path.isdir(candidate_filepath):
|
||||
- if (spec := importlib.util.spec_from_file_location(candidate_filepath.split('/')[-1], candidate_filepath + "/__init__.py")) is not None:
|
||||
- candidate_module = importlib.util.module_from_spec(spec)
|
||||
- sys.modules[plugin_module_name] = candidate_module
|
||||
- spec.loader.exec_module(candidate_module)
|
||||
+ location = candidate_filepath + '/__init__.py'
|
||||
else:
|
||||
- if (spec := importlib.util.spec_from_file_location(candidate_filepath.split('/')[-1], candidate_filepath + ".py")) is not None:
|
||||
- candidate_module = importlib.util.module_from_spec(spec)
|
||||
- sys.modules[plugin_module_name] = candidate_module
|
||||
- spec.loader.exec_module(candidate_module)
|
||||
+ location = candidate_filepath + '.py'
|
||||
+
|
||||
+ if (spec := importlib.util.spec_from_file_location(filepath_base, location)):
|
||||
+ candidate_module = importlib.util.module_from_spec(spec)
|
||||
+ sys.modules[plugin_module_name] = candidate_module
|
||||
+ spec.loader.exec_module(candidate_module)
|
||||
return candidate_module
|
||||
|
||||
def instanciateElementWithImportInfo(self, element, element_name,
|
||||
Reference in New Issue
Block a user