Merge pull request #126478 from dotlambda/notify-py-paths
python3Packages.notify-py: hardcode paths to aplay and notify-send
This commit is contained in:
commit
b9d925bd41
4 changed files with 124 additions and 16 deletions
|
@ -2,9 +2,11 @@
|
||||||
, buildPythonPackage
|
, buildPythonPackage
|
||||||
, fetchPypi
|
, fetchPypi
|
||||||
, pythonOlder
|
, pythonOlder
|
||||||
|
, dbus
|
||||||
, pytest
|
, pytest
|
||||||
|
, pytest-trio
|
||||||
|
, pytest-asyncio
|
||||||
, testpath
|
, testpath
|
||||||
, tornado
|
|
||||||
, trio
|
, trio
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
@ -12,30 +14,44 @@ buildPythonPackage rec {
|
||||||
pname = "jeepney";
|
pname = "jeepney";
|
||||||
version = "0.6.0";
|
version = "0.6.0";
|
||||||
|
|
||||||
disabled = pythonOlder "3.5";
|
disabled = pythonOlder "3.6";
|
||||||
|
|
||||||
src = fetchPypi {
|
src = fetchPypi {
|
||||||
inherit pname version;
|
inherit pname version;
|
||||||
sha256 = "7d59b6622675ca9e993a6bd38de845051d315f8b0c72cca3aef733a20b648657";
|
sha256 = "7d59b6622675ca9e993a6bd38de845051d315f8b0c72cca3aef733a20b648657";
|
||||||
};
|
};
|
||||||
|
|
||||||
propagatedBuildInputs = [
|
|
||||||
tornado
|
|
||||||
];
|
|
||||||
|
|
||||||
checkInputs = [
|
checkInputs = [
|
||||||
|
dbus
|
||||||
pytest
|
pytest
|
||||||
|
pytest-trio
|
||||||
|
pytest-asyncio
|
||||||
testpath
|
testpath
|
||||||
trio
|
trio
|
||||||
];
|
];
|
||||||
|
|
||||||
checkPhase = ''
|
checkPhase = ''
|
||||||
pytest
|
runHook preCheck
|
||||||
|
|
||||||
|
dbus-run-session --config-file=${dbus}/share/dbus-1/session.conf -- pytest
|
||||||
|
|
||||||
|
runHook postCheck
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
pythonImportsCheck = [
|
||||||
|
"jeepney"
|
||||||
|
"jeepney.auth"
|
||||||
|
"jeepney.io"
|
||||||
|
"jeepney.io.asyncio"
|
||||||
|
"jeepney.io.blocking"
|
||||||
|
"jeepney.io.threading"
|
||||||
|
"jeepney.io.trio"
|
||||||
|
];
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
homepage = "https://gitlab.com/takluyver/jeepney";
|
homepage = "https://gitlab.com/takluyver/jeepney";
|
||||||
description = "Pure Python DBus interface";
|
description = "Pure Python DBus interface";
|
||||||
license = licenses.mit;
|
license = licenses.mit;
|
||||||
|
maintainers = with maintainers; [ dotlambda ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
13
pkgs/development/python-modules/notify-py/darwin-paths.patch
Normal file
13
pkgs/development/python-modules/notify-py/darwin-paths.patch
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
diff --git a/notifypy/os_notifiers/macos.py b/notifypy/os_notifiers/macos.py
|
||||||
|
index 68731fb..53fcee3 100644
|
||||||
|
--- a/notifypy/os_notifiers/macos.py
|
||||||
|
+++ b/notifypy/os_notifiers/macos.py
|
||||||
|
@@ -75,7 +75,7 @@ class MacOSNotifier(BaseNotifier):
|
||||||
|
def _find_installed_afplay():
|
||||||
|
"""Function to find the path for afplay"""
|
||||||
|
try:
|
||||||
|
- run_which_for_aplay = subprocess.check_output(["which", "afplay"])
|
||||||
|
+ run_which_for_aplay = subprocess.check_output(["@which@", "afplay"])
|
||||||
|
return run_which_for_aplay.decode("utf-8")
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
logger.exception("Unable to find aplay.")
|
|
@ -1,5 +1,17 @@
|
||||||
{ lib, stdenv, buildPythonPackage, fetchFromGitHub, isPy3k, coreutils, alsa-utils
|
{ lib
|
||||||
, libnotify, which, jeepney, loguru, pytestCheckHook }:
|
, stdenv
|
||||||
|
, buildPythonPackage
|
||||||
|
, isPy3k
|
||||||
|
, fetchFromGitHub
|
||||||
|
, substituteAll
|
||||||
|
, alsa-utils
|
||||||
|
, libnotify
|
||||||
|
, which
|
||||||
|
, jeepney
|
||||||
|
, loguru
|
||||||
|
, pytestCheckHook
|
||||||
|
, coreutils
|
||||||
|
}:
|
||||||
|
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
pname = "notify-py";
|
pname = "notify-py";
|
||||||
|
@ -14,15 +26,28 @@ buildPythonPackage rec {
|
||||||
sha256 = "1n35adwsyhz304n4ifnsz6qzkymwhyqc8sg8d76qv5psv2xsnzlf";
|
sha256 = "1n35adwsyhz304n4ifnsz6qzkymwhyqc8sg8d76qv5psv2xsnzlf";
|
||||||
};
|
};
|
||||||
|
|
||||||
propagatedNativeBuildInputs = [ which ]
|
patches = lib.optionals stdenv.isLinux [
|
||||||
++ lib.optionals stdenv.isLinux [ alsa-utils libnotify ];
|
# hardcode paths to aplay and notify-send
|
||||||
|
(substituteAll {
|
||||||
|
src = ./linux-paths.patch;
|
||||||
|
aplay = "${alsa-utils}/bin/aplay";
|
||||||
|
notifysend = "${libnotify}/bin/notify-send";
|
||||||
|
})
|
||||||
|
] ++ lib.optionals stdenv.isDarwin [
|
||||||
|
# hardcode path to which
|
||||||
|
(substituteAll {
|
||||||
|
src = ./darwin-paths.patch;
|
||||||
|
which = "${which}/bin/which";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
propagatedBuildInputs = [ loguru ]
|
propagatedBuildInputs = [ loguru ]
|
||||||
++ lib.optionals stdenv.isLinux [ jeepney ];
|
++ lib.optionals stdenv.isLinux [ jeepney ];
|
||||||
|
|
||||||
checkInputs = [ coreutils pytestCheckHook ];
|
checkInputs = [ pytestCheckHook ];
|
||||||
|
|
||||||
# Tests search for "afplay" binary which is built in to MacOS and not available in nixpkgs
|
# Tests search for "afplay" binary which is built in to MacOS and not available in nixpkgs
|
||||||
preCheck = ''
|
preCheck = lib.optionalString stdenv.isDarwin ''
|
||||||
mkdir $TMP/bin
|
mkdir $TMP/bin
|
||||||
ln -s ${coreutils}/bin/true $TMP/bin/afplay
|
ln -s ${coreutils}/bin/true $TMP/bin/afplay
|
||||||
export PATH="$TMP/bin:$PATH"
|
export PATH="$TMP/bin:$PATH"
|
||||||
|
@ -31,9 +56,9 @@ buildPythonPackage rec {
|
||||||
pythonImportsCheck = [ "notifypy" ];
|
pythonImportsCheck = [ "notifypy" ];
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Python Module for sending cross-platform desktop notifications on Windows, macOS, and Linux.";
|
description = "Cross-platform desktop notification library for Python";
|
||||||
homepage = "https://github.com/ms7m/notify-py/";
|
homepage = "https://github.com/ms7m/notify-py";
|
||||||
license = licenses.mit;
|
license = licenses.mit;
|
||||||
maintainers = with maintainers; [ austinbutler ];
|
maintainers = with maintainers; [ austinbutler dotlambda ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
54
pkgs/development/python-modules/notify-py/linux-paths.patch
Normal file
54
pkgs/development/python-modules/notify-py/linux-paths.patch
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
diff --git a/notifypy/os_notifiers/linux.py b/notifypy/os_notifiers/linux.py
|
||||||
|
index ee89216..5201574 100644
|
||||||
|
--- a/notifypy/os_notifiers/linux.py
|
||||||
|
+++ b/notifypy/os_notifiers/linux.py
|
||||||
|
@@ -53,30 +53,12 @@ class LinuxNotifierLibNotify(BaseNotifier):
|
||||||
|
@staticmethod
|
||||||
|
def _find_installed_aplay():
|
||||||
|
"""Function to find the path for notify-send"""
|
||||||
|
- try:
|
||||||
|
- run_which_for_aplay = subprocess.check_output(["which", "aplay"])
|
||||||
|
- return run_which_for_aplay.decode("utf-8")
|
||||||
|
- except subprocess.CalledProcessError:
|
||||||
|
- logger.exception("Unable to find aplay.")
|
||||||
|
- return False
|
||||||
|
- except Exception:
|
||||||
|
- logger.exception("Unhandled exception for finding aplay.")
|
||||||
|
- return False
|
||||||
|
+ return "@aplay@"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _find_installed_notify_send():
|
||||||
|
"""Function to find the path for notify-send"""
|
||||||
|
- try:
|
||||||
|
- run_which_for_notify_send = subprocess.check_output(
|
||||||
|
- ["which", "notify-send"]
|
||||||
|
- )
|
||||||
|
- return run_which_for_notify_send.decode("utf-8")
|
||||||
|
- except subprocess.CalledProcessError:
|
||||||
|
- logger.exception("Unable to find notify-send.")
|
||||||
|
- return False
|
||||||
|
- except Exception:
|
||||||
|
- logger.exception("Unhandled exception for finding notify-send.")
|
||||||
|
- return False
|
||||||
|
+ return "@notifysend@"
|
||||||
|
|
||||||
|
def send_notification(
|
||||||
|
self,
|
||||||
|
@@ -159,15 +141,7 @@ class LinuxNotifier(BaseNotifier):
|
||||||
|
@staticmethod
|
||||||
|
def _find_installed_aplay():
|
||||||
|
"""Function to find the path for notify-send"""
|
||||||
|
- try:
|
||||||
|
- run_which_for_aplay = subprocess.check_output(["which", "aplay"])
|
||||||
|
- return run_which_for_aplay.decode("utf-8")
|
||||||
|
- except subprocess.CalledProcessError:
|
||||||
|
- logger.exception("Unable to find aplay.")
|
||||||
|
- return False
|
||||||
|
- except Exception:
|
||||||
|
- logger.exception("Unhandled exception for finding aplay.")
|
||||||
|
- return False
|
||||||
|
+ return "@aplay@"
|
||||||
|
|
||||||
|
def send_notification(
|
||||||
|
self,
|
Loading…
Reference in a new issue