From 9225072017ae20814d8e567c8a22e2d82ae1bc63 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Mon, 17 Feb 2025 17:29:15 +0100 Subject: [PATCH] python312Packages.xgrammar: 0.1.11 -> 0.1.14 Diff: https://github.com/mlc-ai/xgrammar/compare/refs/tags/v0.1.11...v0.1.14 Changelog: https://github.com/mlc-ai/xgrammar/releases/tag/v0.1.14 --- .../python-modules/xgrammar/default.nix | 77 +++++++++---------- 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/pkgs/development/python-modules/xgrammar/default.nix b/pkgs/development/python-modules/xgrammar/default.nix index b422e74bc023..d97fac3743e3 100644 --- a/pkgs/development/python-modules/xgrammar/default.nix +++ b/pkgs/development/python-modules/xgrammar/default.nix @@ -3,57 +3,63 @@ stdenv, buildPythonPackage, fetchFromGitHub, + + # build-system cmake, ninja, - pip, - pytestCheckHook, - python3, pybind11, + scikit-build-core, + + # dependencies pydantic, sentencepiece, tiktoken, torch, transformers, triton, + + # tests + pytestCheckHook, + writableTmpDirAsHomeHook, }: buildPythonPackage rec { pname = "xgrammar"; - version = "0.1.11"; - format = "other"; + version = "0.1.14"; + pyproject = true; src = fetchFromGitHub { owner = "mlc-ai"; - repo = pname; + repo = "xgrammar"; tag = "v${version}"; - hash = "sha256-q5d8/9S9p9M8HlCIernT9IwPEDnbC1R9nGsLuS15RXY="; fetchSubmodules = true; + hash = "sha256-ohsoc3g5XUp9vSXxyOGj20wXzCXZC02ktHYVQjDqNeM="; }; - nativeBuildInputs = [ + build-system = [ cmake ninja + pybind11 + scikit-build-core ]; + dontUseCmakeConfigure = true; - buildInputs = [ pip ]; + dependencies = + [ + pydantic + sentencepiece + tiktoken + torch + transformers + ] + ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isx86_64) [ + triton + ]; - dontUseNinjaInstall = true; - - installPhase = '' - runHook preInstall - - cd ../python - ${python3.interpreter} -m pip install --prefix=$out . - cd .. - - runHook postInstall - ''; - - nativeCheckInputs = [ pytestCheckHook ]; - - preCheck = '' - cd tests/python/ - ''; + nativeCheckInputs = [ + pytestCheckHook + writableTmpDirAsHomeHook + ]; disabledTests = [ # You are trying to access a gated repo. @@ -64,27 +70,18 @@ buildPythonPackage rec { "test_grammar_matcher_json_schema" "test_grammar_matcher_tag_dispatch" "test_regex_converter" + "test_tokenizer_info" + # Torch not compiled with CUDA enabled "test_token_bitmask_operations" - # You are trying to access a gated repo. - "test_tokenizer_info" ]; pythonImportsCheck = [ "xgrammar" ]; - dependencies = [ - pybind11 - pydantic - sentencepiece - tiktoken - torch - transformers - triton - ]; - - meta = with lib; { + meta = { description = "Efficient, Flexible and Portable Structured Generation"; homepage = "https://xgrammar.mlc.ai"; - license = licenses.asl20; + changelog = "https://github.com/mlc-ai/xgrammar/releases/tag/v${version}"; + license = lib.licenses.asl20; }; }