python3Packages.notify-py: hardcode paths to aplay, notify-send, and which

+101 -9
+13
pkgs/development/python-modules/notify-py/darwin-paths.patch
··· 1 + diff --git a/notifypy/os_notifiers/macos.py b/notifypy/os_notifiers/macos.py 2 + index 68731fb..53fcee3 100644 3 + --- a/notifypy/os_notifiers/macos.py 4 + +++ b/notifypy/os_notifiers/macos.py 5 + @@ -75,7 +75,7 @@ class MacOSNotifier(BaseNotifier): 6 + def _find_installed_afplay(): 7 + """Function to find the path for afplay""" 8 + try: 9 + - run_which_for_aplay = subprocess.check_output(["which", "afplay"]) 10 + + run_which_for_aplay = subprocess.check_output(["@which@", "afplay"]) 11 + return run_which_for_aplay.decode("utf-8") 12 + except subprocess.CalledProcessError: 13 + logger.exception("Unable to find aplay.")
+34 -9
pkgs/development/python-modules/notify-py/default.nix
··· 1 - { lib, stdenv, buildPythonPackage, fetchFromGitHub, isPy3k, coreutils, alsa-utils 2 - , libnotify, which, jeepney, loguru, pytestCheckHook }: 1 + { lib 2 + , stdenv 3 + , buildPythonPackage 4 + , isPy3k 5 + , fetchFromGitHub 6 + , substituteAll 7 + , alsa-utils 8 + , libnotify 9 + , which 10 + , jeepney 11 + , loguru 12 + , pytestCheckHook 13 + , coreutils 14 + }: 3 15 4 16 buildPythonPackage rec { 5 17 pname = "notify-py"; ··· 14 26 sha256 = "1n35adwsyhz304n4ifnsz6qzkymwhyqc8sg8d76qv5psv2xsnzlf"; 15 27 }; 16 28 17 - propagatedNativeBuildInputs = [ which ] 18 - ++ lib.optionals stdenv.isLinux [ alsa-utils libnotify ]; 29 + patches = lib.optionals stdenv.isLinux [ 30 + # hardcode paths to aplay and notify-send 31 + (substituteAll { 32 + src = ./linux-paths.patch; 33 + aplay = "${alsa-utils}/bin/aplay"; 34 + notifysend = "${libnotify}/bin/notify-send"; 35 + }) 36 + ] ++ lib.optionals stdenv.isDarwin [ 37 + # hardcode path to which 38 + (substituteAll { 39 + src = ./darwin-paths.patch; 40 + which = "${which}/bin/which"; 41 + }) 42 + ]; 43 + 19 44 propagatedBuildInputs = [ loguru ] 20 45 ++ lib.optionals stdenv.isLinux [ jeepney ]; 21 46 22 - checkInputs = [ coreutils pytestCheckHook ]; 47 + checkInputs = [ pytestCheckHook ]; 23 48 24 49 # Tests search for "afplay" binary which is built in to MacOS and not available in nixpkgs 25 - preCheck = '' 50 + preCheck = lib.optionalString stdenv.isDarwin '' 26 51 mkdir $TMP/bin 27 52 ln -s ${coreutils}/bin/true $TMP/bin/afplay 28 53 export PATH="$TMP/bin:$PATH" ··· 31 56 pythonImportsCheck = [ "notifypy" ]; 32 57 33 58 meta = with lib; { 34 - description = "Python Module for sending cross-platform desktop notifications on Windows, macOS, and Linux."; 35 - homepage = "https://github.com/ms7m/notify-py/"; 59 + description = "Cross-platform desktop notification library for Python"; 60 + homepage = "https://github.com/ms7m/notify-py"; 36 61 license = licenses.mit; 37 - maintainers = with maintainers; [ austinbutler ]; 62 + maintainers = with maintainers; [ austinbutler dotlambda ]; 38 63 }; 39 64 }
+54
pkgs/development/python-modules/notify-py/linux-paths.patch
··· 1 + diff --git a/notifypy/os_notifiers/linux.py b/notifypy/os_notifiers/linux.py 2 + index ee89216..5201574 100644 3 + --- a/notifypy/os_notifiers/linux.py 4 + +++ b/notifypy/os_notifiers/linux.py 5 + @@ -53,30 +53,12 @@ class LinuxNotifierLibNotify(BaseNotifier): 6 + @staticmethod 7 + def _find_installed_aplay(): 8 + """Function to find the path for notify-send""" 9 + - try: 10 + - run_which_for_aplay = subprocess.check_output(["which", "aplay"]) 11 + - return run_which_for_aplay.decode("utf-8") 12 + - except subprocess.CalledProcessError: 13 + - logger.exception("Unable to find aplay.") 14 + - return False 15 + - except Exception: 16 + - logger.exception("Unhandled exception for finding aplay.") 17 + - return False 18 + + return "@aplay@" 19 + 20 + @staticmethod 21 + def _find_installed_notify_send(): 22 + """Function to find the path for notify-send""" 23 + - try: 24 + - run_which_for_notify_send = subprocess.check_output( 25 + - ["which", "notify-send"] 26 + - ) 27 + - return run_which_for_notify_send.decode("utf-8") 28 + - except subprocess.CalledProcessError: 29 + - logger.exception("Unable to find notify-send.") 30 + - return False 31 + - except Exception: 32 + - logger.exception("Unhandled exception for finding notify-send.") 33 + - return False 34 + + return "@notifysend@" 35 + 36 + def send_notification( 37 + self, 38 + @@ -159,15 +141,7 @@ class LinuxNotifier(BaseNotifier): 39 + @staticmethod 40 + def _find_installed_aplay(): 41 + """Function to find the path for notify-send""" 42 + - try: 43 + - run_which_for_aplay = subprocess.check_output(["which", "aplay"]) 44 + - return run_which_for_aplay.decode("utf-8") 45 + - except subprocess.CalledProcessError: 46 + - logger.exception("Unable to find aplay.") 47 + - return False 48 + - except Exception: 49 + - logger.exception("Unhandled exception for finding aplay.") 50 + - return False 51 + + return "@aplay@" 52 + 53 + def send_notification( 54 + self,