mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-20 20:53:48 +00:00
4a7f99d55d
Part of: https://github.com/NixOS/nixpkgs/issues/108938 meta = with stdenv.lib; is a widely used pattern. We want to slowly remove the `stdenv.lib` indirection and encourage people to use `lib` directly. Thus let’s start with the meta field. This used a rewriting script to mostly automatically replace all occurances of this pattern, and add the `lib` argument to the package header if it doesn’t exist yet. The script in its current form is available at https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
74 lines
1.6 KiB
Nix
74 lines
1.6 KiB
Nix
{ lib, stdenv
|
|
, buildPythonPackage
|
|
, fetchurl
|
|
, isPy37
|
|
, isPy38
|
|
, isPy39
|
|
, python
|
|
, nvidia_x11
|
|
, addOpenGLRunpath
|
|
, future
|
|
, numpy
|
|
, patchelf
|
|
, pyyaml
|
|
, requests
|
|
, typing-extensions
|
|
}:
|
|
|
|
let
|
|
pyVerNoDot = builtins.replaceStrings [ "." ] [ "" ] python.pythonVersion;
|
|
platform = if stdenv.isDarwin then "darwin" else "linux";
|
|
srcs = import ./binary-hashes.nix version;
|
|
unsupported = throw "Unsupported system";
|
|
version = "1.7.1";
|
|
in buildPythonPackage {
|
|
inherit version;
|
|
|
|
pname = "pytorch";
|
|
# Don't forget to update pytorch to the same version.
|
|
|
|
format = "wheel";
|
|
|
|
disabled = !(isPy37 || isPy38 || isPy39);
|
|
|
|
src = fetchurl srcs."${stdenv.system}-${pyVerNoDot}" or unsupported;
|
|
|
|
nativeBuildInputs = [
|
|
addOpenGLRunpath
|
|
patchelf
|
|
];
|
|
|
|
propagatedBuildInputs = [
|
|
future
|
|
numpy
|
|
pyyaml
|
|
requests
|
|
typing-extensions
|
|
];
|
|
|
|
postInstall = ''
|
|
# ONNX conversion
|
|
rm -rf $out/bin
|
|
'';
|
|
|
|
postFixup = let
|
|
rpath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc.lib nvidia_x11 ];
|
|
in ''
|
|
find $out/${python.sitePackages}/torch/lib -type f \( -name '*.so' -or -name '*.so.*' \) | while read lib; do
|
|
echo "setting rpath for $lib..."
|
|
patchelf --set-rpath "${rpath}:$out/${python.sitePackages}/torch/lib" "$lib"
|
|
addOpenGLRunpath "$lib"
|
|
done
|
|
'';
|
|
|
|
pythonImportsCheck = [ "torch" ];
|
|
|
|
meta = with lib; {
|
|
description = "Open source, prototype-to-production deep learning platform";
|
|
homepage = "https://pytorch.org/";
|
|
license = licenses.unfree; # Includes CUDA and Intel MKL.
|
|
platforms = platforms.linux;
|
|
maintainers = with maintainers; [ danieldk ];
|
|
};
|
|
}
|