python312Packages.sentence-transformers: add optional-dependencies (#371955)

This commit is contained in:
Pol Dellaiera
2025-03-13 05:07:50 +01:00
committed by GitHub
2 changed files with 21 additions and 12 deletions
+1
View File
@@ -163,6 +163,7 @@ python312.pkgs.buildPythonApplication rec {
requests
restrictedpython
sentence-transformers
sentencepiece
soundfile
tiktoken
transformers
@@ -2,14 +2,17 @@
lib,
buildPythonPackage,
fetchFromGitHub,
pythonOlder,
# build-system
setuptools,
# dependencies
accelerate,
datasets,
huggingface-hub,
nltk,
numpy,
optimum,
pillow,
scikit-learn,
scipy,
sentencepiece,
@@ -19,8 +22,6 @@
transformers,
# tests
accelerate,
datasets,
pytestCheckHook,
pytest-cov-stub,
}:
@@ -30,6 +31,8 @@ buildPythonPackage rec {
version = "3.4.1";
pyproject = true;
disabled = pythonOlder "3.9";
src = fetchFromGitHub {
owner = "UKPLab";
repo = "sentence-transformers";
@@ -41,23 +44,28 @@ buildPythonPackage rec {
dependencies = [
huggingface-hub
nltk
numpy
pillow
scikit-learn
scipy
sentencepiece
tokenizers
torch
tqdm
transformers
];
optional-dependencies = {
train = [
accelerate
datasets
];
onnx = [ optimum ] ++ optimum.optional-dependencies.onnxruntime;
# onnx-gpu = [ optimum ] ++ optimum.optional-dependencies.onnxruntime-gpu;
# openvino = [ optimum-intel ] ++ optimum-intel.optional-dependencies.openvino;
};
nativeCheckInputs = [
accelerate
datasets
pytestCheckHook
pytest-cov-stub
];
pytestCheckHook
] ++ lib.flatten (builtins.attrValues optional-dependencies);
pythonImportsCheck = [ "sentence_transformers" ];