1{ stdenv, lib, fetchPypi, buildPythonPackage, libvorbis, flac, libogg, libopus, opusfile }:
2
3buildPythonPackage rec {
4 pname = "PyOgg";
5 version = "0.6.2a1";
6
7 src = fetchPypi {
8 inherit pname version;
9 sha256 = "1mjh5zx7mfy246lya1qc42j4q4pz6v5zbd8blnfib9ncswcb1v6l";
10 };
11
12 buildInputs = [ libvorbis flac libogg libopus ];
13 propagatedBuidInputs = [ libvorbis flac libogg libopus opusfile ];
14 # There are no tests in this package.
15 doCheck = false;
16 postPatch = ''
17 substituteInPlace pyogg/vorbis.py --replace \
18 'libvorbisfile = ExternalLibrary.load("vorbisfile")' "libvorbisfile = ctypes.CDLL('${libvorbis}/lib/libvorbisfile${stdenv.hostPlatform.extensions.sharedLibrary}')"
19 substituteInPlace pyogg/vorbis.py --replace \
20 'libvorbisenc = ExternalLibrary.load("vorbisenc")' "libvorbisenc = ctypes.CDLL('${libvorbis}/lib/libvorbisenc${stdenv.hostPlatform.extensions.sharedLibrary}')"
21 substituteInPlace pyogg/vorbis.py --replace \
22 'libvorbis = ExternalLibrary.load("vorbis")' "libvorbis = ctypes.CDLL('${libvorbis}/lib/libvorbis${stdenv.hostPlatform.extensions.sharedLibrary}')"
23 substituteInPlace pyogg/flac.py --replace \
24 'libflac = ExternalLibrary.load("flac")' "libflac = ctypes.CDLL('${flac.out}/lib/libFLAC${stdenv.hostPlatform.extensions.sharedLibrary}')"
25 substituteInPlace pyogg/ogg.py --replace \
26 'libogg = ExternalLibrary.load("ogg")' "libogg = ctypes.CDLL('${libogg}/lib/libogg${stdenv.hostPlatform.extensions.sharedLibrary}')"
27 substituteInPlace pyogg/opus.py --replace \
28 'libopus = ExternalLibrary.load("opus")' "libopus = ctypes.CDLL('${libopus}/lib/libopus${stdenv.hostPlatform.extensions.sharedLibrary}')"
29 substituteInPlace pyogg/opus.py --replace \
30 'libopusfile = ExternalLibrary.load("opusfile")' "libopusfile = ctypes.CDLL('${opusfile}/lib/libopusfile${stdenv.hostPlatform.extensions.sharedLibrary}')"
31 '';
32
33 meta = {
34 description = "Xiph.org's Ogg Vorbis, Opus and FLAC for Python";
35 homepage = https://github.com/Zuzu-Typ/PyOgg;
36 license = lib.licenses.publicDomain;
37 maintainers = with lib.maintainers; [ pmiddend ];
38 };
39}