Commit e3dc8787 authored by Gaetan Lepage's avatar Gaetan Lepage
Browse files

python312Packages.xnd: cleanup, fix



Co-authored-by: default avatarNick Cao <nickcao@nichi.co>
parent d1e172d8
Loading
Loading
Loading
Loading
+29 −15
Original line number Diff line number Diff line
@@ -2,31 +2,41 @@
  lib,
  stdenv,
  buildPythonPackage,
  python,
  libxnd,
  setuptools,
  ndtypes,
  libndtypes,
  libxnd,
  isPy27,
  pythonAtLeast,
  python,
}:

buildPythonPackage {
  pname = "xnd";
  format = "setuptools";
  disabled = isPy27;
  inherit (libxnd) version src meta;
  pyproject = true;

  build-system = [ setuptools ];

  propagatedBuildInputs = [ ndtypes ];
  dependencies = [ ndtypes ];

  buildInputs = [ libndtypes ];

  postPatch = ''
  postPatch =
    ''
      substituteInPlace setup.py \
      --replace 'include_dirs = ["libxnd", "ndtypes/python/ndtypes"] + INCLUDES' \
        --replace-fail \
          'include_dirs = ["libxnd", "ndtypes/python/ndtypes"] + INCLUDES' \
          'include_dirs = ["${libndtypes}/include", "${ndtypes}/include", "${libxnd}/include"]' \
      --replace 'library_dirs = ["libxnd", "ndtypes/libndtypes"] + LIBS' \
        --replace-fail \
          'library_dirs = ["libxnd", "ndtypes/libndtypes"] + LIBS' \
          'library_dirs = ["${libndtypes}/lib", "${libxnd}/lib"]' \
      --replace 'runtime_library_dirs = ["$ORIGIN"]' \
                'runtime_library_dirs = ["${libndtypes}/lib", "${libxnd}/lib"]' \
        --replace-fail \
          'runtime_library_dirs = ["$ORIGIN"]' \
          'runtime_library_dirs = ["${libndtypes}/lib", "${libxnd}/lib"]'
    ''
    + lib.optionalString (pythonAtLeast "3.12") ''
      substituteInPlace python/xnd/util.h \
        --replace-fail '->ob_digit[i]' '->long_value.ob_digit[i]'
    '';

  postInstall =
@@ -39,9 +49,13 @@ buildPythonPackage {
    '';

  checkPhase = ''
    runHook preCheck

    pushd python
    mv xnd _xnd
    python test_xnd.py
    popd

    runHook postCheck
  '';
}