How to prevent pytorch from building from source

Makes sense, thank you

It finished building (took just over an hour) but now I’m having issues with setuptools_scm[toml]>=8 which is a dependency of SubPlz.

My current config is:

{
  pkgs,
  system,
  lib,
  ...
}: let
  buildPythonPackage = pkgs.python311Packages.buildPythonPackage;

  stable-ts = buildPythonPackage rec {
    pname = "stable-ts";
    version = "2.19.0";
    format = "setuptools";

    src = pkgs.fetchFromGitHub {
      owner = "jianfch";
      repo = "stable-ts";
      rev = "97b4bcd20df50ac79aee18b2d3ab4ceda753734f";
      hash = "sha256-EGkGct1l/PR3TO2/aa9OT1BPjhq2MJe9Gdq1gPSt+RA=";
    };

    doCheck = false;

    propagatedBuildInputs = with pkgs.python311Packages; [
      numpy
      # Might need not the bin
      torch
      torchaudio
      tqdm
      # Might need openai-whisper
      faster-whisper
    ];
  };

  subplz = buildPythonPackage rec {
    pname = "SubPlz";
    version = "1.4.0";
    #    format = "pyproject";

    doCheck = false;

    src = pkgs.fetchFromGitHub {
      owner = "kanjieater";
      repo = "SubPlz";
      rev = "7ce5671a3006a0e54d58b7f44651c97d593ae571";
      hash = "sha256-x5pBgRP20Y3RefE7lnawidY9trmizwo/9qGl81oHm8w=";
    };

    pypaBuildFlags = ["--skip-dependency-check"];

    pyproject = true;

    propagatedBuildInputs = with pkgs.python311Packages; [
      # Build dependencies
      setuptools
      setuptools-scm

      # SubPlz dependencies
      beautifulsoup4
      biopython
      ebooklib
      faster-whisper
      ffmpeg-python
      rapidfuzz
      numpy
      regex
      wcwidth
      natsort
      tqdm
      pysbd
      stable-ts
      ctranslate2
      stanza
    ];
  };
in {
  nixpkgs = {
    config = {
      cudaSupport = false;
      allowUnfree = true;
    };

    # Set ctranslate2 cuda support
    overlays = [
      (final: prev: {
        ctranslate2 = prev.ctranslate2.override {
          withCUDA = true;
          withCuDNN = true;
        };
        torchvision = prev.torchvision.override {
          withCUDA = true;
          withCuDNN = true;
        };
      })
    ];
  };

  nix = {
    package = pkgs.nix;
    settings = {
      cores = 6;
      max-jobs = 2;
      #      substituters = [
      #        "https://cachix.cachix.org"
      #        "https://nix-community.cachix.org"
      #      ];
      #      trusted-public-keys = [
      #        "cachix.cachix.org-1:eWNHQldwUO7G2VkjpnjDbWwy4KQ/HNxht7H4SSoMckM="
      #        "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
      #      ];
    };
  };

  home.packages = [
    (pkgs.python311.withPackages (
      p:
        with p; [
          subplz
        ]
    ))
  ];
}

Seems like this person had a very similar issue but I can’t seem to replicate their results.

Here’s the trace when trying to build:

yuki% home-manager switch --flake ~/.nix --show-trace
warning: Git tree '/home/safri/.nix' is dirty
warning: Git tree '/home/safri/.nix' is dirty
warning: Git tree '/home/safri/.nix' is dirty
warning: Git tree '/home/safri/.nix' is dirty
error: builder for '/nix/store/jk6m0xnl5qqp3firjpdpdj02gy33s8dw-python3.11-SubPlz-1.4.0.drv' failed with exit code 1;
       last 25 log lines:
       > adding 'subplz/sync.py'
       > adding 'subplz/test_align.py'
       > adding 'subplz/text.py'
       > adding 'subplz/transcribe.py'
       > adding 'subplz/utils.py'
       > adding 'subplz/alass/__init__.py'
       > adding 'subplz/alass/alass-linux64'
       > adding 'subplz/alass/alass.py'
       > adding 'subplz-2.0.0.dist-info/licenses/LICENSE'
       > adding 'subplz-2.0.0.dist-info/METADATA'
       > adding 'subplz-2.0.0.dist-info/WHEEL'
       > adding 'subplz-2.0.0.dist-info/entry_points.txt'
       > adding 'subplz-2.0.0.dist-info/top_level.txt'
       > adding 'subplz-2.0.0.dist-info/RECORD'
       > removing build/bdist.linux-x86_64/wheel
       > Successfully built subplz-2.0.0-py3-none-any.whl
       > Finished creating a wheel...
       > Finished executing pypaBuildPhase
       > Running phase: pythonRuntimeDepsCheckHook
       > Executing pythonRuntimeDepsCheck
       > Checking runtime dependencies for subplz-2.0.0-py3-none-any.whl
       >   - beautifulsoup4~=4.13.3 not satisfied by version 4.12.3
       >   - rapidfuzz~=3.12.1 not satisfied by version 3.13.0
       >   - numpy~=1.26.4 not satisfied by version 2.2.5
       >   - ctranslate2==4.4.0 not satisfied by version 4.6.0
       For full logs, run:
         nix log /nix/store/jk6m0xnl5qqp3firjpdpdj02gy33s8dw-python3.11-SubPlz-1.4.0.drv
error: 1 dependencies of derivation '/nix/store/9h8iw9l1pvnacj3nksdqqlqwaw6dbrrd-python3-3.11.13-env.drv' failed to build
error: 1 dependencies of derivation '/nix/store/snkh2b8g321lza8qycfjs7437bnmpk5z-home-manager-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/25bn5wawk1sfd888jxwvkqw07vw93bwc-home-manager-generation.drv' failed to build