From a9ae2724a903cff3123089090148a0bd8f1c5c15 Mon Sep 17 00:00:00 2001 From: Martin Joerg Date: Mon, 1 Dec 2025 09:05:07 +0000 Subject: [PATCH 1/3] python3Packages.wxpython: fix references to libraries This corrects the following issues: + libpangocairo was referencing the library in an incorrect package output + the substitution for libcairo was not having the desired effect + the used library extensions were not correct on all platforms --- .../python-modules/wxpython/4.2-ctypes.patch | 14 +++++++++++--- pkgs/development/python-modules/wxpython/4.2.nix | 6 +++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pkgs/development/python-modules/wxpython/4.2-ctypes.patch b/pkgs/development/python-modules/wxpython/4.2-ctypes.patch index 17fd8a9a8490..1f07fb004d1a 100644 --- a/pkgs/development/python-modules/wxpython/4.2-ctypes.patch +++ b/pkgs/development/python-modules/wxpython/4.2-ctypes.patch @@ -1,8 +1,17 @@ diff --git a/wx/lib/wxcairo/wx_pycairo.py b/wx/lib/wxcairo/wx_pycairo.py -index 7cfe3071..24d1120f 100644 +index 19a28dd131f659cd596de280bc52f3f7fb1acb5f..dc6bea6afb36e4197fac990877b7112ade84d6f4 100644 --- a/wx/lib/wxcairo/wx_pycairo.py +++ b/wx/lib/wxcairo/wx_pycairo.py -@@ -197,7 +197,12 @@ def _findCairoLib(): +@@ -25,7 +25,7 @@ import ctypes.util + #---------------------------------------------------------------------------- + + # A reference to the cairo shared lib via ctypes.CDLL +-cairoLib = None ++cairoLib = ctypes.CDLL("@libcairo@") + + # A reference to the pycairo C API structure + pycairoAPI = None +@@ -196,7 +196,11 @@ def _findCairoLib(): # For other DLLs we'll just use a dictionary to track them, as there # probably isn't any need to use them outside of this module. @@ -10,7 +19,6 @@ index 7cfe3071..24d1120f 100644 +_dlls = { + "gdk": ctypes.CDLL("@libgdk@"), + "pangocairo": ctypes.CDLL("@libpangocairo@"), -+ "cairoLib": ctypes.CDLL("@libcairo@"), + "appsvc": ctypes.CDLL(None), +} diff --git a/pkgs/development/python-modules/wxpython/4.2.nix b/pkgs/development/python-modules/wxpython/4.2.nix index a4bd7a8af2f1..6346fefa0014 100644 --- a/pkgs/development/python-modules/wxpython/4.2.nix +++ b/pkgs/development/python-modules/wxpython/4.2.nix @@ -53,9 +53,9 @@ buildPythonPackage rec { patches = [ (replaceVars ./4.2-ctypes.patch { - libgdk = "${gtk3.out}/lib/libgdk-3.so"; - libpangocairo = "${pango}/lib/libpangocairo-1.0.so"; - libcairo = "${cairo}/lib/libcairo.so"; + libgdk = "${lib.getLib gtk3}/lib/libgdk-3${stdenv.hostPlatform.extensions.sharedLibrary}"; + libpangocairo = "${lib.getLib pango}/lib/libpangocairo-1.0${stdenv.hostPlatform.extensions.sharedLibrary}"; + libcairo = "${lib.getLib cairo}/lib/libcairo${stdenv.hostPlatform.extensions.sharedLibrary}"; }) ./0001-add-missing-bool-c.patch # Add missing bool.c from old source ]; From 8a95cd2b0ce18baeebbf35bf98be05a6379421da Mon Sep 17 00:00:00 2001 From: Martin Joerg Date: Mon, 1 Dec 2025 09:05:07 +0000 Subject: [PATCH 2/3] python3Packages.wxpython: enable tests --- .../python-modules/wxpython/4.2.nix | 48 ++++++++++++++++--- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/pkgs/development/python-modules/wxpython/4.2.nix b/pkgs/development/python-modules/wxpython/4.2.nix index 6346fefa0014..68bee00914d6 100644 --- a/pkgs/development/python-modules/wxpython/4.2.nix +++ b/pkgs/development/python-modules/wxpython/4.2.nix @@ -38,6 +38,12 @@ numpy, pillow, six, + + # checks + py, + pytest, + pytest-forked, + xvfb-run, }: buildPythonPackage rec { @@ -64,7 +70,8 @@ buildPythonPackage rec { postPatch = '' ln -s ${lib.getExe buildPackages.waf} bin/waf substituteInPlace build.py \ - --replace-fail "distutils.dep_util" "setuptools.modified" + --replace-fail "distutils.dep_util" "setuptools.modified" \ + --replace-fail "runcmd(cmd, fatal=False)" "runcmd(cmd, fatal=True)" # fail when pytest reports errors ''; nativeBuildInputs = [ @@ -102,6 +109,13 @@ buildPythonPackage rec { six ]; + nativeCheckInputs = [ + py # py must be ordered before pytest (see https://github.com/pytest-dev/pytest-forked/issues/88) + pytest + pytest-forked + xvfb-run + ]; + wafPath = "bin/waf"; buildPhase = '' @@ -124,13 +138,35 @@ buildPythonPackage rec { runHook postInstall ''; - checkPhase = '' - runHook preCheck + # The majority of the tests require a graphical environment, but xvfb-run is available only on Linux. + # Tests on aarch64-linux fail randomly on OfBorg. + doCheck = stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform.isLinux; - ${python.interpreter} build.py -v test + checkPhase = + let + # Some tests appear to be incompatible with xvfb-run. + skippedTests = [ + "dirdlg" + "display" + "filectrl" + "filedlg" + "filedlgcustomize" + "frame" + "glcanvas" + "pickers" + "windowid" + ]; + testArguments = lib.concatMapStringsSep " " ( + test: "--ignore unittests/test_${test}.py" + ) skippedTests; + in + '' + runHook preCheck - runHook postCheck - ''; + HOME=$(mktemp -d) xvfb-run ${python.interpreter} build.py -v --extra_pytest='${testArguments}' test + + runHook postCheck + ''; meta = with lib; { changelog = "https://github.com/wxWidgets/Phoenix/blob/wxPython-${version}/CHANGES.rst"; From ebbdb1b6cf159ee8085f4953a36c30d643fae4c6 Mon Sep 17 00:00:00 2001 From: Martin Joerg Date: Mon, 1 Dec 2025 09:05:07 +0000 Subject: [PATCH 3/3] python3Packages.wxpython: 4.2.3 -> 4.2.4 https://github.com/wxWidgets/Phoenix/blob/refs/tags/wxPython-4.2.4/CHANGES.rst https://github.com/wxWidgets/Phoenix/compare/refs/tags/wxPython-4.2.3...refs/tags/wxPython-4.2.4 --- .../development/python-modules/wxpython/4.2.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/wxpython/4.2.nix b/pkgs/development/python-modules/wxpython/4.2.nix index 68bee00914d6..8dfeb074c16b 100644 --- a/pkgs/development/python-modules/wxpython/4.2.nix +++ b/pkgs/development/python-modules/wxpython/4.2.nix @@ -4,11 +4,13 @@ buildPythonPackage, setuptools, fetchPypi, + fetchpatch, replaceVars, # build autoPatchelfHook, attrdict, + cython, doxygen, pkg-config, python, @@ -48,13 +50,12 @@ buildPythonPackage rec { pname = "wxpython"; - version = "4.2.3"; + version = "4.2.4"; format = "other"; src = fetchPypi { - pname = "wxPython"; - inherit version; - hash = "sha256-INbgySfifO2FZDcZvWPp9/1QHfbpqKqxSJsDmJf9fAE="; + inherit pname version; + hash = "sha256-LrEjl5yHvLMp6KJFImnWD/j59lHpvyXGdXnlPE67rjw="; }; patches = [ @@ -64,6 +65,13 @@ buildPythonPackage rec { libcairo = "${lib.getLib cairo}/lib/libcairo${stdenv.hostPlatform.extensions.sharedLibrary}"; }) ./0001-add-missing-bool-c.patch # Add missing bool.c from old source + # TODO: drop when updating beyond version 4.2.4 + # https://github.com/wxWidgets/Phoenix/pull/2822 + (fetchpatch { + name = "Fix-wx.svg-to-work-with-cython-3.1-generated-code.patch"; + url = "https://github.com/wxWidgets/Phoenix/commit/31303649ab0a0fed0789e0951a7487d172b65bfa.patch"; + hash = "sha256-OAnAsyqHGPNEAiOxLLpdEGcd92K7TCxqEBYceuIb8so="; + }) ]; # https://github.com/wxWidgets/Phoenix/issues/2575 @@ -76,6 +84,7 @@ buildPythonPackage rec { nativeBuildInputs = [ attrdict + cython pkg-config requests setuptools