dtc: fix python 3.10 compatibility

authored by Sandro Jäckel and committed by Jonathan Ringer 548ae98b 1d5ed925

+50 -3
+22 -3
pkgs/development/compilers/dtc/default.nix
··· 1 - { stdenv, lib, fetchgit, flex, bison, pkg-config, which 2 - , pythonSupport ? false, python ? null, swig, libyaml 1 + { stdenv 2 + , lib 3 + , fetchgit 4 + , fetchpatch 5 + , flex 6 + , bison 7 + , pkg-config 8 + , which 9 + , pythonSupport ? false 10 + , python ? null 11 + , swig 12 + , libyaml 3 13 }: 4 14 5 15 stdenv.mkDerivation rec { ··· 12 22 sha256 = "sha256-gx9LG3U9etWhPxm7Ox7rOu9X5272qGeHqZtOe68zFs4="; 13 23 }; 14 24 25 + patches = [ 26 + # fix python 3.10 compatibility 27 + # based on without requiring the setup.py rework 28 + # https://git.kernel.org/pub/scm/utils/dtc/dtc.git/commit/?id=383e148b70a47ab15f97a19bb999d54f9c3e810f 29 + ./python-3.10.patch 30 + ]; 31 + 32 + nativeBuildInputs = [ flex bison pkg-config which ] 33 + ++ lib.optionals pythonSupport [ python swig ]; 34 + 15 35 buildInputs = [ libyaml ]; 16 - nativeBuildInputs = [ flex bison pkg-config which ] ++ lib.optionals pythonSupport [ python swig ]; 17 36 18 37 postPatch = '' 19 38 patchShebangs pylibfdt/
+28
pkgs/development/compilers/dtc/python-3.10.patch
··· 1 + diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i 2 + index 51ee801..075ef70 100644 3 + --- a/pylibfdt/libfdt.i 4 + +++ b/pylibfdt/libfdt.i 5 + @@ -1044,9 +1044,9 @@ typedef uint32_t fdt32_t; 6 + $result = Py_None; 7 + else 8 + %#if PY_VERSION_HEX >= 0x03000000 9 + - $result = Py_BuildValue("y#", $1, *arg4); 10 + + $result = Py_BuildValue("y#", $1, (Py_ssize_t)*arg4); 11 + %#else 12 + - $result = Py_BuildValue("s#", $1, *arg4); 13 + + $result = Py_BuildValue("s#", $1, (Py_ssize_t)*arg4); 14 + %#endif 15 + } 16 + 17 + diff --git a/pylibfdt/setup.py b/pylibfdt/setup.py 18 + index ef40f15..81e161a 100755 19 + --- a/pylibfdt/setup.py 20 + +++ b/pylibfdt/setup.py 21 + @@ -42,6 +42,7 @@ def get_version(): 22 + libfdt_module = Extension( 23 + '_libfdt', 24 + sources=[os.path.join(srcdir, 'libfdt.i')], 25 + + define_macros=[('PY_SSIZE_T_CLEAN', None)], 26 + include_dirs=[os.path.join(srcdir, '../libfdt')], 27 + libraries=['fdt'], 28 + library_dirs=[os.path.join(top_builddir, 'libfdt')],