Commit 76612602 authored by Gaetan Lepage's avatar Gaetan Lepage
Browse files
parent 6e77d59a
Loading
Loading
Loading
Loading
+1170 −403

File changed.

Preview size limit exceeded, changes collapsed.

+39 −11
Original line number Diff line number Diff line
{
  lib,
  buildPythonPackage,
  fetchPypi,
  pythonOlder,
  fetchFromGitHub,

  # nativeBuildInputs
  cargo,
  pkg-config,
  rustPlatform,
  rustc,

  # buildInputs
  openssl,

  # build-system
  setuptools-rust,
  setuptools-scm,

  # dependencies
  interegular,
  jsonschema,

  # optional-dependencies
  datasets,
  numpy,
  pytestCheckHook,
  pydantic,
  scipy,
  torch,
  transformers,

  # tests
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "outlines-core";
  version = "0.1.26";
  pyproject = true;
  version = "0.2.11";

  disabled = pythonOlder "3.8";
  pyproject = true;

  src = fetchPypi {
    inherit version;
    pname = "outlines_core";
    hash = "sha256-SBxDATQed8yPGDLWFnhK201GG0/sZYeOfA0sunFjoYk=";
  src = fetchFromGitHub {
    owner = "dottxt-ai";
    repo = "outlines-core";
    tag = version;
    hash = "sha256-lLMTHFytJT2MhnzT0RlRCaSBPijA81fjxUqx4IGfVo8=";
  };

  cargoDeps = rustPlatform.importCargoLock {
@@ -39,6 +50,11 @@ buildPythonPackage rec {
  };

  postPatch = ''
    substituteInPlace Cargo.toml \
      --replace-fail \
        'version = "0.0.0"' \
        'version = "${version}"'

    cp --no-preserve=mode ${./Cargo.lock} Cargo.lock
  '';

@@ -46,6 +62,7 @@ buildPythonPackage rec {
    cargo
    pkg-config
    rustPlatform.cargoSetupHook
    rustPlatform.maturinBuildHook
    rustc
  ];

@@ -74,16 +91,27 @@ buildPythonPackage rec {
    ];
  };

  pythonImportsCheck = [ "outlines_core" ];

  preCheck = ''
    rm -rf outlines_core
  '';

  nativeCheckInputs = [ pytestCheckHook ] ++ lib.flatten (lib.attrValues optional-dependencies);

  disabledTests = [
    # Tests that need to download from Hugging Face Hub.
    "test_complex_serialization"
    "test_create_fsm_index_tokenizer"
    "test_from_pretrained"
    "test_pickling_from_pretrained_with_revision"
    "test_reduced_vocabulary_with_rare_tokens"
  ];

  pythonImportsCheck = [ "outlines_core" ];
  disabledTestPaths = [
    # Downloads from Hugging Face Hub
    "tests/test_kernels.py"
  ];

  meta = {
    description = "Structured text generation (core)";