ansible-later: 2.0.22 -> 2.0.23
[NixPkgs.git] / pkgs / development / python-modules / torchvision / bin.nix
blobe1a0055af2609bf4a7e1b186774813d306c0ebbc
1 { lib
2 , stdenv
3 , buildPythonPackage
4 , fetchurl
5 , isPy37
6 , isPy38
7 , isPy39
8 , isPy310
9 , patchelf
10 , pillow
11 , python
12 , torch-bin
15 let
16   pyVerNoDot = builtins.replaceStrings [ "." ] [ "" ] python.pythonVersion;
17   srcs = import ./binary-hashes.nix version;
18   unsupported = throw "Unsupported system";
19   version = "0.13.1";
20 in buildPythonPackage {
21   inherit version;
23   pname = "torchvision";
25   format = "wheel";
27   src = fetchurl srcs."${stdenv.system}-${pyVerNoDot}" or unsupported;
29   disabled = !(isPy37 || isPy38 || isPy39 || isPy310);
31   nativeBuildInputs = [
32     patchelf
33   ];
35   propagatedBuildInputs = [
36     pillow
37     torch-bin
38   ];
40   # The wheel-binary is not stripped to avoid the error of `ImportError: libtorch_cuda_cpp.so: ELF load command address/offset not properly aligned.`.
41   dontStrip = true;
43   pythonImportsCheck = [ "torchvision" ];
45   postFixup = let
46     rpath = lib.makeLibraryPath [ stdenv.cc.cc.lib ];
47   in ''
48     # Note: after patchelf'ing, libcudart can still not be found. However, this should
49     #       not be an issue, because PyTorch is loaded before torchvision and brings
50     #       in the necessary symbols.
51     patchelf --set-rpath "${rpath}:${torch-bin}/${python.sitePackages}/torch/lib:" \
52       "$out/${python.sitePackages}/torchvision/_C.so"
53   '';
55   meta = with lib; {
56     description = "PyTorch vision library";
57     homepage = "https://pytorch.org/";
58     changelog = "https://github.com/pytorch/vision/releases/tag/v${version}";
59     # Includes CUDA and Intel MKL, but redistributions of the binary are not limited.
60     # https://docs.nvidia.com/cuda/eula/index.html
61     # https://www.intel.com/content/www/us/en/developer/articles/license/onemkl-license-faq.html
62     license = licenses.bsd3;
63     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
64     platforms = platforms.linux;
65     maintainers = with maintainers; [ junjihashimoto ];
66   };