Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 07 Apr 2026 09:58:15 +0000
From:      Yuri Victorovich <yuri@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 56eb0aed6ba0 - main - misc/py-xgrammar: New port: Efficient, flexible and portable structured generation
Message-ID:  <69d4d537.47e3e.120d9ef9@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=56eb0aed6ba0d037ccd31cdc85411645ee84b5af

commit 56eb0aed6ba0d037ccd31cdc85411645ee84b5af
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2026-04-06 21:47:35 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2026-04-07 09:58:07 +0000

    misc/py-xgrammar: New port: Efficient, flexible and portable structured generation
---
 misc/Makefile                               |  1 +
 misc/py-xgrammar/Makefile                   | 32 +++++++++++++++++++++++++++++
 misc/py-xgrammar/distinfo                   |  3 +++
 misc/py-xgrammar/files/patch-pyproject.toml | 11 ++++++++++
 misc/py-xgrammar/pkg-descr                  |  3 +++
 5 files changed, 50 insertions(+)

diff --git a/misc/Makefile b/misc/Makefile
index c0cb043cbb64..5a31e2d54906 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -622,6 +622,7 @@
     SUBDIR += py-wurlitzer
     SUBDIR += py-xformers
     SUBDIR += py-xgboost
+    SUBDIR += py-xgrammar
     SUBDIR += pyobd
     SUBDIR += pytorch
     SUBDIR += qbrew
diff --git a/misc/py-xgrammar/Makefile b/misc/py-xgrammar/Makefile
new file mode 100644
index 000000000000..5bb4182f3db0
--- /dev/null
+++ b/misc/py-xgrammar/Makefile
@@ -0,0 +1,32 @@
+PORTNAME=	xgrammar
+DISTVERSION=	0.1.33
+CATEGORIES=	misc python # machine-learning
+MASTER_SITES=	PYPI
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER=	yuri@FreeBSD.org
+COMMENT=	Efficient, flexible and portable structured generation
+WWW=		https://xgrammar.mlc.ai/ \
+		https://github.com/mlc-ai/xgrammar
+
+LICENSE=	APACHE20
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}scikit-build-core>=0.10.0:devel/py-scikit-build-core@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}nanobind>=2.5.0:devel/py-nanobind@${PY_FLAVOR}
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}numpy1>0:math/py-numpy1@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pydantic2>0:devel/py-pydantic2@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pytorch>=1.10.0:misc/py-pytorch@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}transformers>=4.38.0:misc/py-transformers@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}typing-extensions>=4.9.0:devel/py-typing-extensions@${PY_FLAVOR}
+
+USES=		cmake:indirect python pytest
+USE_PYTHON=	pep517 autoplist
+
+TEST_ENV=	${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
+TEST_WRKSRC=	${WRKSRC}/tests
+
+# tests as of 0.1.33: 260 failed, 971 passed, 57 skipped, 9 warnings, 1098 errors in 538.64s (0:08:58)
+# ... many failures are due to unauthorized access to gated HF models, which is expected and not a problem for the port, see https://github.com/mlc-ai/xgrammar/issues/584
+
+.include <bsd.port.mk>
diff --git a/misc/py-xgrammar/distinfo b/misc/py-xgrammar/distinfo
new file mode 100644
index 000000000000..27ca5fb5da9b
--- /dev/null
+++ b/misc/py-xgrammar/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1775500352
+SHA256 (xgrammar-0.1.33.tar.gz) = 8dbe5fc3d76651ab1fac7a68fc2a118b885fa0ec7189927fb6e0dce0081aea99
+SIZE (xgrammar-0.1.33.tar.gz) = 2398956
diff --git a/misc/py-xgrammar/files/patch-pyproject.toml b/misc/py-xgrammar/files/patch-pyproject.toml
new file mode 100644
index 000000000000..019a294df7fc
--- /dev/null
+++ b/misc/py-xgrammar/files/patch-pyproject.toml
@@ -0,0 +1,11 @@
+--- pyproject.toml.orig	2026-04-06 19:29:01 UTC
++++ pyproject.toml
+@@ -41,7 +41,7 @@ metal = ["mlx-lm; platform_system == 'Darwin' and plat
+ metal = ["mlx-lm; platform_system == 'Darwin' and platform_machine == 'arm64'"]
+ 
+ [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]
diff --git a/misc/py-xgrammar/pkg-descr b/misc/py-xgrammar/pkg-descr
new file mode 100644
index 000000000000..c6e20e182c9b
--- /dev/null
+++ b/misc/py-xgrammar/pkg-descr
@@ -0,0 +1,3 @@
+xgrammar enables efficient, flexible and portable structured generation
+for large language models. It provides grammar-constrained decoding that
+works with JSON schemas, regular expressions, and custom context-free grammars.


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69d4d537.47e3e.120d9ef9>