From 23b7dc80662fdf2ca5471beb2eac412c3176b1e7 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 30 Oct 2024 19:23:01 +0100 Subject: [PATCH 01/10] picard: set localedir without relying on bash eval To be able to remove the bash-eval behavior for setupPyGlobalFlags, we change $out to use placeholder "out" instead. Confirmed that the locales are still loaded from the correct path as demonstrated in #284050. --- pkgs/by-name/pi/picard/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/pi/picard/package.nix b/pkgs/by-name/pi/picard/package.nix index e43e39e5a47d..e39f26d4a84e 100644 --- a/pkgs/by-name/pi/picard/package.nix +++ b/pkgs/by-name/pi/picard/package.nix @@ -62,7 +62,7 @@ pythonPackages.buildPythonApplication rec { pyyaml ]; - setupPyGlobalFlags = [ "build" "--disable-autoupdate" "--localedir=$out/share/locale" ]; + setupPyGlobalFlags = [ "build" "--disable-autoupdate" "--localedir=${placeholder "out"}/share/locale" ]; preCheck = '' export HOME=$(mktemp -d) From 95a3185bf895269a37fc630797f60788c8d81c4c Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 30 Oct 2024 21:14:56 +0100 Subject: [PATCH 02/10] fichub-cli: disable only test the easy way There is only one test and this was disabled via some nasty bash eval hacks in pytestFlagsArray. Let's just use... doCheck = false instead? --- pkgs/by-name/fi/fichub-cli/package.nix | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/pkgs/by-name/fi/fichub-cli/package.nix b/pkgs/by-name/fi/fichub-cli/package.nix index 3d62d7b2a304..f694a9b99307 100644 --- a/pkgs/by-name/fi/fichub-cli/package.nix +++ b/pkgs/by-name/fi/fichub-cli/package.nix @@ -35,21 +35,8 @@ python3Packages.buildPythonApplication rec { pytestCheckHook ]; - # The package tries to create a file under the home directory on import - preCheck = '' - export HOME=$(mktemp -d) - ''; - - pytestFlagsArray = [ - # pytest exits with a code of 5 if no tests are selected. - # handle this specific case as not an error - "|| ([ $? = 5 ] || exit $?)" - ]; - - disabledTestPaths = [ - # Loading tests tries to download something from pypi.org - "tests/test_cli.py" - ]; + # Loading tests tries to download something from pypi.org + doCheck = false; meta = { description = "CLI for the fichub.net API"; From f363956c3c64f7e8450b99835d9d677ff655f41b Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 30 Oct 2024 21:56:25 +0100 Subject: [PATCH 03/10] python3Packages.macaddress: remove useless $src from pytestFlagsArray We'd like to avoid bash eval in pytestFlagsArray, because we want to get rid of support for it. This case works just fine without. --- pkgs/development/python-modules/macaddress/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/macaddress/default.nix b/pkgs/development/python-modules/macaddress/default.nix index 97d07f45d1c8..137561253049 100644 --- a/pkgs/development/python-modules/macaddress/default.nix +++ b/pkgs/development/python-modules/macaddress/default.nix @@ -27,7 +27,7 @@ buildPythonPackage rec { reprshed ]; - pytestFlagsArray = [ "$src/test.py" ]; + pytestFlagsArray = [ "test.py" ]; meta = with lib; { homepage = "https://github.com/mentalisttraceur/python-macaddress"; From 676b249c5563964a5a5a8a247214b2f31d26523f Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 30 Oct 2024 22:19:09 +0100 Subject: [PATCH 04/10] python3Packages.iso4217: avoid mis-using $pname It makes no sense to depend those folders on pname - they are part of the source code, not our convention, after all. Also this avoids using bash eval behavior in pytestFlagsArray. --- pkgs/development/python-modules/iso4217/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/iso4217/default.nix b/pkgs/development/python-modules/iso4217/default.nix index 56945d3ed07a..b9dd6d2f9f7b 100644 --- a/pkgs/development/python-modules/iso4217/default.nix +++ b/pkgs/development/python-modules/iso4217/default.nix @@ -40,15 +40,15 @@ buildPythonPackage rec { # The table is already downloaded export ISO4217_DOWNLOAD=0 # Copy the table file to satifiy the build process - cp -r ${table} $pname/table.xml + cp -r ${table} iso4217/table.xml ''; postInstall = '' # Copy the table file - cp -r ${table} $out/${python.sitePackages}/$pname/table.xml + cp -r ${table} $out/${python.sitePackages}/iso4217/table.xml ''; - pytestFlagsArray = [ "$pname/test.py" ]; + pytestFlagsArray = [ "iso4217/test.py" ]; pythonImportsCheck = [ "iso4217" ]; From 5eeb03141c423999ad500fedc25cbf579765627e Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Thu, 31 Oct 2024 17:06:01 +0100 Subject: [PATCH 05/10] python3Packages.certbot-dns-inwx: fix broken pytestImportsCheck This surely was intended to be an imports check, judging by the content of the list. Setting pytestCheckHook like that surely makes no sense. --- pkgs/development/python-modules/certbot-dns-inwx/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/certbot-dns-inwx/default.nix b/pkgs/development/python-modules/certbot-dns-inwx/default.nix index 08c83c264bca..81b20f23ff79 100644 --- a/pkgs/development/python-modules/certbot-dns-inwx/default.nix +++ b/pkgs/development/python-modules/certbot-dns-inwx/default.nix @@ -24,7 +24,7 @@ buildPythonPackage rec { # Doesn't have any tests doCheck = false; - pytestCheckHook = [ "certbot_dns_inwx" ]; + pytestImportsCheck = [ "certbot_dns_inwx" ]; meta = with lib; { description = "INWX DNS Authenticator plugin for Certbot"; From cfd186f0978147e6c71c50e907c794d103ed0370 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Thu, 31 Oct 2024 17:05:07 +0100 Subject: [PATCH 06/10] python3Packages: remove left-over "--numprocesses" Those are provided by pytest-xdist's setup hook automatically anyway. --- pkgs/by-name/co/conan/package.nix | 5 ----- pkgs/by-name/ro/routersploit/package.nix | 2 -- pkgs/development/python-modules/qcodes/default.nix | 2 -- 3 files changed, 9 deletions(-) diff --git a/pkgs/by-name/co/conan/package.nix b/pkgs/by-name/co/conan/package.nix index 386e59d985b0..67fb019af535 100644 --- a/pkgs/by-name/co/conan/package.nix +++ b/pkgs/by-name/co/conan/package.nix @@ -65,11 +65,6 @@ python3.pkgs.buildPythonApplication rec { "conan" ]; - pytestFlagsArray = [ - "-n" - "$NIX_BUILD_CORES" - ]; - disabledTests = [ # Tests require network access "TestFTP" diff --git a/pkgs/by-name/ro/routersploit/package.nix b/pkgs/by-name/ro/routersploit/package.nix index 3f656e8e4578..14de115541af 100644 --- a/pkgs/by-name/ro/routersploit/package.nix +++ b/pkgs/by-name/ro/routersploit/package.nix @@ -39,8 +39,6 @@ python3.pkgs.buildPythonApplication rec { ]; pytestFlagsArray = [ - "-n" - "$NIX_BUILD_CORES" # Run the same tests as upstream does in the first round "tests/core/" "tests/test_exploit_scenarios.py" diff --git a/pkgs/development/python-modules/qcodes/default.nix b/pkgs/development/python-modules/qcodes/default.nix index 01ae8380228c..a1c5206f4af2 100644 --- a/pkgs/development/python-modules/qcodes/default.nix +++ b/pkgs/development/python-modules/qcodes/default.nix @@ -148,8 +148,6 @@ buildPythonPackage rec { pytestFlagsArray = [ "-v" - "-n" - "$NIX_BUILD_CORES" # Follow upstream with settings "-m 'not serial'" "--hypothesis-profile ci" From c23f21beadaccc1f76b8810b381abfe2a99c23f1 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 30 Oct 2024 22:01:04 +0100 Subject: [PATCH 07/10] python3Packages.dtw-python: set pytestFlagsArray in preCheck hook This flag relies on bash eval of pytestFlagsArray, which we'd like to get rid of. By moving the evaluation of $src into the preCheck hook, we achieve the same. --- pkgs/development/python-modules/dtw-python/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/dtw-python/default.nix b/pkgs/development/python-modules/dtw-python/default.nix index 7021d576bab4..627d16b0e062 100644 --- a/pkgs/development/python-modules/dtw-python/default.nix +++ b/pkgs/development/python-modules/dtw-python/default.nix @@ -39,10 +39,12 @@ buildPythonPackage rec { ]; # We need to run tests on real built package: https://github.com/NixOS/nixpkgs/issues/255262 - preCheck = "cd $out"; - nativeCheckInputs = [ pytestCheckHook ]; # tests/ are not included to output package, so we have to set path explicitly - pytestFlagsArray = [ "$src/tests" ]; + preCheck = '' + appendToVar pytestFlagsArray "$src/tests" + cd $out + ''; + nativeCheckInputs = [ pytestCheckHook ]; pythonImportsCheck = [ "dtw" ]; From 0032be6d426e8646f5986b4ffb6a1878648339a0 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 1 Nov 2024 19:13:55 +0100 Subject: [PATCH 08/10] python3Packages.bottleneck: avoid bash eval in pytestFlagsArray We can just cd to $out to let the tests run from that folder automatically. Additionally we get better test output, because the /nix/store component is missing from file names. --- pkgs/development/python-modules/bottleneck/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/bottleneck/default.nix b/pkgs/development/python-modules/bottleneck/default.nix index 18aa852cd73b..f89ea81255e4 100644 --- a/pkgs/development/python-modules/bottleneck/default.nix +++ b/pkgs/development/python-modules/bottleneck/default.nix @@ -24,7 +24,8 @@ buildPythonPackage rec { nativeCheckInputs = [ pytestCheckHook ]; - pytestFlagsArray = [ "$out/${python.sitePackages}" ]; + preCheck = "pushd $out"; + postCheck = "popd"; disabledTests = [ "test_make_c_files" ]; From 5ea3790cbe8254f2a432d48a0ff1dcda1e466560 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 1 Nov 2024 21:16:58 +0100 Subject: [PATCH 09/10] python3Packages.vapoursynth: remove useless $src from unittestFlagsArray Avoids the use of bash eval in unittestFlagsArray, which we want to remove. --- pkgs/development/python-modules/vapoursynth/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/vapoursynth/default.nix b/pkgs/development/python-modules/vapoursynth/default.nix index 1fb1d4be03ef..8e50bba69a4d 100644 --- a/pkgs/development/python-modules/vapoursynth/default.nix +++ b/pkgs/development/python-modules/vapoursynth/default.nix @@ -20,7 +20,7 @@ buildPythonPackage { unittestFlagsArray = [ "-s" - "$src/test" + "test" "-p" "'*test.py'" ]; From f9969cbf471f07dde16fd22adcd98ee3b0a499a2 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Tue, 12 Nov 2024 21:09:07 +0100 Subject: [PATCH 10/10] python3Packages.conan: disable unstable test This test failed repeatedly on aarch64-linux, so far. --- pkgs/by-name/co/conan/package.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/by-name/co/conan/package.nix b/pkgs/by-name/co/conan/package.nix index 67fb019af535..ebd96f12693c 100644 --- a/pkgs/by-name/co/conan/package.nix +++ b/pkgs/by-name/co/conan/package.nix @@ -68,6 +68,8 @@ python3.pkgs.buildPythonApplication rec { disabledTests = [ # Tests require network access "TestFTP" + # Unstable test + "test_shared_windows_find_libraries" ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ # Rejects paths containing nix "test_conditional_os"