[packages/python-anyjson] - added python3,do-not-use-2to3,update-order patches from Fedora; use six instead of 2to3 (fixes pyt

qboosh qboosh at pld-linux.org
Sat Oct 14 09:40:18 CEST 2023


commit 18ff688136c5301802ac1528163006f04d5b898b
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Sat Oct 14 09:42:10 2023 +0200

    - added python3,do-not-use-2to3,update-order patches from Fedora; use six instead of 2to3 (fixes python3 build)

 anyjson-do-not-use-2to3.patch     | 16 +++++++++
 anyjson-python3.patch             | 69 +++++++++++++++++++++++++++++++++++++++
 python-anyjson-update-order.patch | 27 +++++++++++++++
 python-anyjson.spec               | 26 ++++++++++++---
 4 files changed, 133 insertions(+), 5 deletions(-)
---
diff --git a/python-anyjson.spec b/python-anyjson.spec
index 74f2e5b..a4d9009 100644
--- a/python-anyjson.spec
+++ b/python-anyjson.spec
@@ -1,6 +1,6 @@
 #
 # Conditional build:
-%bcond_without	tests	# do not perform "make test"
+%bcond_without	tests	# unit tests
 %bcond_without	python2 # CPython 2.x module
 %bcond_without	python3 # CPython 3.x module
 
@@ -12,21 +12,34 @@ Version:	0.3.3
 Release:	10
 License:	BSD
 Group:		Development/Languages/Python
-Source0:	http://pypi.python.org/packages/source/a/%{module}/%{module}-%{version}.tar.gz
+Source0:	https://files.pythonhosted.org/packages/source/a/anyjson/%{module}-%{version}.tar.gz
 # Source0-md5:	2ea28d6ec311aeeebaf993cb3008b27c
-URL:		https://bitbucket.org/runeh/anyjson
+# use six instead of 2to3 (which is no longer supported by python3 setuptools)
+Patch0:		anyjson-python3.patch
+Patch1:		anyjson-do-not-use-2to3.patch
+# raise priority of cjson and drop the 'deprecation' warning (it's about as
+# alive as half the others), drop jsonlib, jsonlib2 and django.utils.simplejson
+# (which are more dead)
+Patch2:		%{name}-update-order.patch
+URL:		https://pypi.org/project/anyjson/
 BuildRequires:	rpm-pythonprov
 BuildRequires:	rpmbuild(macros) >= 1.714
 %if %{with python2}
 BuildRequires:	python-modules >= 1:2.4
-%{?with_tests:BuildRequires: python-nose}
 BuildRequires:	python-setuptools
+%if %{with tests}
+BuildRequires:	python-nose
+BuildRequires:	python-six
+%endif
 %endif
 %if %{with python3}
 BuildRequires:	python3-2to3 >= 1:3.2
 BuildRequires:	python3-modules >= 1:3.2
-%{?with_tests:BuildRequires: python3-nose}
 BuildRequires:	python3-setuptools
+%if %{with tests}
+BuildRequires:	python3-nose
+BuildRequires:	python3-six
+%endif
 %endif
 Requires:	python-modules >= 1:2.4
 BuildArch:	noarch
@@ -58,6 +71,9 @@ udostępnia jednolite API, niezależnie od używanej implementacji JSON.
 
 %prep
 %setup -q -n %{module}-%{version}
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
 
 %build
 %if %{with python2}
diff --git a/anyjson-do-not-use-2to3.patch b/anyjson-do-not-use-2to3.patch
new file mode 100644
index 0000000..8603130
--- /dev/null
+++ b/anyjson-do-not-use-2to3.patch
@@ -0,0 +1,16 @@
+Description: Do not use 2to3
+Author: Thomas Goirand <zigo at debian.org>
+Forwarded: no
+Last-Update: 2021-11-11
+
+--- python-anyjson-0.3.3.orig/setup.py
++++ python-anyjson-0.3.3/setup.py
+@@ -2,8 +2,6 @@ import os
+ import sys
+ 
+ extra = {}
+-if sys.version_info >= (3, 0):
+-    extra.update(use_2to3=True)
+ 
+ try:
+     from setuptools import setup, find_packages
diff --git a/anyjson-python3.patch b/anyjson-python3.patch
new file mode 100644
index 0000000..5e16f8f
--- /dev/null
+++ b/anyjson-python3.patch
@@ -0,0 +1,69 @@
+--- anyjson-0.3.3/anyjson/__init__.py	2012-06-21 16:08:51.000000000 -0700
++++ anyjson-0.3.3/anyjson/__init__.py.new	2016-12-24 14:52:05.027940293 -0800
+@@ -1,6 +1,7 @@
+ """Wraps the best available JSON implementation available in a common
+ interface"""
+ 
++from six import (reraise, string_types)
+ import sys
+ 
+ VERSION = (0, 3, 3)
+@@ -64,9 +65,9 @@
+         self._encode_error = modinfo["encerror"]
+         self._decode_error = modinfo["decerror"]
+ 
+-        if isinstance(modinfo["encerror"], basestring):
++        if isinstance(modinfo["encerror"], string_types):
+             self._encode_error = getattr(module, modinfo["encerror"])
+-        if isinstance(modinfo["decerror"], basestring):
++        if isinstance(modinfo["decerror"], string_types):
+             self._decode_error = getattr(module, modinfo["decerror"])
+ 
+         self.name = modinfo["modname"]
+@@ -85,8 +86,8 @@
+         TypeError if the object could not be serialized."""
+         try:
+             return self._encode(data)
+-        except self._encode_error, exc:
+-            raise TypeError, TypeError(*exc.args), sys.exc_info()[2]
++        except self._encode_error as exc:
++            reraise(TypeError, TypeError(*exc.args), sys.exc_info()[2])
+     serialize = dumps
+ 
+     def loads(self, s):
+@@ -94,11 +95,11 @@
+         ValueError if the string could not be parsed."""
+         # uses StringIO to support buffer objects.
+         try:
+-            if self._filedecode and not isinstance(s, basestring):
++            if self._filedecode and not isinstance(s, string_types):
+                 return self._filedecode(StringIO(s))
+             return self._decode(s)
+-        except self._decode_error, exc:
+-            raise ValueError, ValueError(*exc.args), sys.exc_info()[2]
++        except self._decode_error as exc:
++            reraise(ValueError, ValueError(*exc.args), sys.exc_info()[2])
+     deserialize = loads
+ 
+ 
+@@ -117,8 +118,7 @@
+     # We do NOT try to load a compatible module because that may throw an
+     # exception, which renders the package uninstallable with easy_install
+     # (It trys to execfile the script when installing, to make sure it works)
+-    print "Running anyjson as a stand alone script is not supported"
+-    sys.exit(1)
++    sys.exit("Running anyjson as a stand alone script is not supported")
+ else:
+     for modspec in _modules:
+         try:
+--- anyjson-0.3.3/setup.py.orig	2012-06-22 00:59:59.000000000 +0200
++++ anyjson-0.3.3/setup.py	2023-10-14 09:40:00.000190565 +0200
+@@ -54,7 +54,7 @@ finally:
+ 
+ supported = ["yajl", "jsonlib2", "jsonlib", "simplejson",
+              "json", "django.utils.simplejson", "cjson"]
+-install_requires = []
++install_requires = ["six"]
+ for module in supported:
+     try:
+         __import__(module)
diff --git a/python-anyjson-update-order.patch b/python-anyjson-update-order.patch
new file mode 100644
index 0000000..45d3542
--- /dev/null
+++ b/python-anyjson-update-order.patch
@@ -0,0 +1,27 @@
+--- anyjson-0.3.3/anyjson/__init__.py	2017-02-10 14:45:17.898510326 -0800
++++ anyjson-0.3.3/anyjson/__init__.py.new	2017-02-10 14:45:27.501549767 -0800
+@@ -32,12 +32,9 @@
+ #: methods, as well as the exceptions they throw.  Exception can be either
+ #: an exception class or a string.
+ _modules = [("yajl", "dumps", TypeError, "loads", ValueError, "load"),
+-            ("jsonlib2", "write", "WriteError", "read", "ReadError", None),
+-            ("jsonlib", "write", "WriteError", "read", "ReadError", None),
++            ("cjson", "encode", "EncodeError", "decode", "DecodeError", None),
+             ("simplejson", "dumps", TypeError, "loads", ValueError, "load"),
+             ("json", "dumps", TypeError, "loads", ValueError, "load"),
+-            ("django.utils.simplejson", "dumps", TypeError, "loads", ValueError, "load"),
+-            ("cjson", "encode", "EncodeError", "decode", "DecodeError", None)
+            ]
+ 
+ _fields = ("modname", "encoder", "encerror",
+@@ -50,10 +47,6 @@
+     def __init__(self, modspec):
+         modinfo = dict(zip(_fields, modspec))
+ 
+-        if modinfo["modname"] == "cjson":
+-            import warnings
+-            warnings.warn("cjson is deprecated! See http://pypi.python.org/pypi/python-cjson/1.0.5", DeprecationWarning)
+-
+         # No try block. We want importerror to end up at caller
+         module = self._attempt_load(modinfo["modname"])
+ 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-anyjson.git/commitdiff/18ff688136c5301802ac1528163006f04d5b898b



More information about the pld-cvs-commit mailing list