Unverified Commit 77ab93a3 authored by Madoura's avatar Madoura
Browse files

python3Packages.fairseq: fix python 3.11 build

parent 96619a09
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
, buildPythonPackage
, pythonOlder
, fetchFromGitHub
, fetchpatch

# Native build inputs
, cython
@@ -27,12 +28,12 @@
, hypothesis
, pytestCheckHook
}:
let

buildPythonPackage rec {
  pname = "fairseq";
  version = "0.12.3";
in
buildPythonPackage rec {
  inherit version pname;
  pyproject = true;
  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "pytorch";
@@ -41,17 +42,25 @@ buildPythonPackage rec {
    hash = "sha256-XX/grU5ljQCwx33miGoFc/7Uj9fZDtmhm4Fz7L4U+Bc=";
  };

  disabled = pythonOlder "3.7";
  patches = [
    # https://github.com/facebookresearch/fairseq/pull/5359
    (fetchpatch {
      url = "https://github.com/facebookresearch/fairseq/commit/2fa0768c2115b0a4c207cfa3e1b3e4ff3ad9a00c.patch";
      hash = "sha256-aYYP/knQX6q6vhyA6q9uOOYfRhDAuJCo9QJWfFEDuuA=";
    })
  ];

  nativeBuildInputs = [
    cython
    pythonRelaxDepsHook
    which
  ];

  pythonRelaxDeps = [
    "hydra-core"
    "omegaconf"
  ];

  propagatedBuildInputs = [
    cffi
    hydra-core
@@ -74,6 +83,7 @@ buildPythonPackage rec {
  ];

  pythonImportsCheck = [ "fairseq" ];

  preCheck = ''
    export HOME=$TMPDIR
    cd tests
@@ -82,6 +92,7 @@ buildPythonPackage rec {
  pytestFlagsArray = [
    "--import-mode append"
  ];

  disabledTests = [
    # this test requires xformers
    "test_xformers_single_forward_parity"
@@ -96,6 +107,11 @@ buildPythonPackage rec {
    "test_librispeech_s2t_conformer_s_checkpoint"
  ];

  disabledTestPaths = [
    # ValueError: mutable default ... for field bar is not allowed: use default_factory
    "test_dataclass_utils.py"
  ];

  meta = with lib; {
    description = "Facebook AI Research Sequence-to-Sequence Toolkit";
    homepage = "https://github.com/pytorch/fairseq";