scandir: fix build on aarch64-darwin

main
Weijia Wang 2 years ago
parent 979a581e10
commit 4ef739adf1
  1. 14
      pkgs/development/misc/resholve/resholve.nix
  2. 28
      pkgs/development/python2-modules/scandir/add-aarch64-darwin-dirent.patch
  3. 6
      pkgs/development/python2-modules/scandir/default.nix

@ -19,24 +19,16 @@ python27Packages.buildPythonApplication {
propagatedBuildInputs = [
oildev
/*
Disable configargparse's tests on aarch64-darwin.
Several of py27 scandir's tests fail on aarch64-darwin. Chain:
configargparse -> pytest-check-hook -> pytest -> pathlib2 -> scandir
TODO: drop if https://github.com/NixOS/nixpkgs/issues/156807 resolves?
*/
(python27Packages.configargparse.overridePythonAttrs (old: {
doCheck = stdenv.hostPlatform.system != "aarch64-darwin";
}))
python27Packages.configargparse
];
patchPhase = ''
postPatch = ''
for file in setup.cfg _resholve/version.py; do
substituteInPlace $file --subst-var-by version ${version}
done
'';
postInstall = ''
postInstall = ''
installManPage resholve.1
'';

@ -0,0 +1,28 @@
diff --git a/scandir.py b/scandir.py
index 3f602fb..40af3e5 100644
--- a/scandir.py
+++ b/scandir.py
@@ -23,6 +23,7 @@ from os import listdir, lstat, stat, strerror
from os.path import join, islink
from stat import S_IFDIR, S_IFLNK, S_IFREG
import collections
+import platform
import sys
try:
@@ -432,6 +433,15 @@ elif sys.platform.startswith(('linux', 'darwin', 'sunos5')) or 'bsd' in sys.plat
('__d_padding', ctypes.c_uint8 * 4),
('d_name', ctypes.c_char * 256),
)
+ elif 'darwin' in sys.platform and 'arm64' in platform.machine():
+ _fields_ = (
+ ('d_ino', ctypes.c_uint64),
+ ('d_off', ctypes.c_uint64),
+ ('d_reclen', ctypes.c_uint16),
+ ('d_namlen', ctypes.c_uint16),
+ ('d_type', ctypes.c_uint8),
+ ('d_name', ctypes.c_char * 1024),
+ )
else:
_fields_ = (
('d_ino', ctypes.c_uint32), # must be uint32, not ulong

@ -6,9 +6,13 @@ buildPythonPackage rec {
src = fetchPypi {
inherit pname version;
sha256 ="1bkqwmf056pkchf05ywbnf659wqlp6lljcdb0y88wr9f0vv32ijd";
sha256 = "1bkqwmf056pkchf05ywbnf659wqlp6lljcdb0y88wr9f0vv32ijd";
};
patches = [
./add-aarch64-darwin-dirent.patch
];
checkPhase = "${python.interpreter} test/run_tests.py";
meta = with lib; {

Loading…
Cancel
Save