1{ 2 lib, 3 buildPythonPackage, 4 fetchPypi, 5 pythonOlder, 6 cargo, 7 pkg-config, 8 rustPlatform, 9 rustc, 10 openssl, 11 setuptools-rust, 12 setuptools-scm, 13 interegular, 14 jsonschema, 15 datasets, 16 numpy, 17 pytestCheckHook, 18 pydantic, 19 scipy, 20 torch, 21 transformers, 22}: 23 24buildPythonPackage rec { 25 pname = "outlines-core"; 26 version = "0.1.26"; 27 pyproject = true; 28 29 disabled = pythonOlder "3.8"; 30 31 src = fetchPypi { 32 inherit version; 33 pname = "outlines_core"; 34 hash = "sha256-SBxDATQed8yPGDLWFnhK201GG0/sZYeOfA0sunFjoYk="; 35 }; 36 37 cargoDeps = rustPlatform.importCargoLock { 38 lockFile = ./Cargo.lock; 39 }; 40 41 postPatch = '' 42 cp --no-preserve=mode ${./Cargo.lock} Cargo.lock 43 ''; 44 45 nativeBuildInputs = [ 46 cargo 47 pkg-config 48 rustPlatform.cargoSetupHook 49 rustc 50 ]; 51 52 buildInputs = [ 53 openssl.dev 54 ]; 55 56 build-system = [ 57 setuptools-rust 58 setuptools-scm 59 ]; 60 61 dependencies = [ 62 interegular 63 jsonschema 64 ]; 65 66 optional-dependencies = { 67 tests = [ 68 datasets 69 numpy 70 pydantic 71 scipy 72 torch 73 transformers 74 ]; 75 }; 76 77 nativeCheckInputs = [ pytestCheckHook ] ++ lib.flatten (lib.attrValues optional-dependencies); 78 79 disabledTests = [ 80 # Tests that need to download from Hugging Face Hub. 81 "test_complex_serialization" 82 "test_create_fsm_index_tokenizer" 83 "test_reduced_vocabulary_with_rare_tokens" 84 ]; 85 86 pythonImportsCheck = [ "outlines_core" ]; 87 88 meta = { 89 description = "Structured text generation (core)"; 90 homepage = "https://github.com/outlines-dev/outlines-core"; 91 changelog = "https://github.com/dottxt-ai/outlines-core/releases/tag/${version}"; 92 license = lib.licenses.asl20; 93 maintainers = with lib.maintainers; [ danieldk ]; 94 }; 95}