From e33181bc6273abdcc4ec67cb6161401823f49b57 Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Thu, 7 Aug 2025 10:11:58 +0200 Subject: [PATCH 1/3] pypy{27,310,311}: make CFFI builds find libsqlite3 --- .../interpreters/python/pypy/default.nix | 16 ++++++++- .../python/pypy/sqlite_paths.patch | 36 ++++++++++++++++--- .../python/pypy/sqlite_paths_2_7.patch | 22 ++++++++++++ 3 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 pkgs/development/interpreters/python/pypy/sqlite_paths_2_7.patch diff --git a/pkgs/development/interpreters/python/pypy/default.nix b/pkgs/development/interpreters/python/pypy/default.nix index 93dadcfce437..7779b3fbba8f 100644 --- a/pkgs/development/interpreters/python/pypy/default.nix +++ b/pkgs/development/interpreters/python/pypy/default.nix @@ -140,8 +140,22 @@ stdenv.mkDerivation rec { tcl_libprefix = tcl.libPrefix; }) - (replaceVars ./sqlite_paths.patch { + # Python ctypes.util uses three different strategies to find a library (on Linux): + # 1. /sbin/ldconfig + # 2. cc -Wl,-t -l"$libname"; objdump -p + # 3. ld -t (where it attaches the values in $LD_LIBRARY_PATH as -L arguments) + # The first is disabled in Nix (and wouldn't work in the build sandbox or on NixOS anyway), and + # the third was only introduced in Python 3.6 (see bugs.python.org/issue9998), so is not + # available when buliding PyPy (which is built using Python/PyPy 2.7). + # The second requires SONAME to be set for the dynamic library for the second part not to fail. + # As libsqlite3 stopped shipping with SONAME after the switch to autosetup (>= 3.50 in Nixpkgs; + # see https://www.sqlite.org/src/forumpost/5a3b44f510df8ded). This makes the Python CFFI module + # unable to find the SQLite library. + # To circumvent these issues, we hardcode the path during build. + # For more information, see https://github.com/NixOS/nixpkgs/issues/419942. + (replaceVars (if isPy3k then ./sqlite_paths.patch else ./sqlite_paths_2_7.patch) { inherit (sqlite) out dev; + libsqlite = "${sqlite.out}/lib/libsqlite3${stdenv.hostPlatform.extensions.sharedLibrary}"; }) ]; diff --git a/pkgs/development/interpreters/python/pypy/sqlite_paths.patch b/pkgs/development/interpreters/python/pypy/sqlite_paths.patch index 42de7efb3ea3..73af8942acf2 100644 --- a/pkgs/development/interpreters/python/pypy/sqlite_paths.patch +++ b/pkgs/development/interpreters/python/pypy/sqlite_paths.patch @@ -1,7 +1,35 @@ -diff -ur a/lib_pypy/_sqlite3_build.py b/lib_pypy/_sqlite3_build.py ---- a/lib_pypy/_sqlite3_build.py 2021-04-12 01:11:48.000000000 -0400 -+++ b/lib_pypy/_sqlite3_build.py 2021-07-14 18:08:33.000000000 -0400 -@@ -301,6 +301,8 @@ +diff --git a/lib_pypy/_sqlite3_build.py b/lib_pypy/_sqlite3_build.py +index 2a4e573..92ab786 100644 +--- a/lib_pypy/_sqlite3_build.py ++++ b/lib_pypy/_sqlite3_build.py +@@ -352,7 +352,7 @@ def _has_load_extension(): + typedef ... sqlite3; + int sqlite3_enable_load_extension(sqlite3 *db, int onoff); + """) +- libname = 'sqlite3' ++ libname = '@libsqlite@' + if sys.platform == 'win32': + import os + _libname = os.path.join(os.path.dirname(sys.executable), libname) +@@ -369,7 +369,7 @@ def _has_backup(): + typedef ... sqlite3_backup; + sqlite3_backup* sqlite3_backup_init(sqlite3 *, const char* , sqlite3 *, const char*); + """) +- libname = 'sqlite3' ++ libname = '@libsqlite@' + if sys.platform == 'win32': + import os + _libname = os.path.join(os.path.dirname(sys.executable), libname) +@@ -383,7 +383,7 @@ def _get_version(): + unverified_ffi.cdef(""" + int sqlite3_libversion_number(void); + """) +- libname = 'sqlite3' ++ libname = '@libsqlite@' + if sys.platform == 'win32': + import os + _libname = os.path.join(os.path.dirname(sys.executable), libname) +@@ -554,6 +554,8 @@ if sys.platform.startswith('freebsd'): else: extra_args = dict( libraries=libraries, diff --git a/pkgs/development/interpreters/python/pypy/sqlite_paths_2_7.patch b/pkgs/development/interpreters/python/pypy/sqlite_paths_2_7.patch new file mode 100644 index 000000000000..2226bac5e3d8 --- /dev/null +++ b/pkgs/development/interpreters/python/pypy/sqlite_paths_2_7.patch @@ -0,0 +1,22 @@ +diff --git a/lib_pypy/_sqlite3_build.py b/lib_pypy/_sqlite3_build.py +index fb03aee..b3b5f39 100644 +--- a/lib_pypy/_sqlite3_build.py ++++ b/lib_pypy/_sqlite3_build.py +@@ -234,7 +234,7 @@ def _has_load_extension(): + typedef ... sqlite3; + int sqlite3_enable_load_extension(sqlite3 *db, int onoff); + """) +- libname = 'sqlite3' ++ libname = '@libsqlite@' + if sys.platform == 'win32': + import os + _libname = os.path.join(os.path.dirname(sys.executable), libname) +@@ -257,6 +257,8 @@ if sys.platform.startswith('freebsd'): + else: + extra_args = dict( + libraries=libraries, ++ include_dirs=['@dev@/include'], ++ library_dirs=['@out@/lib'] + ) + + _ffi.set_source("_sqlite3_cffi", "#include ", **extra_args) From f6b62e03ed4e485506b194fd1ca4d572072c90ab Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Sun, 17 Aug 2025 15:01:00 +0200 Subject: [PATCH 2/3] fbpanel: correctly apply -Wno-error --- pkgs/by-name/fb/fbpanel/package.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/fb/fbpanel/package.nix b/pkgs/by-name/fb/fbpanel/package.nix index bf62ae6d41da..2572ff5a00c1 100644 --- a/pkgs/by-name/fb/fbpanel/package.nix +++ b/pkgs/by-name/fb/fbpanel/package.nix @@ -49,8 +49,10 @@ stdenv.mkDerivation { ''; makeFlags = [ "V=1" ]; - NIX_CFLAGS_COMPILE = [ + + env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error" + "-Wno-error=incompatible-pointer-types" # not implied by -Wno-error "-I${gdk-pixbuf-xlib.dev}/include/gdk-pixbuf-2.0" ]; From 20d8a653d0a826994e59c9bddede2b7d58598b1c Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Sun, 17 Aug 2025 15:06:28 +0200 Subject: [PATCH 3/3] python3Packages.pyflakes: disable failing test for PyPy3 test_misencodedFileUTF16 fails with PyPy3 as it outputs a different error message than CPython. --- pkgs/development/python-modules/pyflakes/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/python-modules/pyflakes/default.nix b/pkgs/development/python-modules/pyflakes/default.nix index 3620594cfb76..821ce3d55f77 100644 --- a/pkgs/development/python-modules/pyflakes/default.nix +++ b/pkgs/development/python-modules/pyflakes/default.nix @@ -26,6 +26,7 @@ buildPythonPackage rec { disabledTests = lib.optionals isPyPy [ # https://github.com/PyCQA/pyflakes/issues/779 "test_eofSyntaxError" + "test_misencodedFileUTF16" "test_misencodedFileUTF8" "test_multilineSyntaxError" ];