From 4e9e5aeafeb41f780932097b6935087793b0ce06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= Date: Mon, 2 Jan 2023 11:51:55 +0100 Subject: [PATCH] spyder: add patch fix startup error Upstream clears out all sys.path entries that come from PYTHONPATH, which completely breaks Nixpkgs packaging. Patch out that code to fix running spyder. Before: $ spyder Traceback (most recent call last): File "/nix/store/icbklw22yrzy7s8k2ai8chkhrvna8pxr-python3.10-spyder-5.4.0/bin/..spyder-wrapped-wrapped", line 6, in from spyder.app.start import main File "/nix/store/icbklw22yrzy7s8k2ai8chkhrvna8pxr-python3.10-spyder-5.4.0/lib/python3.10/site-packages/spyder/app/start.py", line 42, in import zmq ModuleNotFoundError: No module named 'zmq' (exit with error code 1) After: $ spyder (succeeds startup) Note that once the GUI is up, it complains (inside GUI) that we've got wrong version of 2 deps and "ModuleNotFoundError: No module named 'spyder_kernels'". Fixes https://github.com/NixOS/nixpkgs/issues/208567 --- .../python-modules/spyder/default.nix | 4 ++++ .../spyder/dont-clear-pythonpath.patch | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 pkgs/development/python-modules/spyder/dont-clear-pythonpath.patch diff --git a/pkgs/development/python-modules/spyder/default.nix b/pkgs/development/python-modules/spyder/default.nix index d6d408b8c686..2a0d74c84f08 100644 --- a/pkgs/development/python-modules/spyder/default.nix +++ b/pkgs/development/python-modules/spyder/default.nix @@ -56,6 +56,10 @@ buildPythonPackage rec { hash = "sha256-kQBOYRXhjz+OQk7Vlxb/UKiDi92mA8ialsFQ+QzqhlE="; }; + patches = [ + ./dont-clear-pythonpath.patch + ]; + nativeBuildInputs = [ pyqtwebengine.wrapQtAppsHook ]; diff --git a/pkgs/development/python-modules/spyder/dont-clear-pythonpath.patch b/pkgs/development/python-modules/spyder/dont-clear-pythonpath.patch new file mode 100644 index 000000000000..cb2a37930715 --- /dev/null +++ b/pkgs/development/python-modules/spyder/dont-clear-pythonpath.patch @@ -0,0 +1,24 @@ +Don't remove sys.path entries that come from PYTHONPATH, or else the app cannot +be used in Nixpkgs. + +Author: Bjørn Forsman +diff -uNr spyder-5.4.0.orig/spyder/app/start.py spyder-5.4.0/spyder/app/start.py +--- spyder-5.4.0.orig/spyder/app/start.py 2022-08-30 02:02:28.000000000 +0200 ++++ spyder-5.4.0/spyder/app/start.py 2023-01-02 11:38:28.138744879 +0100 +@@ -6,16 +6,8 @@ + # (see spyder/__init__.py for details) + # ----------------------------------------------------------------------------- + +-# Remove PYTHONPATH paths from sys.path before other imports to protect against +-# shadowed standard libraries. + import os + import sys +-if os.environ.get('PYTHONPATH'): +- for path in os.environ['PYTHONPATH'].split(os.pathsep): +- try: +- sys.path.remove(path.rstrip(os.sep)) +- except ValueError: +- pass + + # Standard library imports + import ctypes