Skip to content

Conversation

@GaetanLepage
Copy link
Contributor

@GaetanLepage GaetanLepage commented Apr 21, 2025

Things done

python/xnd/util.h: In function ‘long_compare’:
python/xnd/util.h:199:29: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  199 |         while (--i >= 0 && a->ob_digit[i] == b->ob_digit[i])
      |                             ^~
python/xnd/util.h:199:47: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  199 |         while (--i >= 0 && a->ob_digit[i] == b->ob_digit[i])
      |                                               ^~
python/xnd/util.h:204:29: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  204 |             sign = (sdigit)a->ob_digit[i] - (sdigit)b->ob_digit[i];
      |                             ^~
python/xnd/util.h:204:54: error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
  204 |             sign = (sdigit)a->ob_digit[i] - (sdigit)b->ob_digit[i];
      |

cc @costrouc

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: python Python is a high-level, general-purpose programming language. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Apr 21, 2025
@GaetanLepage GaetanLepage requested review from NickCao and pbsds April 21, 2025 19:53
@NickCao
Copy link
Member

NickCao commented Apr 21, 2025

Here it says updating cython alone is enough to fix this: aio-libs/aiohttp#7229.

@GaetanLepage
Copy link
Contributor Author

Here it says updating cython alone is enough to fix this: aio-libs/aiohttp#7229.

Adding cython to build-system does not help... The version is 3.0.12 (released 2025-02-11) so I suppose that it is recent enough...

@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Apr 21, 2025
@nix-owners nix-owners bot requested a review from costrouc April 21, 2025 22:42
@NickCao
Copy link
Member

NickCao commented Apr 21, 2025

diff --git a/pkgs/development/python-modules/xnd/default.nix b/pkgs/development/python-modules/xnd/default.nix
index d8580eeb4396..a7f57b44b3c0 100644
--- a/pkgs/development/python-modules/xnd/default.nix
+++ b/pkgs/development/python-modules/xnd/default.nix
@@ -7,6 +7,7 @@
   ndtypes,
   libndtypes,
   python,
+  pythonAtLeast,
 }:
 
 buildPythonPackage {
@@ -20,18 +21,23 @@ buildPythonPackage {
 
   buildInputs = [ libndtypes ];
 
-  postPatch = ''
-    substituteInPlace setup.py \
-      --replace-fail \
-        'include_dirs = ["libxnd", "ndtypes/python/ndtypes"] + INCLUDES' \
-        'include_dirs = ["${libndtypes}/include", "${ndtypes}/include", "${libxnd}/include"]' \
-      --replace-fail \
-        'library_dirs = ["libxnd", "ndtypes/libndtypes"] + LIBS' \
-        'library_dirs = ["${libndtypes}/lib", "${libxnd}/lib"]' \
-      --replace-fail \
-        'runtime_library_dirs = ["$ORIGIN"]' \
-        'runtime_library_dirs = ["${libndtypes}/lib", "${libxnd}/lib"]'
-  '';
+  postPatch =
+    ''
+      substituteInPlace setup.py \
+        --replace-fail \
+          'include_dirs = ["libxnd", "ndtypes/python/ndtypes"] + INCLUDES' \
+          'include_dirs = ["${libndtypes}/include", "${ndtypes}/include", "${libxnd}/include"]' \
+        --replace-fail \
+          'library_dirs = ["libxnd", "ndtypes/libndtypes"] + LIBS' \
+          '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 =
     ''
@@ -52,9 +58,4 @@ buildPythonPackage {
 
     runHook postCheck
   '';
-
-  meta = libxnd.meta // {
-    #  error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
-    broken = true;
-  };
 }

@GaetanLepage GaetanLepage force-pushed the xnd branch 2 times, most recently from 6c615d4 to 5f466fb Compare April 21, 2025 23:09
Co-authored-by: Nick Cao <nickcao@nichi.co>
@GaetanLepage
Copy link
Contributor Author

d

diff --git a/pkgs/development/python-modules/xnd/default.nix b/pkgs/development/python-modules/xnd/default.nix
index d8580eeb4396..a7f57b44b3c0 100644
--- a/pkgs/development/python-modules/xnd/default.nix
+++ b/pkgs/development/python-modules/xnd/default.nix
@@ -7,6 +7,7 @@
   ndtypes,
   libndtypes,
   python,
+  pythonAtLeast,
 }:
 
 buildPythonPackage {
@@ -20,18 +21,23 @@ buildPythonPackage {
 
   buildInputs = [ libndtypes ];
 
-  postPatch = ''
-    substituteInPlace setup.py \
-      --replace-fail \
-        'include_dirs = ["libxnd", "ndtypes/python/ndtypes"] + INCLUDES' \
-        'include_dirs = ["${libndtypes}/include", "${ndtypes}/include", "${libxnd}/include"]' \
-      --replace-fail \
-        'library_dirs = ["libxnd", "ndtypes/libndtypes"] + LIBS' \
-        'library_dirs = ["${libndtypes}/lib", "${libxnd}/lib"]' \
-      --replace-fail \
-        'runtime_library_dirs = ["$ORIGIN"]' \
-        'runtime_library_dirs = ["${libndtypes}/lib", "${libxnd}/lib"]'
-  '';
+  postPatch =
+    ''
+      substituteInPlace setup.py \
+        --replace-fail \
+          'include_dirs = ["libxnd", "ndtypes/python/ndtypes"] + INCLUDES' \
+          'include_dirs = ["${libndtypes}/include", "${ndtypes}/include", "${libxnd}/include"]' \
+        --replace-fail \
+          'library_dirs = ["libxnd", "ndtypes/libndtypes"] + LIBS' \
+          '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 =
     ''
@@ -52,9 +58,4 @@ buildPythonPackage {
 
     runHook postCheck
   '';
-
-  meta = libxnd.meta // {
-    #  error: ‘PyLongObject’ {aka ‘struct _longobject’} has no member named ‘ob_digit’
-    broken = true;
-  };
 }

Nice! It works!

@GaetanLepage GaetanLepage changed the title python312Packages.xnd: mark as broken python312Packages.xnd: cleanup, fix Apr 21, 2025
@GaetanLepage
Copy link
Contributor Author

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 400567


x86_64-linux

✅ 8 packages built:
  • python312Packages.gumath
  • python312Packages.gumath.dist
  • python312Packages.xnd
  • python312Packages.xnd.dist
  • python313Packages.gumath
  • python313Packages.gumath.dist
  • python313Packages.xnd
  • python313Packages.xnd.dist

aarch64-linux

✅ 8 packages built:
  • python312Packages.gumath
  • python312Packages.gumath.dist
  • python312Packages.xnd
  • python312Packages.xnd.dist
  • python313Packages.gumath
  • python313Packages.gumath.dist
  • python313Packages.xnd
  • python313Packages.xnd.dist

x86_64-darwin

✅ 8 packages built:
  • python312Packages.gumath
  • python312Packages.gumath.dist
  • python312Packages.xnd
  • python312Packages.xnd.dist
  • python313Packages.gumath
  • python313Packages.gumath.dist
  • python313Packages.xnd
  • python313Packages.xnd.dist

aarch64-darwin

✅ 8 packages built:
  • python312Packages.gumath
  • python312Packages.gumath.dist
  • python312Packages.xnd
  • python312Packages.xnd.dist
  • python313Packages.gumath
  • python313Packages.gumath.dist
  • python313Packages.xnd
  • python313Packages.xnd.dist

@GaetanLepage GaetanLepage merged commit 9397bec into NixOS:master Apr 21, 2025
63 of 67 checks passed
@GaetanLepage GaetanLepage deleted the xnd branch April 21, 2025 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: python Python is a high-level, general-purpose programming language. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants