From 6e206006105c91cb88249e6f6d840a1d8b3ab922 Mon Sep 17 00:00:00 2001
From: Federico Bond <federicobond@gmail.com>
Date: Mon, 18 Mar 2024 15:56:58 +1100
Subject: [PATCH 1/2] Add support for Python 3.11 and 3.12

---
 .github/workflows/python-app.yml | 2 +-
 CHANGES.rst                      | 2 +-
 setup.cfg                        | 2 ++
 tox.ini                          | 6 ++++--
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/tox.ini b/tox.ini
index 9967a1f5..dbff736b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -3,7 +3,7 @@ distribute = False
 envlist =
     coverage_setup
     nopil
-    py{36,37,38,39,310}
+    py{36,37,38,39,310,311,312}
     readme
     coverage_report
 skip_missing_interpreters = True
@@ -14,6 +14,8 @@ python =
     3.8: py38
     3.9: py39, readme, nopil
     3.10: py310
+    3.11: py311
+    3.12: py312
 
 [testenv]
 depends = coverage_setup
@@ -44,7 +46,7 @@ commands = coverage erase
 
 [testenv:coverage_report]
 depends =
-    py{36,37,38,39,310}
+    py{36,37,38,39,310,311,312}
     nopil
 skip_install = True
 deps = coverage

From ec00fc4041f846025b01163e4cd41f3292a79fec Mon Sep 17 00:00:00 2001
From: Federico Bond <federicobond@gmail.com>
Date: Mon, 18 Mar 2024 16:04:18 +1100
Subject: [PATCH 2/2] Fix missing pkg_resources in Python 3.12

---
 qrcode/console_scripts.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/qrcode/console_scripts.py b/qrcode/console_scripts.py
index 424fe6fd..3752642a 100755
--- a/qrcode/console_scripts.py
+++ b/qrcode/console_scripts.py
@@ -37,12 +37,20 @@
 }
 
 
+def get_version() -> str:
+    try:
+        from importlib.metadata import version
+        return version("qrcode")
+    except Exception:
+        from pkg_resources import get_distribution
+        return get_distribution("qrcode").version
+
+
 def main(args=None):
     if args is None:
         args = sys.argv[1:]
-    from pkg_resources import get_distribution
 
-    version = get_distribution("qrcode").version
+    version = get_version()
     parser = optparse.OptionParser(usage=(__doc__ or "").strip(), version=version)
 
     # Wrap parser.error in a typed NoReturn method for better typing.
