blob: eefb41d73d7c906720890f3f3b02afffc46fbb49 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
From 7e5752de7d49f222cec5107aa5044fa8f8ffbb39 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Wed, 22 Apr 2020 20:38:28 +0200
Subject: [PATCH] Use importlib.metadata from the standard library on Python
3.8+
Fixes https://github.com/jsonpickle/jsonpickle/issues/303
---
jsonpickle/version.py | 7 ++++++-
setup.cfg | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/jsonpickle/version.py b/jsonpickle/version.py
index 01c83c4..92b44b2 100644
--- a/jsonpickle/version.py
+++ b/jsonpickle/version.py
@@ -1,5 +1,10 @@
+import sys
+
try:
- import importlib_metadata as metadata
+ if sys.version_info < (3, 8):
+ import importlib_metadata as metadata
+ else:
+ from importlib import metadata
except (ImportError, OSError):
metadata = None
diff --git a/setup.cfg b/setup.cfg
index 9f0eab2..46707ec 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -36,7 +36,7 @@ packages = find:
include_package_data = true
python_requires = >=2.7
install_requires =
- importlib_metadata
+ importlib_metadata; python_version<"3.8"
setup_requires = setuptools_scm[toml] >= 3.4.1
[options.extras_require]
--
2.28.0
|