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 <module>
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 <module>
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

+28
+4
pkgs/development/python-modules/spyder/default.nix
··· 56 56 hash = "sha256-kQBOYRXhjz+OQk7Vlxb/UKiDi92mA8ialsFQ+QzqhlE="; 57 57 }; 58 58 59 + patches = [ 60 + ./dont-clear-pythonpath.patch 61 + ]; 62 + 59 63 nativeBuildInputs = [ 60 64 pyqtwebengine.wrapQtAppsHook 61 65 ];
+24
pkgs/development/python-modules/spyder/dont-clear-pythonpath.patch
··· 1 + Don't remove sys.path entries that come from PYTHONPATH, or else the app cannot 2 + be used in Nixpkgs. 3 + 4 + Author: Bjørn Forsman <bjorn.forsman@gmail.com> 5 + diff -uNr spyder-5.4.0.orig/spyder/app/start.py spyder-5.4.0/spyder/app/start.py 6 + --- spyder-5.4.0.orig/spyder/app/start.py 2022-08-30 02:02:28.000000000 +0200 7 + +++ spyder-5.4.0/spyder/app/start.py 2023-01-02 11:38:28.138744879 +0100 8 + @@ -6,16 +6,8 @@ 9 + # (see spyder/__init__.py for details) 10 + # ----------------------------------------------------------------------------- 11 + 12 + -# Remove PYTHONPATH paths from sys.path before other imports to protect against 13 + -# shadowed standard libraries. 14 + import os 15 + import sys 16 + -if os.environ.get('PYTHONPATH'): 17 + - for path in os.environ['PYTHONPATH'].split(os.pathsep): 18 + - try: 19 + - sys.path.remove(path.rstrip(os.sep)) 20 + - except ValueError: 21 + - pass 22 + 23 + # Standard library imports 24 + import ctypes