Install this version:
emerge -a =dev-python/ast-grep-cli-0.45.3
If this version is masked, you can unmask it using the autounmask tool or standard emerge options:
autounmask =dev-python/ast-grep-cli-0.45.3
Or alternatively:
emerge --autounmask-write -a =dev-python/ast-grep-cli-0.45.3
# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
DISTUTILS_USE_PEP517=standalone
PYTHON_COMPAT=( python3_{12..14} )
inherit distutils-r1
DESCRIPTION="Structural search and rewrite tool for code using tree-sitter ASTs"
HOMEPAGE="https://ast-grep.github.io/ https://pypi.org/project/ast-grep-cli/"
# Upstream (maturin) publishes platform-tagged wheels containing the native
# ast-grep/sg binaries; the sdist is only a pip download wrapper with no Rust
# source. PyPI dist name is ast-grep-cli, wheel name uses an underscore.
_WHL_AMD64="ast_grep_cli-${PV}-py3-none-manylinux_2_28_x86_64.whl"
_WHL_ARM64="ast_grep_cli-${PV}-py3-none-manylinux_2_28_aarch64.whl"
SRC_URI="
amd64? ( https://files.pythonhosted.org/packages/c2/20/1445bff6593d492c31904fe309c157cb16bcb73cfd30b4a55718acef5cb1/${_WHL_AMD64} )
arm64? ( https://files.pythonhosted.org/packages/a9/d5/584cc4cf46a751f35fc086e9dca9962c05de2b37f95056f3653dc4736e19/${_WHL_ARM64} )
"
S="${WORKDIR}"
LICENSE="MIT"
SLOT="0"
KEYWORDS="-* ~amd64 ~arm64"
RESTRICT="mirror strip test"
QA_PREBUILT="usr/bin/ast-grep"
# The wheel has no Python runtime deps; it merely installs two native
# (ELF) console scripts, ast-grep and its sg alias.
src_unpack() {
:
}
src_compile() {
:
}
python_install() {
local whl
case ${ARCH} in
amd64) whl=${_WHL_AMD64} ;;
arm64) whl=${_WHL_ARM64} ;;
*) die "Unsupported architecture: ${ARCH}" ;;
esac
# the script is a shared file and the wheel installer refuses to
# overwrite; drop the copy left by the previous python target.
# sg (ast-grep's alias) is dropped too: it collides with shadow's
# setgroups utility, and headroom only resolves "ast-grep"
rm -f "${ED}/usr/bin/ast-grep" "${ED}/usr/bin/sg" || die
distutils_wheel_install "${ED}" "${DISTDIR}/${whl}"
rm -f "${ED}/usr/bin/sg" || die
}