dtc: fix python 3.10 compatibility

main
Sandro Jäckel 2 years ago committed by Jonathan Ringer
parent 1d5ed925d5
commit 548ae98b58
No known key found for this signature in database
GPG Key ID: 5C841D3CFDFEC4E0
  1. 25
      pkgs/development/compilers/dtc/default.nix
  2. 28
      pkgs/development/compilers/dtc/python-3.10.patch

@ -1,5 +1,15 @@
{ stdenv, lib, fetchgit, flex, bison, pkg-config, which
, pythonSupport ? false, python ? null, swig, libyaml
{ stdenv
, lib
, fetchgit
, fetchpatch
, flex
, bison
, pkg-config
, which
, pythonSupport ? false
, python ? null
, swig
, libyaml
}:
stdenv.mkDerivation rec {
@ -12,8 +22,17 @@ stdenv.mkDerivation rec {
sha256 = "sha256-gx9LG3U9etWhPxm7Ox7rOu9X5272qGeHqZtOe68zFs4=";
};
patches = [
# fix python 3.10 compatibility
# based on without requiring the setup.py rework
# https://git.kernel.org/pub/scm/utils/dtc/dtc.git/commit/?id=383e148b70a47ab15f97a19bb999d54f9c3e810f
./python-3.10.patch
];
nativeBuildInputs = [ flex bison pkg-config which ]
++ lib.optionals pythonSupport [ python swig ];
buildInputs = [ libyaml ];
nativeBuildInputs = [ flex bison pkg-config which ] ++ lib.optionals pythonSupport [ python swig ];
postPatch = ''
patchShebangs pylibfdt/

@ -0,0 +1,28 @@
diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
index 51ee801..075ef70 100644
--- a/pylibfdt/libfdt.i
+++ b/pylibfdt/libfdt.i
@@ -1044,9 +1044,9 @@ typedef uint32_t fdt32_t;
$result = Py_None;
else
%#if PY_VERSION_HEX >= 0x03000000
- $result = Py_BuildValue("y#", $1, *arg4);
+ $result = Py_BuildValue("y#", $1, (Py_ssize_t)*arg4);
%#else
- $result = Py_BuildValue("s#", $1, *arg4);
+ $result = Py_BuildValue("s#", $1, (Py_ssize_t)*arg4);
%#endif
}
diff --git a/pylibfdt/setup.py b/pylibfdt/setup.py
index ef40f15..81e161a 100755
--- a/pylibfdt/setup.py
+++ b/pylibfdt/setup.py
@@ -42,6 +42,7 @@ def get_version():
libfdt_module = Extension(
'_libfdt',
sources=[os.path.join(srcdir, 'libfdt.i')],
+ define_macros=[('PY_SSIZE_T_CLEAN', None)],
include_dirs=[os.path.join(srcdir, '../libfdt')],
libraries=['fdt'],
library_dirs=[os.path.join(top_builddir, 'libfdt')],
Loading…
Cancel
Save