From f955f2ce5e400bcccfc506c0bc7e6662567dd4f1 Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Mon, 1 Sep 2025 01:38:28 +0900 Subject: [PATCH] anki: move python libraries into 'lib' output Fixes #438598 Anki's packaging got reworked in https://github.com/NixOS/nixpkgs/pull/425219, and one of the changes was to effectively 'pip install' the anki wheel into $out directly. This resulted in an output structure of '$out/bin' and '$out/lib', with python files in 'lib'. Per #438598, this can cause conflicts. Let's split anki into `anki.out` and `anki.lib`, requiring a user to specifically include `anki.lib` in their environment in order to hit the python conflicts described there. This seems like the easiest solution, though I'm of course open to any better alternatives. --- pkgs/games/anki/default.nix | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkgs/games/anki/default.nix b/pkgs/games/anki/default.nix index 1f0ac2e22982..0038bffbf2e6 100644 --- a/pkgs/games/anki/default.nix +++ b/pkgs/games/anki/default.nix @@ -111,6 +111,7 @@ python3Packages.buildPythonApplication rec { "out" "doc" "man" + "lib" ]; inherit src; @@ -226,7 +227,7 @@ python3Packages.buildPythonApplication rec { # And finally build patchShebangs ./ninja - export PYTHONPATH=$PYTHONPATH:$PWD/out/pyenv/lib/python${python3.pythonVersion}/site-packages + export PYTHONPATH=$PYTHONPATH:$PWD/out/pyenv/${python3.sitePackages} # Necessary for yarn to not complain about 'corepack' jq 'del(.packageManager)' package.json > package.json.tmp && mv package.json.tmp package.json YARN_BINARY="${lib.getExe noInstallYarn}" PIP_USER=1 \ @@ -251,7 +252,7 @@ python3Packages.buildPythonApplication rec { in '' runHook preCheck - export PYTHONPATH=$PYTHONPATH:$PWD/out/pyenv/lib/python${python3.pythonVersion}/site-packages + export PYTHONPATH=$PYTHONPATH:$PWD/out/pyenv/${python3.sitePackages} HOME=$TMP ANKI_TEST_MODE=1 PYTHONPATH=$PYTHONPATH:$PWD/out/pylib \ pytest -p no:cacheprovider pylib/tests -k ${disabledTestsString} HOME=$TMP ANKI_TEST_MODE=1 PYTHONPATH=$PYTHONPATH:$PWD/out/pylib:$PWD/pylib:$PWD/out/qt \ @@ -262,10 +263,13 @@ python3Packages.buildPythonApplication rec { installPhase = '' runHook preInstall - mkdir -p $out - uv pip install out/wheels/*.whl --prefix $out + mkdir -p $lib $out + uv pip install out/wheels/*.whl --prefix $lib # remove non-anki bins from dependencies - find $out/bin -type f ! -name "anki*" -delete + find $lib/bin -type f ! -name "anki*" -delete + # and put bin into $out so people can access it. Leave $lib separate to avoid collisions, see + # https://github.com/NixOS/nixpkgs/issues/438598 + mv $lib/bin $out/bin install -D -t $out/share/applications qt/launcher/lin/anki.desktop install -D -t $doc/share/doc/anki README* LICENSE* @@ -280,6 +284,7 @@ python3Packages.buildPythonApplication rec { makeWrapperArgs+=( "''${qtWrapperArgs[@]}" --prefix PATH ':' "${lame}/bin:${mpv-unwrapped}/bin" + --prefix PYTHONPATH ':' "$lib/${python3.sitePackages}" ) '';