cudaPackages.writeGpuTestPython: allow a selector for libraries to accommodate different python versions
This commit is contained in:
@@ -2,16 +2,40 @@
|
||||
lib,
|
||||
writers,
|
||||
runCommand,
|
||||
python3Packages,
|
||||
}:
|
||||
{
|
||||
feature ? "cuda",
|
||||
name ? feature,
|
||||
libraries ? [ ],
|
||||
libraries ? [ ], # [PythonPackage] | (PackageSet -> [PythonPackage])
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (builtins) isFunction all;
|
||||
librariesFun = if isFunction libraries then libraries else (_: libraries);
|
||||
in
|
||||
|
||||
assert lib.assertMsg (
|
||||
isFunction libraries || all (python3Packages.hasPythonModule) libraries
|
||||
) "writeGpuTestPython was passed `libraries` from the wrong python release";
|
||||
|
||||
content:
|
||||
|
||||
let
|
||||
tester = writers.writePython3Bin "tester-${name}" { inherit libraries; } content;
|
||||
interpreter = python3Packages.python.withPackages librariesFun;
|
||||
tester =
|
||||
runCommand "tester-${name}"
|
||||
{
|
||||
inherit content;
|
||||
passAsFile = [ "content" ];
|
||||
}
|
||||
''
|
||||
mkdir -p "$out"/bin
|
||||
cat << EOF >"$out"/bin/"tester-${name}"
|
||||
#!${lib.getExe interpreter}
|
||||
EOF
|
||||
cat "$contentPath" >>"$out"/bin/"tester-${name}"
|
||||
'';
|
||||
tester' = tester.overrideAttrs (oldAttrs: {
|
||||
passthru.gpuCheck =
|
||||
runCommand "test-${name}"
|
||||
|
||||
Reference in New Issue
Block a user