nix-community / vs-overlay

Overlay with VapourSynth plugins packaged for Nix
MIT License
12 stars 6 forks source link

havsfunc r33 too old #11

Closed sshiroi closed 1 year ago

sshiroi commented 2 years ago

When trying to use QTGMC I get the error:

vapoursynth.Error: Analyse: Function does not take argument(s) named _lambda, _global

This is fixed in master.

But this also add vsutil as dependecy which seems to break the checkPhase of havsfunc and vsTAAAmbk. Relevant line from failing build:

> Found duplicated packages in closure for dependency 'vsutil':
>   vsutil 0.6.0 (/nix/store/04gah7vydfxzy3aqmpmhixmajvbxayyh-vapoursynth-59-with-plugins/lib/python3.10/site-packages)
>   vsutil 0.6.0 (/nix/store/jf48qi1j625nw0z5ib3drq2pmyg42b39-python3.10-vsutil-unstable-2021-10-23/lib/python3.10/site-packages)

Commenting out the checkphase seems to make it build and work properly.

  version = "unstable-2022-09-08";
  src = fetchFromGitHub {
    owner = "HomeOfVapourSynthEvolution";
    repo = pname;
    rev = "2c6d3fedc3c4c3f3ed2460f7014d1227fe2fe207";
    sha256 = "sha256-YJl/X9niJelgovwUK6S50lvQUe/yYAbXEHWBbMqfXz0=";
  };
sbruder commented 2 years ago

But this also add vsutil as dependecy which seems to break the checkPhase of havsfunc and vsTAAAmbk. Relevant line from failing build:

> Found duplicated packages in closure for dependency 'vsutil':
>   vsutil 0.6.0 (/nix/store/04gah7vydfxzy3aqmpmhixmajvbxayyh-vapoursynth-59-with-plugins/lib/python3.10/site-packages)
>   vsutil 0.6.0 (/nix/store/jf48qi1j625nw0z5ib3drq2pmyg42b39-python3.10-vsutil-unstable-2021-10-23/lib/python3.10/site-packages)

That’s exactly the issue I was facing a few days ago, which I couldn’t fix yet. The problem in general is that for checking, we need to use vapoursynth’s withPlugins feature to allow the tests to access native plugins. Currently, however, this also includes python modules, which can lead to duplicate packages. I’ll open an issue on this in the future and hopefully think of some solution to this.

sshiroi commented 2 years ago

If I understand the problem correctly, passing the native dependecys along manually like this should fix it. This would add quite a bit of boilerplate though. Also I don't want to rush anything, I'd rather wait for you to come up with a proper solution.

Edit: This one liner replacing checkInputs would do the same thing but better.

checkInputs = [ (vapoursynth.withPlugins (builtins.filter (a: !(builtins.hasAttr "isBuildPythonPackage" a.meta)) propagatedBuildInputs)) ];
{ lib, buildPythonPackage, stdenv, runCommand, fetchFromGitHub, vapoursynthPlugins, python, vapoursynth }:
let
  our_plugins_native = with vapoursynthPlugins; [
    addgrain
    adjust
    bm3d
    cas
    ctmf
    dctfilter
    deblock
    dfttest
    eedi2
    eedi3m
    fft3dfilter
    fluxsmooth
    fmtconv
    fmtconv
    hqdn3d
    knlmeanscl
    miscfilters-obsolete
    mvsfunc
    mvtools
    nnedi3
    nnedi3cl
    sangnom
    ttempsmooth
    znedi3
  ];
  our_plugins_python = with vapoursynthPlugins; [
    vsutil
  ];
in
buildPythonPackage rec {
  pname = "havsfunc";
  version = "unstable-2022-09-08";
  src = fetchFromGitHub {
    owner = "HomeOfVapourSynthEvolution";
    repo = pname;
    rev = "2c6d3fedc3c4c3f3ed2460f7014d1227fe2fe207";
    sha256 = "sha256-YJl/X9niJelgovwUK6S50lvQUe/yYAbXEHWBbMqfXz0=";
  };

  plugins_native = our_plugins_native;

  propagatedBuildInputs = our_plugins_native ++ our_plugins_python;

  format = "other";

  installPhase = ''
    install -D havsfunc.py $out/${python.sitePackages}/havsfunc.py
  '';

  checkInputs = [ (vapoursynth.withPlugins plugins_native ) ];
  checkPhase = ''
    PYTHONPATH=$out/${python.sitePackages}:$PYTHONPATH
  '';
  pythonImportsCheck = [ "havsfunc" ];

  meta = with lib; {
    description = "Holy’s ported AviSynth functions for VapourSynth";
    homepage = "https://github.com/HomeOfVapourSynthEvolution/havsfunc";
    license = licenses.unfree; # no license
    maintainers = with maintainers; [ sbruder ];
    platforms = platforms.all;
  };
}
{ lib, buildPythonPackage, stdenv, runCommand, fetchFromGitHub, vapoursynthPlugins, python, vapoursynth }:
let
  our_plugins_native = with vapoursynthPlugins; [
    awarpsharp2
    cas
    eedi2
    eedi3m
    fmtconv
    msmoosh
    mvsfunc
    mvtools
    nnedi3
    nnedi3cl
    removegrain
    sangnom
    tcanny
    znedi3
  ];
 our_plugins_python = with vapoursynthPlugins; [
    havsfunc
    mvsfunc
  ];
in
buildPythonPackage rec {
  pname = "vsTAAmbk";
  version = "0.8.1";

  src = fetchFromGitHub {
    owner = "HomeOfVapourSynthEvolution";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-KfU2f7tBhw007f4RmVruV3Pkgo1zdA4o43+1lL/ohKo=";
  };

  patches = [
    ./0001-Skip-OpenCL-test.patch
    ./0002-Use-format-IDs-from-VapourSynth-R55.patch
  ];

  plugins_native = our_plugins_native ++ vapoursynthPlugins.havsfunc.plugins_native;

  propagatedBuildInputs = our_plugins_native ++ our_plugins_python;

  format = "other";

  installPhase = ''
    install -D vsTAAmbk.py $out/${python.sitePackages}/vsTAAmbk.py
  '';

  checkInputs = [ (vapoursynth.withPlugins plugins_native) ];
  checkPhase = ''
    PYTHONPATH=$out/${python.sitePackages}:$PYTHONPATH
    python3 test/vsTAAmbkTestCase.py
  '';

  meta = with lib; {
    description = "An Anti-aliasing script for VapourSynth ported from Avisynth";
    homepage = "https://github.com/HomeOfVapourSynthEvolution/vsTAAmbk";
    license = licenses.unfree; # no license
    maintainers = with maintainers; [ sbruder ];
    platforms = platforms.all;
  };
}