Skip to content

Commit

Permalink
python3Packages.soundcard: init at 0.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdotsh committed Aug 2, 2024
1 parent 29c6f7d commit b74c97b
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
50 changes: 50 additions & 0 deletions pkgs/development/python-modules/soundcard/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
buildPythonPackage,
cffi,
fetchPypi,
lib,
libpulseaudio,
numpy,
setuptools,
testers,
}:
let
version = "0.4.3";
in
buildPythonPackage {
inherit version;
pname = "soundcard";
pyproject = true;

src = fetchPypi {
inherit version;
pname = "SoundCard";
hash = "sha256-QQg1UUuhCAmAPLmIfUJw85K1nq82WRW7lFFq8/ix0Dc=";
};

patchPhase = ''
substituteInPlace soundcard/pulseaudio.py \
--replace "'pulse'" "'${libpulseaudio}/lib/libpulse.so'"
'';

build-system = [ setuptools ];

dependencies = [
cffi
numpy
];

# doesn't work because there are not many soundcards in the
# sandbox. See VM-test
# pythonImportsCheck = [ "soundcard" ];

passthru.tests.vm-with-soundcard = testers.runNixOSTest ./test.nix;

meta = {
description = "Pure-Python Real-Time Audio Library";
homepage = "https://github.com/bastibe/SoundCard";
changelog = "https://github.com/bastibe/SoundCard/blob/${version}/README.rst#changelog";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ matthiasdotsh ];
};
}
47 changes: 47 additions & 0 deletions pkgs/development/python-modules/soundcard/test.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
name = "Python Soundcard Library Test";

nodes.machine =
{ pkgs, ... }:
{
environment.systemPackages = [ (pkgs.python3.withPackages (ps: [ ps.soundcard ])) ];

hardware.pulseaudio.enable = true;
hardware.pulseaudio.systemWide = true;

virtualisation.qemu.options = [
"-device virtio-sound-pci,audiodev=my_audiodev"
"-audiodev wav,id=my_audiodev"
];
};

interactive.nodes.machine =
{ ... }:
{
services.openssh.enable = true;
services.openssh.settings.PermitRootLogin = "yes";
users.extraUsers.root.initialPassword = "";
users.extraUsers.root.hashedPassword = null;
users.extraUsers.root.hashedPasswordFile = null;
users.extraUsers.root.initialHashedPassword = null;
virtualisation.forwardPorts = [
{
from = "host";
host.port = 2222;
guest.port = 22;
}
];
};

testScript =
let
script = builtins.toFile "import.py" ''
import soundcard
'';
in
''
start_all()
machine.wait_for_unit("multi-user.target")
machine.succeed("python ${script}")
'';
}
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14562,6 +14562,8 @@ self: super: with self; {

sortedcontainers = callPackage ../development/python-modules/sortedcontainers { };

soundcard = callPackage ../development/python-modules/soundcard { };

soundcloud-v2 = callPackage ../development/python-modules/soundcloud-v2 { };

sounddevice = callPackage ../development/python-modules/sounddevice { };
Expand Down

0 comments on commit b74c97b

Please sign in to comment.