Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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 build-system = [ 31 pybind11 32 setuptools 33 ]; 34 35 buildInputs = [ ctranslate2-cpp ]; 36 37 dependencies = [ 38 numpy 39 pyyaml 40 ]; 41 42 cmakeFlags = [ "-DCMAKE_POLICY_VERSION_MINIMUM=3.5" ]; 43 44 pythonImportsCheck = [ 45 # https://opennmt.net/CTranslate2/python/overview.html 46 "ctranslate2" 47 "ctranslate2.converters" 48 "ctranslate2.models" 49 "ctranslate2.specs" 50 ]; 51 52 nativeCheckInputs = [ 53 pytestCheckHook 54 torch 55 transformers 56 writableTmpDirAsHomeHook 57 wurlitzer 58 ]; 59 60 preCheck = '' 61 # run tests against build result, not sources 62 rm -rf ctranslate2 63 ''; 64 65 disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [ 66 # Fatal Python error: Aborted 67 "test_invalid_model_path" 68 ]; 69 70 disabledTestPaths = [ 71 # TODO: ModuleNotFoundError: No module named 'opennmt' 72 "tests/test_opennmt_tf.py" 73 # OSError: We couldn't connect to 'https://huggingface.co' to load this file 74 "tests/test_transformers.py" 75 ]; 76 77 meta = { 78 description = "Fast inference engine for Transformer models"; 79 homepage = "https://github.com/OpenNMT/CTranslate2"; 80 changelog = "https://github.com/OpenNMT/CTranslate2/blob/${src.rev}/CHANGELOG.md"; 81 license = lib.licenses.mit; 82 maintainers = with lib.maintainers; [ hexa ]; 83 }; 84}