wrapPythonPrograms: support structuredAttrs, modify gi-docgen and freecell-solver to verify (#471986)

This commit is contained in:
Philip Taron
2026-01-31 15:52:13 +00:00
committed by GitHub
3 changed files with 33 additions and 7 deletions

View File

@@ -11,15 +11,16 @@
pkg-config,
python3,
rinutils,
versionCheckHook,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "freecell-solver";
version = "6.14.0";
version = "6.16.0";
src = fetchurl {
url = "https://fc-solve.shlomifish.org/downloads/fc-solve/freecell-solver-${finalAttrs.version}.tar.xz";
hash = "sha256-HREl2FQivNUhEC18sefIS3aGP+RF3SGHn5d53Gss59w=";
hash = "sha256-cbiILmjxvmJSkGkBjQxzK3UHhmkHfJY0gnlXWEnzQxM=";
};
outputs = [
@@ -74,10 +75,29 @@ stdenv.mkDerivation (finalAttrs: {
(lib.cmakeBool "BUILD_STATIC_LIBRARY" false)
];
postFixup = ''
wrapPythonProgramsIn "$out/bin" "$out $pythonPath"
preFixup = ''
# This is a module and should not be wrapped, or it causes import errors
# on the scripts that are actually executable
chmod a-x $out/bin/fc_solve_find_index_s2ints.py
'';
postFixup = ''
wrapPythonProgramsIn "$out/bin" "$out ''${pythonPath[*]}"
'';
nativeInstallCheckInputs = [ versionCheckHook ];
postInstallCheck = ''
# Check that the python wrappers work correctly:
# * fc_solve_find_index_s2ints.py should be unwrapped (we get SyntaxError otherwise)
# * the wrapper should provide all modules from the pythonPath (we get ModuleNotFoundError otherwise)
# * we don't provide valid input so expect IndexError
unset PYTHONPATH
($out/bin/make_pysol_freecell_board.py 2>&1 | tee /dev/stderr || true) | grep -q "IndexError:"
'';
doInstallCheck = true;
__structuredAttrs = true;
meta = {
homepage = "https://fc-solve.shlomifish.org/";
description = "FreeCell automatic solver";

View File

@@ -5,6 +5,7 @@
ninja,
python3,
gnome,
versionCheckHook,
}:
python3.pkgs.buildPythonApplication rec {
@@ -36,12 +37,17 @@ python3.pkgs.buildPythonApplication rec {
typogrify
];
doCheck = false; # no tests
# For Python this must be placed in nativeCheckInputs instead of nativeInstallCheckInputs
# https://github.com/nixos/nixpkgs/issues/420531
nativeCheckInputs = [ versionCheckHook ];
# doCheck = false; # no tests - restore this after versionCheckHook can be moved
__structuredAttrs = true;
postFixup = ''
# Do not propagate Python
substituteInPlace $out/nix-support/propagated-build-inputs \
--replace "${python3}" ""
--replace-fail "${python3}" ""
'';
passthru = {

View File

@@ -1,7 +1,7 @@
# Wrapper around wrapPythonProgramsIn, below. The $pythonPath
# variable is passed in from the buildPythonPackage function.
wrapPythonPrograms() {
wrapPythonProgramsIn "$out/bin" "$out $pythonPath"
wrapPythonProgramsIn "$out/bin" "$out ${pythonPath[*]}"
}
# Builds environment variables like PYTHONPATH and PATH walking through closure