diff --git a/pkgs/development/python-modules/setuptools-scm/default.nix b/pkgs/development/python-modules/setuptools-scm/default.nix
index 87f8c3d13ae4..6713e5e84f4b 100644
--- a/pkgs/development/python-modules/setuptools-scm/default.nix
+++ b/pkgs/development/python-modules/setuptools-scm/default.nix
@@ -1,29 +1,36 @@
-{ lib, buildPythonPackage, fetchPypi, toml, tomli }:
+{ buildPythonPackage
+, callPackage
+, fetchPypi
+, packaging
+, tomli
+, lib
+}:
 
 buildPythonPackage rec {
   pname = "setuptools-scm";
-  # don't update to 6.1.0 or 6.2.0, releases were pulled because of regression
-  # https://github.com/pypa/setuptools_scm/issues/615
-  version = "6.0.1";
+  version = "6.3.1";
 
   src = fetchPypi {
     pname = "setuptools_scm";
     inherit version;
-    sha256 = "sha256-0ZJaacsH6bKUFqJ1ufrbAJojwUis6QWy+yIGSabBjpI=";
+    sha256 = "sha256-D2omORKxN5jAKLmicdka873g5CeECRx5fezMOtOn9ZY=";
   };
 
-  postPatch = ''
-    substituteInPlace setup.cfg \
-      --replace "tomli~=1.0.0" "tomli>=1.0.0"
-  '';
+  propagatedBuildInputs = [
+    packaging
+    tomli
+  ];
 
-  # TODO: figure out why both toml and tomli are needed when only tomli is listed in setuptools-scm
-  # if not both are listed some packages like zipp silently fallback to a 0.0.0 version number and break version pins in other packages
-  propagatedBuildInputs = [ toml tomli ];
+  pythonImportsCheck = [
+    "setuptools_scm"
+  ];
 
-  # Requires pytest, circular dependency
+  # check in passhtru.tests.pytest to escape infinite recursion on pytest
   doCheck = false;
-  pythonImportsCheck = [ "setuptools_scm" ];
+
+  passthru.tests = {
+    pytest = callPackage ./tests.nix { };
+  };
 
   meta = with lib; {
     homepage = "https://github.com/pypa/setuptools_scm/";
diff --git a/pkgs/development/python-modules/setuptools-scm/tests.nix b/pkgs/development/python-modules/setuptools-scm/tests.nix
new file mode 100644
index 000000000000..174b54aca9cd
--- /dev/null
+++ b/pkgs/development/python-modules/setuptools-scm/tests.nix
@@ -0,0 +1,33 @@
+{ lib
+, buildPythonPackage
+, setuptools-scm
+, pytestCheckHook
+, git
+, mercurial
+, pip
+, virtualenv
+}:
+
+buildPythonPackage rec {
+  pname = "setuptools-scm-tests";
+  inherit (setuptools-scm) version;
+
+  src = setuptools-scm.src;
+
+  dontBuild = true;
+  dontInstall = true;
+
+  checkInputs = [
+    pytestCheckHook
+    setuptools-scm
+    pip
+    virtualenv
+    git
+    mercurial
+  ];
+
+  disabledTests = [
+    # network access
+    "test_pip_download"
+  ];
+}