From ef31a2ba5fca12f70178fcbe737263f01fdc02ce Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Tue, 24 Jun 2025 17:57:31 +0200 Subject: [PATCH 1/3] python3Packages.mmengine: remove failing numpy.compat import --- pkgs/development/python-modules/mmengine/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/development/python-modules/mmengine/default.nix b/pkgs/development/python-modules/mmengine/default.nix index ecedb608e878..3de90cbfd427 100644 --- a/pkgs/development/python-modules/mmengine/default.nix +++ b/pkgs/development/python-modules/mmengine/default.nix @@ -52,6 +52,11 @@ buildPythonPackage rec { }) ]; + postPatch = '' + substituteInPlace tests/test_config/test_lazy.py \ + --replace-fail "import numpy.compat" "" + ''; + build-system = [ setuptools ]; dependencies = [ From f005289e1232e42a8833fba962de9b2e6d21dfdd Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Tue, 24 Jun 2025 18:45:50 +0200 Subject: [PATCH 2/3] python3Packages.mmengine: fix on python 3.13 --- .../python-modules/mmengine/default.nix | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/mmengine/default.nix b/pkgs/development/python-modules/mmengine/default.nix index 3de90cbfd427..816b042cf7bf 100644 --- a/pkgs/development/python-modules/mmengine/default.nix +++ b/pkgs/development/python-modules/mmengine/default.nix @@ -52,10 +52,22 @@ buildPythonPackage rec { }) ]; - postPatch = '' - substituteInPlace tests/test_config/test_lazy.py \ - --replace-fail "import numpy.compat" "" - ''; + postPatch = + # Fails in python >= 3.13 + # exec(compile(f.read(), version_file, "exec")) does not populate the locals() namesp + # In python 3.13, the locals() dictionary in a function does not automatically update with + # changes made by exec(). + # https://peps.python.org/pep-0558/ + '' + substituteInPlace setup.py \ + --replace-fail \ + "return locals()['__version__']" \ + "return '${version}'" + '' + + '' + substituteInPlace tests/test_config/test_lazy.py \ + --replace-fail "import numpy.compat" "" + ''; build-system = [ setuptools ]; From d5a9a624062d065e0328c13cae42fa05bc2b2d1e Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Tue, 24 Jun 2025 18:59:33 +0200 Subject: [PATCH 3/3] python3Packages.mmcv: fix on python 3.13 --- pkgs/development/python-modules/mmcv/default.nix | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/mmcv/default.nix b/pkgs/development/python-modules/mmcv/default.nix index 3f7b5f9f4ce9..cc9efa952bf3 100644 --- a/pkgs/development/python-modules/mmcv/default.nix +++ b/pkgs/development/python-modules/mmcv/default.nix @@ -48,10 +48,17 @@ buildPythonPackage rec { hash = "sha256-NNF9sLJWV1q6uBE73LUW4UWwYm4TBMTBJjJkFArBmsc="; }; - postPatch = '' - substituteInPlace setup.py \ - --replace-fail "cpu_use = 4" "cpu_use = $NIX_BUILD_CORES" - ''; + postPatch = + # Fails in python >= 3.13 + # exec(compile(f.read(), version_file, "exec")) does not populate the locals() namesp + # In python 3.13, the locals() dictionary in a function does not automatically update with + # changes made by exec(). + # https://peps.python.org/pep-0558/ + '' + substituteInPlace setup.py \ + --replace-fail "cpu_use = 4" "cpu_use = $NIX_BUILD_CORES" \ + --replace-fail "return locals()['__version__']" "return '${version}'" + ''; nativeBuildInputs = [ ninja