Commit 5b0471b7 authored by Conroy Cheers's avatar Conroy Cheers
Browse files

python312Packages.xgrammar: 0.1.16 -> 0.1.19

parent 5238dd92
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
From c01e056ee845ae973ec36cc50125492ef8c02c12 Mon Sep 17 00:00:00 2001
From: Conroy Cheers <conroy@corncheese.org>
Date: Thu, 12 Jun 2025 17:45:27 +1000
Subject: [PATCH] [Fix] find nanobind from Python module

---
 cpp/nanobind/CMakeLists.txt | 4 ++++
 pyproject.toml              | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/cpp/nanobind/CMakeLists.txt b/cpp/nanobind/CMakeLists.txt
index 8ea5622..02500ac 100644
--- a/cpp/nanobind/CMakeLists.txt
+++ b/cpp/nanobind/CMakeLists.txt
@@ -3,6 +3,10 @@ find_package(
   COMPONENTS Interpreter Development.Module
   REQUIRED
 )
+
+execute_process(
+  COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
+  OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE nanobind_DIR)
 find_package(nanobind CONFIG REQUIRED)
 
 # Compile this source file seperately. Nanobind suggests to optimize bindings code for size, but
diff --git a/pyproject.toml b/pyproject.toml
index 11fae7d..d2078b1 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -44,7 +44,7 @@ provider = "scikit_build_core.metadata.regex"
 input = "python/xgrammar/version.py"
 
 [build-system]
-requires = ["scikit-build-core>=0.10.0", "nanobind==2.5.0"]
+requires = ["scikit-build-core>=0.10.0", "nanobind>=2.5.0"]
 build-backend = "scikit_build_core.build"
 
 [tool.scikit-build]
-- 
2.49.0
+13 −4
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
  # build-system
  cmake,
  ninja,
  pybind11,
  nanobind,
  scikit-build-core,

  # dependencies
@@ -25,7 +25,7 @@

buildPythonPackage rec {
  pname = "xgrammar";
  version = "0.1.14";
  version = "0.1.19";
  pyproject = true;

  src = fetchFromGitHub {
@@ -33,13 +33,17 @@ buildPythonPackage rec {
    repo = "xgrammar";
    tag = "v${version}";
    fetchSubmodules = true;
    hash = "sha256-ohsoc3g5XUp9vSXxyOGj20wXzCXZC02ktHYVQjDqNeM=";
    hash = "sha256-0b2tJx1D/2X/uosbthHfevUpTCBtuSKNlxOKyidTotA=";
  };

  patches = [
    ./0001-fix-find-nanobind-from-python-module.patch
  ];

  build-system = [
    cmake
    ninja
    pybind11
    nanobind
    scikit-build-core
  ];
  dontUseCmakeConfigure = true;
@@ -61,6 +65,11 @@ buildPythonPackage rec {
    writableTmpDirAsHomeHook
  ];

  NIX_CFLAGS_COMPILE = toString [
    # xgrammar hardcodes -flto=auto while using static linking, which can cause linker errors without this additional flag.
    "-ffat-lto-objects"
  ];

  disabledTests = [
    # You are trying to access a gated repo.
    "test_grammar_compiler"