diff --git a/.git_archival.txt b/.git_archival.txt
new file mode 100644
index 00000000..3994ec0a
--- /dev/null
+++ b/.git_archival.txt
@@ -0,0 +1,4 @@
+node: $Format:%H$
+node-date: $Format:%cI$
+describe-name: $Format:%(describe:tags=true)$
+ref-names: $Format:%D$
diff --git a/.gitattributes b/.gitattributes
index 00e5815f..84cc7a59 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,1 +1,7 @@
+# Needed for setuptools-scm-git-archive
+.git_archival.txt  export-subst
+
+# Blame ignore list entries are expected to always be appended, never edited
+.git-blame-ignore-revs  merge=union
+
 /CHANGES.rst merge=union
diff --git a/docs/conf.py b/docs/conf.py
index 4a0ceb54..ebd25867 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -203,7 +203,7 @@ link_files = {
         ),
         replace=[
             dict(
-                pattern=r'^(?m)((?P<scm_version>v?\d+(\.\d+){1,2}))\n[-=]+\n',
+                pattern=r'(?m)^((?P<scm_version>v?\d+(\.\d+){1,2}))\n[-=]+\n',
                 with_scm='{text}\n{rev[timestamp]:%d %b %Y}\n',
             ),
         ],
diff --git a/pyproject.toml b/pyproject.toml
index a29ffa3b..2c3a7cff 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,8 +4,7 @@ requires = [
     "setuptools >= 45",
 
     # Plugins
-    "setuptools_scm[toml] >= 3.5",
-    "setuptools_scm_git_archive >= 1.1",
+    "setuptools_scm[toml] >= 7.0.0",
 ]
 build-backend = "setuptools.build_meta"
 

diff --git a/cherrypy/test/test_session.py b/cherrypy/test/test_session.py
index 80567504..f566c37f 100755
--- a/cherrypy/test/test_session.py
+++ b/cherrypy/test/test_session.py
@@ -146,9 +146,14 @@ class SessionTest(helper.CPWebCase):
     def teardown_class(cls):
         """Clean up sessions."""
         super(cls, cls).teardown_class()
+        try:
+            files_to_clean = localDir.iterdir()  # Python 3.8+
+        except AttributeError:
+            files_to_clean = localDir.listdir()  # Python 3.6-3.7
+
         consume(
             file.remove_p()
-            for file in localDir.iterdir()
+            for file in files_to_clean
             if file.basename().startswith(
                 sessions.FileSession.SESSION_PREFIX
             )

`setuptools_scm_git_archive` is obsolete
The `setuptools_scm_git_archive` package is obsolete.  Please switch to `setuptools_scm >= 7.0.0`.
cherrypy/test/test_session.py::SessionTest::test_0_Session
cherrypy/test/test_session.py::SessionTest::test_1_Ram_Concurrency cherrypy/test/test_session.py::SessionTest::test_2_File_Concurrency cherrypy/test/test_session.py::SessionTest::test_3_Redirect cherrypy/test/test_session.py::SessionTest::test_4_File_deletion cherrypy/test/test_session.py::SessionTest::test_5_Error_paths cherrypy/test/test_session.py::SessionTest::test_6_regenerate cherrypy/test/test_session.py::SessionTest::test_7_session_cookies cherrypy/test/test_session.py::SessionTest::test_8_Ram_Cleanup cherrypy/test/test_session.py::SessionTest::test_gc