From d5c515c4553d831a5fca23ed7e8975d8f811c5bd3222680645d8be47cc30cbb7 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Sat, 13 Apr 2024 07:48:20 +0000 Subject: [PATCH] Accepting request 1167046 from home:mcalabkova:branches:devel:languages:python - Add patch no-six.patch to clean-up the unneeded six dependency. OBS-URL: https://build.opensuse.org/request/show/1167046 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-compat-patcher-core?expand=0&rev=12 --- no-six.patch | 174 +++++++++++++++++++++++++++++ python-compat-patcher-core.changes | 5 + python-compat-patcher-core.spec | 8 +- 3 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 no-six.patch diff --git a/no-six.patch b/no-six.patch new file mode 100644 index 0000000..50fba5f --- /dev/null +++ b/no-six.patch @@ -0,0 +1,174 @@ +Index: compat-patcher-core-release-2.2/src/compat_patcher_core/registry.py +=================================================================== +--- compat-patcher-core-release-2.2.orig/src/compat_patcher_core/registry.py ++++ compat-patcher-core-release-2.2/src/compat_patcher_core/registry.py +@@ -3,8 +3,6 @@ from __future__ import absolute_import, + import collections + import itertools + +-import six +- + from compat_patcher_core.utilities import ( + tuplify_software_version, + _import_attribute_from_dotted_string, +@@ -30,7 +28,7 @@ class PatchingRegistry(object): + self, family_prefix, populate_callable=None, current_software_version=None + ): + assert family_prefix and isinstance( +- family_prefix, six.string_types ++ family_prefix, str + ), family_prefix + assert populate_callable is None or hasattr( + populate_callable, "__call__" +@@ -47,10 +45,10 @@ class PatchingRegistry(object): + version of the software to be patched. + """ + current_software_version = self._current_software_version +- if six.callable(current_software_version): ++ if callable(current_software_version): + current_software_version = current_software_version() + assert current_software_version is None or isinstance( +- current_software_version, (six.string_types, tuple, list) ++ current_software_version, (str, tuple, list) + ), current_software_version + return current_software_version + +@@ -109,7 +107,7 @@ class PatchingRegistry(object): + """ + + assert ( +- isinstance(fixer_reference_version, six.string_types) ++ isinstance(fixer_reference_version, str) + and fixer_reference_version + ), fixer_reference_version # eg. "1.9" + assert fixer_tags is None or isinstance(fixer_tags, list), fixer_tags +@@ -325,12 +323,12 @@ class MultiPatchingRegistry(object): + + original_registry_reference = registry_reference + +- if isinstance(registry_reference, six.string_types): ++ if isinstance(registry_reference, str): + registry_reference = _import_attribute_from_dotted_string( + registry_reference + ) + +- if six.callable(registry_reference): ++ if callable(registry_reference): + registry_reference = registry_reference() + + if not isinstance(registry_reference, PatchingRegistry): +@@ -379,6 +377,4 @@ class MultiPatchingRegistry(object): + pass + raise KeyError("Fixer %r not found in any patching registries" % fixer_id) + +- get_relevant_fixer_ids = six.get_unbound_function( +- PatchingRegistry.get_relevant_fixer_ids +- ) # Unmodified ++ get_relevant_fixer_ids = PatchingRegistry.get_relevant_fixer_ids # Unmodified +Index: compat-patcher-core-release-2.2/src/compat_patcher_core/runner.py +=================================================================== +--- compat-patcher-core-release-2.2.orig/src/compat_patcher_core/runner.py ++++ compat-patcher-core-release-2.2/src/compat_patcher_core/runner.py +@@ -2,8 +2,6 @@ from __future__ import absolute_import, + + import functools + +-import six +- + from compat_patcher_core.exceptions import SkipFixerException + + +@@ -46,7 +44,7 @@ class PatchingRunner(object): + if name.startswith("include") or name.startswith("exclude"): + assert value in ("*", None) or ( + isinstance(value, (list, tuple)) +- and all(isinstance(f, six.string_types) for f in value) ++ and all(isinstance(f, str) for f in value) + ), value + + return value +Index: compat-patcher-core-release-2.2/src/compat_patcher_core/utilities.py +=================================================================== +--- compat-patcher-core-release-2.2.orig/src/compat_patcher_core/utilities.py ++++ compat-patcher-core-release-2.2/src/compat_patcher_core/utilities.py +@@ -7,8 +7,6 @@ import sys + import types + import warnings as stdlib_warnings # Do NOT import/use elsewhere than here! + +-import six +- + + def tuplify_software_version(version): + """ +@@ -17,10 +15,10 @@ def tuplify_software_version(version): + """ + if version is None: + return version +- if isinstance(version, six.string_types): ++ if isinstance(version, str): + version = tuple(int(x) for x in version.split(".")) + assert len(version) <= 5, version +- assert all(isinstance(x, six.integer_types) for x in version), version ++ assert all(isinstance(x, int) for x in version), version + return version + + +@@ -33,7 +31,7 @@ def detuplify_software_version(version): + return version + if isinstance(version, (tuple, list)): + version = ".".join(str(number) for number in version) +- assert isinstance(version, six.string_types) ++ assert isinstance(version, str) + return version + + +@@ -104,7 +102,7 @@ class PatchingUtilities(object): + if patch_injected_objects is True: + patch_injected_objects = "__COMPAT_PATCHED__" # Default marker name + assert not patch_injected_objects or isinstance( +- patch_injected_objects, six.string_types ++ patch_injected_objects, str + ), repr(patch_injected_objects) + self._patch_injected_objects = patch_injected_objects + +@@ -161,7 +159,7 @@ class PatchingUtilities(object): + """ + assert attribute is not None + assert not self._is_simple_callable(attribute), attribute +- assert not isinstance(attribute, six.class_types), attribute ++ assert not isinstance(attribute, type), attribute + + self._patch_injected_object(attribute) + setattr(target_object, target_attrname, attribute) +@@ -217,7 +215,7 @@ class PatchingUtilities(object): + :param target_klassname: The name given to the new class in the object to patch + :param klass: The class to inject + """ +- assert isinstance(klass, six.class_types), klass ++ assert isinstance(klass, type), klass + + self._patch_injected_object(klass) + setattr(target_object, target_klassname, klass) +Index: compat-patcher-core-release-2.2/tests/test_import_proxifier.py +=================================================================== +--- compat-patcher-core-release-2.2.orig/tests/test_import_proxifier.py ++++ compat-patcher-core-release-2.2/tests/test_import_proxifier.py +@@ -1,4 +1,4 @@ +-import sys, six ++import sys, urllib + + from compat_patcher_core.import_proxifier import ( + install_import_proxifier, +@@ -90,8 +90,8 @@ def test_import_proxifier(): + + # We test_compatibility_with_other_custom_importers(): + # Old versions of lib crashed with AssertionError due to wrong module name "six.moves.urllib_parse" set by six._importer +- register_module_alias("my_six_urllib_parse_alias", real_name="six.moves.urllib.parse") +- import my_six_urllib_parse_alias ++ register_module_alias("my_urllib_parse_alias", real_name="urllib.parse") ++ import my_urllib_parse_alias + # Re-overridden by our own importer on python3 only +- assert my_six_urllib_parse_alias.__name__ == "six.moves.urllib.parse" if six.PY3 else "six.moves.urllib_parse" +- assert my_six_urllib_parse_alias.urlencode(dict(name="h\xc3llo")) == "name=h%C3%83llo" if six.PY3 else "name=h%C3llo" ++ assert my_urllib_parse_alias.__name__ == "urllib.parse" ++ assert my_urllib_parse_alias.urlencode(dict(name="h\xc3llo")) == "name=h%C3%83llo" diff --git a/python-compat-patcher-core.changes b/python-compat-patcher-core.changes index cdf22e1..9e08b5d 100644 --- a/python-compat-patcher-core.changes +++ b/python-compat-patcher-core.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Apr 12 11:48:56 UTC 2024 - Markéta Machová + +- Add patch no-six.patch to clean-up the unneeded six dependency. + ------------------------------------------------------------------- Wed Nov 29 12:43:32 UTC 2023 - Dirk Müller diff --git a/python-compat-patcher-core.spec b/python-compat-patcher-core.spec index 7772724..5d67689 100644 --- a/python-compat-patcher-core.spec +++ b/python-compat-patcher-core.spec @@ -1,7 +1,7 @@ # # spec file for package python-compat-patcher-core # -# 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 @@ -25,20 +25,20 @@ License: MIT Group: Development/Languages/Python URL: https://github.com/pakal/compat-patcher-core Source: https://github.com/pakal/compat-patcher-core/archive/refs/tags/release-%{version}.tar.gz#/compat-patch-core-%{version}-gh.tar.gz +# PATCH-FIX-UPSTREAM https://github.com/pakal/compat-patcher-core/pull/3 Get rid of the six dependency +Patch: no-six.patch BuildRequires: %{python_module pip} BuildRequires: %{python_module wheel} BuildRequires: cookiecutter > 1.6.0 BuildRequires: dos2unix BuildRequires: fdupes BuildRequires: python-rpm-macros -Requires: python-six Suggests: cookiecutter > 1.6.0 BuildArch: noarch # SECTION test requirements BuildRequires: %{python_module docutils} BuildRequires: %{python_module pytest-cov} BuildRequires: %{python_module pytest} -BuildRequires: %{python_module six} BuildRequires: %{python_module tomli} BuildRequires: python3-pytest-cookies # /SECTION @@ -48,7 +48,7 @@ BuildRequires: python3-pytest-cookies Python patcher system to allow easy and lasting API compatibility. %prep -%setup -q -n compat-patcher-core-release-%{version} +%autosetup -p1 -n compat-patcher-core-release-%{version} %build %pyproject_wheel