1{ lib 2, stdenv 3, buildPythonPackage 4, fetchurl 5, python 6, pytorch-bin 7, pythonOlder 8, pythonAtLeast 9}: 10 11buildPythonPackage rec { 12 pname = "torchaudio"; 13 version = "0.10.0"; 14 format = "wheel"; 15 16 src = 17 let pyVerNoDot = lib.replaceStrings [ "." ] [ "" ] python.pythonVersion; 18 unsupported = throw "Unsupported system"; 19 srcs = (import ./binary-hashes.nix version)."${stdenv.system}-${pyVerNoDot}" or unsupported; 20 in fetchurl srcs; 21 22 disabled = ! (pythonAtLeast "3.7" && pythonOlder "3.10"); 23 24 propagatedBuildInputs = [ 25 pytorch-bin 26 ]; 27 28 # The wheel-binary is not stripped to avoid the error of `ImportError: libtorch_cuda_cpp.so: ELF load command address/offset not properly aligned.`. 29 dontStrip = true; 30 31 pythonImportsCheck = [ "torchaudio" ]; 32 33 postFixup = '' 34 # Note: after patchelf'ing, libcudart can still not be found. However, this should 35 # not be an issue, because PyTorch is loaded before torchvision and brings 36 # in the necessary symbols. 37 patchelf --set-rpath "${lib.makeLibraryPath [ stdenv.cc.cc.lib ]}:${pytorch-bin}/${python.sitePackages}/torch/lib:" \ 38 "$out/${python.sitePackages}/torchaudio/_torchaudio.so" 39 ''; 40 41 meta = with lib; { 42 description = "PyTorch audio library"; 43 homepage = "https://pytorch.org/"; 44 changelog = "https://github.com/pytorch/audio/releases/tag/v${version}"; 45 # Includes CUDA and Intel MKL, but redistributions of the binary are not limited. 46 # https://docs.nvidia.com/cuda/eula/index.html 47 # https://www.intel.com/content/www/us/en/developer/articles/license/onemkl-license-faq.html 48 license = licenses.bsd3; 49 platforms = platforms.linux; 50 maintainers = with maintainers; [ junjihashimoto ]; 51 }; 52}