From 2a40cf4f35adb195a9d4bb0c649626458a2727d8 Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Thu, 20 Oct 2022 20:02:42 +0000 Subject: [PATCH 1/2] package/python-nbformat: patch for py >=3.9 compat nbformat 4.4 contains an unused import of a function that was deprecated since python 3.1 and removed in python 3.9. Since we now run 3.10, this causes things that import nbformat to raise an ImportError. By removing the import we should be able to import nbformat on 3.10 again. --- ...1-v1-remove-unused-deprecated-import.patch | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 package/python-nbformat/0001-v1-remove-unused-deprecated-import.patch diff --git a/package/python-nbformat/0001-v1-remove-unused-deprecated-import.patch b/package/python-nbformat/0001-v1-remove-unused-deprecated-import.patch new file mode 100644 index 0000000000..33f1fab649 --- /dev/null +++ b/package/python-nbformat/0001-v1-remove-unused-deprecated-import.patch @@ -0,0 +1,24 @@ +From 0b66e0d6be6d62e4828108fd7993106c279fab75 Mon Sep 17 00:00:00 2001 +From: Seth Foster +Date: Thu, 20 Oct 2022 15:52:47 -0400 +Subject: [PATCH] v1: remove unused deprecated import + +--- + nbformat/v1/nbjson.py | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/nbformat/v1/nbjson.py b/nbformat/v1/nbjson.py +index 6af14c6..fd234c3 100644 +--- a/nbformat/v1/nbjson.py ++++ b/nbformat/v1/nbjson.py +@@ -16,7 +16,6 @@ Authors: + # Imports + #----------------------------------------------------------------------------- + +-from base64 import encodestring + from .rwbase import NotebookReader, NotebookWriter + from .nbbase import from_dict + import json +-- +2.37.3 + From 6f5682c708b601fd229c1d5085594ca8636e5370 Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Fri, 21 Oct 2022 11:43:07 -0400 Subject: [PATCH 2/2] actually way more changes than that were needed --- ...eprecated-base64-encode-decodestring.patch | 294 ++++++++++++++++++ ...1-v1-remove-unused-deprecated-import.patch | 24 -- ...oknode-Mapping-is-in-collections.abc.patch | 27 ++ 3 files changed, 321 insertions(+), 24 deletions(-) create mode 100644 package/python-nbformat/0001-all-remove-deprecated-base64-encode-decodestring.patch delete mode 100644 package/python-nbformat/0001-v1-remove-unused-deprecated-import.patch create mode 100644 package/python-nbformat/0002-notebooknode-Mapping-is-in-collections.abc.patch diff --git a/package/python-nbformat/0001-all-remove-deprecated-base64-encode-decodestring.patch b/package/python-nbformat/0001-all-remove-deprecated-base64-encode-decodestring.patch new file mode 100644 index 0000000000..e24f3c109a --- /dev/null +++ b/package/python-nbformat/0001-all-remove-deprecated-base64-encode-decodestring.patch @@ -0,0 +1,294 @@ +From 5f2042ce4c92f12568ab0ee58dddca98e7474b19 Mon Sep 17 00:00:00 2001 +From: Seth Foster +Date: Fri, 21 Oct 2022 11:40:24 -0400 +Subject: [PATCH 1/2] all: remove deprecated base64 encode/decodestring + +These functions were deprecated since 3.1 and removed in 3.9; they are +1:1 replaced with {encode,decode}bytes. +--- + nbformat/sign.py | 2 +- + nbformat/v1/nbjson.py | 1 - + nbformat/v1/rwbase.py | 1 - + nbformat/v2/nbxml.py | 6 +++--- + nbformat/v2/rwbase.py | 10 +++++----- + nbformat/v2/tests/nbexamples.py | 6 +++--- + nbformat/v3/rwbase.py | 10 +++++----- + nbformat/v3/tests/nbexamples.py | 6 +++--- + nbformat/v3/tests/test_json.py | 6 +++--- + nbformat/v4/tests/nbexamples.py | 6 +++--- + nbformat/v4/tests/test_json.py | 6 +++--- + 11 files changed, 29 insertions(+), 31 deletions(-) + +diff --git a/nbformat/sign.py b/nbformat/sign.py +index 0d52251..555605f 100644 +--- a/nbformat/sign.py ++++ b/nbformat/sign.py +@@ -383,7 +383,7 @@ class NotebookNotary(LoggingConfigurable): + with io.open(self.secret_file, 'rb') as f: + return f.read() + else: +- secret = base64.encodestring(os.urandom(1024)) ++ secret = base64.encodebytes(os.urandom(1024)) + self._write_secret_file(secret) + return secret + +diff --git a/nbformat/v1/nbjson.py b/nbformat/v1/nbjson.py +index 6af14c6..fd234c3 100644 +--- a/nbformat/v1/nbjson.py ++++ b/nbformat/v1/nbjson.py +@@ -16,7 +16,6 @@ Authors: + # Imports + #----------------------------------------------------------------------------- + +-from base64 import encodestring + from .rwbase import NotebookReader, NotebookWriter + from .nbbase import from_dict + import json +diff --git a/nbformat/v1/rwbase.py b/nbformat/v1/rwbase.py +index 3938604..62c9d38 100644 +--- a/nbformat/v1/rwbase.py ++++ b/nbformat/v1/rwbase.py +@@ -16,7 +16,6 @@ Authors: + # Imports + #----------------------------------------------------------------------------- + +-from base64 import encodestring, decodestring + + #----------------------------------------------------------------------------- + # Code +diff --git a/nbformat/v2/nbxml.py b/nbformat/v2/nbxml.py +index e851e52..eaf5444 100644 +--- a/nbformat/v2/nbxml.py ++++ b/nbformat/v2/nbxml.py +@@ -16,7 +16,7 @@ Authors: + # Imports + #----------------------------------------------------------------------------- + +-from base64 import encodestring, decodestring ++from base64 import encodebytes, decodebytes + import warnings + from xml.etree import ElementTree as ET + +@@ -97,13 +97,13 @@ def _get_binary(e, tag): + if sub_e is None: + return None + else: +- return decodestring(sub_e.text) ++ return decodebytes(sub_e.text) + + + def _set_binary(nbnode, attr, parent, tag): + if attr in nbnode: + e = ET.SubElement(parent, tag) +- e.text = encodestring(nbnode[attr]) ++ e.text = encodebytes(nbnode[attr]) + + + class XMLReader(NotebookReader): +diff --git a/nbformat/v2/rwbase.py b/nbformat/v2/rwbase.py +index 07b7be3..f5dea6d 100644 +--- a/nbformat/v2/rwbase.py ++++ b/nbformat/v2/rwbase.py +@@ -16,7 +16,7 @@ Authors: + # Imports + #----------------------------------------------------------------------------- + +-from base64 import encodestring, decodestring ++from base64 import encodebytes, decodebytes + import pprint + + from ipython_genutils.py3compat import str_to_bytes, unicode_type, string_types +@@ -112,11 +112,11 @@ def base64_decode(nb): + if 'png' in output: + if isinstance(output.png, unicode_type): + output.png = output.png.encode('ascii') +- output.png = decodestring(output.png) ++ output.png = decodebytes(output.png) + if 'jpeg' in output: + if isinstance(output.jpeg, unicode_type): + output.jpeg = output.jpeg.encode('ascii') +- output.jpeg = decodestring(output.jpeg) ++ output.jpeg = decodebytes(output.jpeg) + return nb + + +@@ -132,9 +132,9 @@ def base64_encode(nb): + if cell.cell_type == 'code': + for output in cell.outputs: + if 'png' in output: +- output.png = encodestring(output.png).decode('ascii') ++ output.png = encodebytes(output.png).decode('ascii') + if 'jpeg' in output: +- output.jpeg = encodestring(output.jpeg).decode('ascii') ++ output.jpeg = encodebytes(output.jpeg).decode('ascii') + return nb + + +diff --git a/nbformat/v2/tests/nbexamples.py b/nbformat/v2/tests/nbexamples.py +index 3e83e8e..ae1c2b0 100644 +--- a/nbformat/v2/tests/nbexamples.py ++++ b/nbformat/v2/tests/nbexamples.py +@@ -1,5 +1,5 @@ + import os +-from base64 import encodestring ++from base64 import encodebytes + + from ..nbbase import ( + NotebookNode, +@@ -8,8 +8,8 @@ from ..nbbase import ( + ) + + # some random base64-encoded *bytes* +-png = encodestring(os.urandom(5)) +-jpeg = encodestring(os.urandom(6)) ++png = encodebytes(os.urandom(5)) ++jpeg = encodebytes(os.urandom(6)) + + ws = new_worksheet(name='worksheet1') + +diff --git a/nbformat/v3/rwbase.py b/nbformat/v3/rwbase.py +index 504f2aa..94a5bea 100644 +--- a/nbformat/v3/rwbase.py ++++ b/nbformat/v3/rwbase.py +@@ -3,7 +3,7 @@ + # Copyright (c) IPython Development Team. + # Distributed under the terms of the Modified BSD License. + +-from base64 import encodestring, decodestring ++from base64 import encodebytes, decodebytes + + from ipython_genutils import py3compat + from ipython_genutils.py3compat import str_to_bytes, unicode_type, string_types +@@ -114,11 +114,11 @@ def base64_decode(nb): + if 'png' in output: + if isinstance(output.png, unicode_type): + output.png = output.png.encode('ascii') +- output.png = decodestring(output.png) ++ output.png = decodebytes(output.png) + if 'jpeg' in output: + if isinstance(output.jpeg, unicode_type): + output.jpeg = output.jpeg.encode('ascii') +- output.jpeg = decodestring(output.jpeg) ++ output.jpeg = decodebytes(output.jpeg) + return nb + + +@@ -134,9 +134,9 @@ def base64_encode(nb): + if cell.cell_type == 'code': + for output in cell.outputs: + if 'png' in output: +- output.png = encodestring(output.png).decode('ascii') ++ output.png = encodebytes(output.png).decode('ascii') + if 'jpeg' in output: +- output.jpeg = encodestring(output.jpeg).decode('ascii') ++ output.jpeg = encodebytes(output.jpeg).decode('ascii') + return nb + + +diff --git a/nbformat/v3/tests/nbexamples.py b/nbformat/v3/tests/nbexamples.py +index 898a032..56f932f 100644 +--- a/nbformat/v3/tests/nbexamples.py ++++ b/nbformat/v3/tests/nbexamples.py +@@ -1,7 +1,7 @@ + # -*- coding: utf-8 -*- + + import os +-from base64 import encodestring ++from base64 import encodebytes + + from ..nbbase import ( + NotebookNode, +@@ -10,8 +10,8 @@ from ..nbbase import ( + ) + + # some random base64-encoded *text* +-png = encodestring(os.urandom(5)).decode('ascii') +-jpeg = encodestring(os.urandom(6)).decode('ascii') ++png = encodebytes(os.urandom(5)).decode('ascii') ++jpeg = encodebytes(os.urandom(6)).decode('ascii') + + ws = new_worksheet() + +diff --git a/nbformat/v3/tests/test_json.py b/nbformat/v3/tests/test_json.py +index de95ea0..a8e6e9f 100644 +--- a/nbformat/v3/tests/test_json.py ++++ b/nbformat/v3/tests/test_json.py +@@ -1,6 +1,6 @@ + import copy + import json +-from base64 import decodestring ++from base64 import decodebytes + from unittest import TestCase + + from ipython_genutils.py3compat import unicode_type +@@ -77,7 +77,7 @@ class TestJSON(formattest.NBFormatTest, TestCase): + self.assertEqual(type(pngdata), unicode_type) + # test that it is valid b64 data + b64bytes = pngdata.encode('ascii') +- raw_bytes = decodestring(b64bytes) ++ raw_bytes = decodebytes(b64bytes) + assert found_png, "never found png output" + + def test_read_jpeg(self): +@@ -95,7 +95,7 @@ class TestJSON(formattest.NBFormatTest, TestCase): + self.assertEqual(type(jpegdata), unicode_type) + # test that it is valid b64 data + b64bytes = jpegdata.encode('ascii') +- raw_bytes = decodestring(b64bytes) ++ raw_bytes = decodebytes(b64bytes) + assert found_jpeg, "never found jpeg output" + + +diff --git a/nbformat/v4/tests/nbexamples.py b/nbformat/v4/tests/nbexamples.py +index e180095..8209135 100644 +--- a/nbformat/v4/tests/nbexamples.py ++++ b/nbformat/v4/tests/nbexamples.py +@@ -1,7 +1,7 @@ + # -*- coding: utf-8 -*- + + import os +-from base64 import encodestring ++from base64 import encodebytes + + from ..nbbase import ( + new_code_cell, new_markdown_cell, new_notebook, +@@ -9,8 +9,8 @@ from ..nbbase import ( + ) + + # some random base64-encoded *text* +-png = encodestring(os.urandom(5)).decode('ascii') +-jpeg = encodestring(os.urandom(6)).decode('ascii') ++png = encodebytes(os.urandom(5)).decode('ascii') ++jpeg = encodebytes(os.urandom(6)).decode('ascii') + + cells = [] + cells.append(new_markdown_cell( +diff --git a/nbformat/v4/tests/test_json.py b/nbformat/v4/tests/test_json.py +index b8090b4..5711c9c 100644 +--- a/nbformat/v4/tests/test_json.py ++++ b/nbformat/v4/tests/test_json.py +@@ -1,4 +1,4 @@ +-from base64 import decodestring ++from base64 import decodebytes + import json + from unittest import TestCase + +@@ -76,7 +76,7 @@ class TestJSON(formattest.NBFormatTest, TestCase): + self.assertEqual(type(pngdata), unicode_type) + # test that it is valid b64 data + b64bytes = pngdata.encode('ascii') +- raw_bytes = decodestring(b64bytes) ++ raw_bytes = decodebytes(b64bytes) + assert found_png, "never found png output" + + def test_read_jpeg(self): +@@ -96,5 +96,5 @@ class TestJSON(formattest.NBFormatTest, TestCase): + self.assertEqual(type(jpegdata), unicode_type) + # test that it is valid b64 data + b64bytes = jpegdata.encode('ascii') +- raw_bytes = decodestring(b64bytes) ++ raw_bytes = decodebytes(b64bytes) + assert found_jpeg, "never found jpeg output" +-- +2.37.3 + diff --git a/package/python-nbformat/0001-v1-remove-unused-deprecated-import.patch b/package/python-nbformat/0001-v1-remove-unused-deprecated-import.patch deleted file mode 100644 index 33f1fab649..0000000000 --- a/package/python-nbformat/0001-v1-remove-unused-deprecated-import.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0b66e0d6be6d62e4828108fd7993106c279fab75 Mon Sep 17 00:00:00 2001 -From: Seth Foster -Date: Thu, 20 Oct 2022 15:52:47 -0400 -Subject: [PATCH] v1: remove unused deprecated import - ---- - nbformat/v1/nbjson.py | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/nbformat/v1/nbjson.py b/nbformat/v1/nbjson.py -index 6af14c6..fd234c3 100644 ---- a/nbformat/v1/nbjson.py -+++ b/nbformat/v1/nbjson.py -@@ -16,7 +16,6 @@ Authors: - # Imports - #----------------------------------------------------------------------------- - --from base64 import encodestring - from .rwbase import NotebookReader, NotebookWriter - from .nbbase import from_dict - import json --- -2.37.3 - diff --git a/package/python-nbformat/0002-notebooknode-Mapping-is-in-collections.abc.patch b/package/python-nbformat/0002-notebooknode-Mapping-is-in-collections.abc.patch new file mode 100644 index 0000000000..baf12a9e78 --- /dev/null +++ b/package/python-nbformat/0002-notebooknode-Mapping-is-in-collections.abc.patch @@ -0,0 +1,27 @@ +From 2621c0d3589749a8dbb31f93cae0504ba5c5af07 Mon Sep 17 00:00:00 2001 +From: Seth Foster +Date: Fri, 21 Oct 2022 11:41:05 -0400 +Subject: [PATCH 2/2] notebooknode: Mapping is in collections.abc + +Since 3.10, the collection abstract base classes were moved to +collections.abc instead of just collections. +--- + nbformat/notebooknode.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/nbformat/notebooknode.py b/nbformat/notebooknode.py +index 5e1fded..b8b59fa 100644 +--- a/nbformat/notebooknode.py ++++ b/nbformat/notebooknode.py +@@ -1,7 +1,7 @@ + """NotebookNode - adding attribute access to dicts""" + + from ipython_genutils.ipstruct import Struct +-from collections import Mapping ++from collections.abc import Mapping + + + class NotebookNode(Struct): +-- +2.37.3 +