Unverified Commit 3f232237 authored by natsukium's avatar natsukium
Browse files

python311Packages.supervise-api: refactor

parent 2d4aaaf7
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -3,39 +3,43 @@
, fetchPypi
, substituteAll
, supervise
, isPy3k
, whichcraft
, util-linux
, setuptools
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "supervise-api";
  version = "0.6.0";
  pyproject = true;

  src = fetchPypi {
    pname = "supervise_api";
    inherit version;
    sha256 = "1230f42294910e83421b7d3b08a968d27d510a4a709e966507ed70db5da1b9de";
    hash = "sha256-EjD0IpSRDoNCG307CKlo0n1RCkpwnpZlB+1w212hud4=";
  };

  patches = [
    (substituteAll {
      src = ./supervise-path.patch;
      inherit supervise;
    })
  ];
  postPatch = ''
    substituteInPlace supervise_api/supervise.py \
      --replace 'which("supervise")' '"${supervise}/bin/supervise"'
  '';

  # In the git repo, supervise_api lives inside a python subdir
  patchFlags = [ "-p2" ];
  nativeBuildInputs = [
    setuptools
  ];

  propagatedBuildInputs = lib.optional (!isPy3k) whichcraft;
  nativeCheckInputs = [
    pytestCheckHook
  ];

  nativeCheckInputs = [ util-linux ];
  pythonImportsCheck = [
    "supervise_api"
  ];

  meta = {
    description = "An API for running processes safely and securely";
    homepage = "https://github.com/catern/supervise";
    license = lib.licenses.lgpl3;
    license = lib.licenses.mit;
    platforms = lib.platforms.linux;
    maintainers = with lib.maintainers; [ catern ];
  };
}
+0 −15
Original line number Diff line number Diff line
diff --git a/python/supervise_api/supervise.py b/python/supervise_api/supervise.py
index 497d3ea..be57e35 100644
--- a/python/supervise_api/supervise.py
+++ b/python/supervise_api/supervise.py
@@ -41,9 +41,7 @@ try:
 except:
     from whichcraft import which
 
-supervise_utility_location = which("supervise")
-if not supervise_utility_location:
-    raise FileNotFoundError(errno.ENOENT, "Executable not found in PATH", "supervise")
+supervise_utility_location = '@supervise@/bin/supervise'
 
 
 def ignore_sigchld():