nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at r-updates 89 lines 1.8 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 6 # build-system 7 pybind11, 8 setuptools, 9 10 # dependencies 11 ctranslate2-cpp, 12 numpy, 13 pyyaml, 14 15 # tests 16 pytestCheckHook, 17 torch, 18 transformers, 19 writableTmpDirAsHomeHook, 20 wurlitzer, 21}: 22 23buildPythonPackage rec { 24 inherit (ctranslate2-cpp) pname version src; 25 pyproject = true; 26 27 # https://github.com/OpenNMT/CTranslate2/tree/master/python 28 sourceRoot = "${src.name}/python"; 29 30 postPatch = '' 31 substituteInPlace pyproject.toml \ 32 --replace-fail "pybind11==" "pybind11>=" 33 ''; 34 35 build-system = [ 36 pybind11 37 setuptools 38 ]; 39 40 buildInputs = [ ctranslate2-cpp ]; 41 42 dependencies = [ 43 numpy 44 pyyaml 45 ]; 46 47 cmakeFlags = [ "-DCMAKE_POLICY_VERSION_MINIMUM=3.5" ]; 48 49 pythonImportsCheck = [ 50 # https://opennmt.net/CTranslate2/python/overview.html 51 "ctranslate2" 52 "ctranslate2.converters" 53 "ctranslate2.models" 54 "ctranslate2.specs" 55 ]; 56 57 nativeCheckInputs = [ 58 pytestCheckHook 59 torch 60 transformers 61 writableTmpDirAsHomeHook 62 wurlitzer 63 ]; 64 65 preCheck = '' 66 # run tests against build result, not sources 67 rm -rf ctranslate2 68 ''; 69 70 disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [ 71 # Fatal Python error: Aborted 72 "test_invalid_model_path" 73 ]; 74 75 disabledTestPaths = [ 76 # TODO: ModuleNotFoundError: No module named 'opennmt' 77 "tests/test_opennmt_tf.py" 78 # OSError: We couldn't connect to 'https://huggingface.co' to load this file 79 "tests/test_transformers.py" 80 ]; 81 82 meta = { 83 description = "Fast inference engine for Transformer models"; 84 homepage = "https://github.com/OpenNMT/CTranslate2"; 85 changelog = "https://github.com/OpenNMT/CTranslate2/blob/${src.rev}/CHANGELOG.md"; 86 license = lib.licenses.mit; 87 maintainers = with lib.maintainers; [ hexa ]; 88 }; 89}