Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions packages/giskard/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# This file is part of BlackArch Linux (https://www.blackarch.org/).
# See COPYING for license details.
#
# Original Maintainer: Behruz <extreme29@proton.me>

pkgname=giskard
_pkgname=giskard-oss
pkgver=3.0.0b1.r10622.g8aafe5892
pkgrel=1
pkgdesc='Evaluation, testing and vulnerability scanning framework for AI agents.'
arch=('x86_64')
groups=('blackarch' 'blackarch-ai')
url='https://github.com/Giskard-AI/giskard-oss'
license=('Apache-2.0')
depends=('python>=3.12')
makedepends=('git' 'python-pip' 'python-virtualenv')
provides=('giskard')
conflicts=('giskard-oss-git' 'python-giskard')
options=('!strip' '!debug')
source=("git+$url.git")
sha512sums=('SKIP')

pkgver() {
cd "$_pkgname"

local _version

_version=$(sed -n \
's/^[[:space:]]*version[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' \
pyproject.toml | head -n 1)

printf '%s.r%s.g%s' \
"${_version:-3.0.0b1}" \
"$(git rev-list --count HEAD)" \
"$(git rev-parse --short HEAD)"
}

package() {
cd "$_pkgname"

local _venv="$pkgdir/opt/$pkgname"
local _python="$_venv/bin/python"
local _file
local _cmd

python -m venv "$_venv"

PIP_DISABLE_PIP_VERSION_CHECK=1 \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't not seem to follow our PKGBUILD templates. Coud you follow https://github.com/BlackArch/blackarch-pkgbuilds/tree/master/python please?

"$_python" -m pip install \
--no-cache-dir \
--no-warn-script-location \
--upgrade \
pip \
setuptools \
wheel

PIP_DISABLE_PIP_VERSION_CHECK=1 \
"$_python" -m pip install \
--no-cache-dir \
--no-warn-script-location \
--compile \
"$srcdir/$_pkgname/libs/giskard-core" \
"$srcdir/$_pkgname/libs/giskard-llm" \
"$srcdir/$_pkgname/libs/giskard-agents" \
"$srcdir/$_pkgname/libs/giskard-checks" \
"$srcdir/$_pkgname/libs/giskard-scan" \
"$srcdir/$_pkgname"

while IFS= read -r -d '' _file; do
if head -n 1 "$_file" 2>/dev/null |
grep -Fq "#!$pkgdir/opt/$pkgname/bin/python"; then
sed -i \
"1s|^#!$pkgdir/opt/$pkgname/bin/python[^[:space:]]*|#!/opt/$pkgname/bin/python|" \
"$_file"
fi
done < <(
find "$_venv/bin" \
-maxdepth 1 \
-type f \
-print0
)

find "$_venv" \
-type d \
\( \
-name '.pytest_cache' \
-o -name '.mypy_cache' \
-o -name '.ruff_cache' \
\) \
-prune \
-exec rm -rf '{}' +

install -dm 755 "$pkgdir/usr/bin"

cat > "$pkgdir/usr/bin/giskard-python" << 'EOF'
#!/bin/sh
exec /opt/giskard/bin/python "$@"
EOF

cat > "$pkgdir/usr/bin/giskard-info" << 'EOF'
#!/opt/giskard/bin/python

from importlib.metadata import PackageNotFoundError, version

packages = (
"giskard",
"giskard-core",
"giskard-llm",
"giskard-agents",
"giskard-checks",
"giskard-scan",
)

for package in packages:
try:
installed_version = version(package)
except PackageNotFoundError:
installed_version = "not installed"

print(f"{package}: {installed_version}")
EOF

chmod 755 \
"$pkgdir/usr/bin/giskard-python" \
"$pkgdir/usr/bin/giskard-info"

for _file in "$_venv"/bin/giskard*; do
[[ -f "$_file" && -x "$_file" ]] || continue

_cmd="${_file##*/}"

[[ "$_cmd" == 'giskard-info' ]] && continue
[[ "$_cmd" == 'giskard-python' ]] && continue

cat > "$pkgdir/usr/bin/$_cmd" << EOF
#!/bin/sh
exec /opt/$pkgname/bin/$_cmd "\$@"
EOF

chmod 755 "$pkgdir/usr/bin/$_cmd"
done

install -Dm 644 LICENSE \
"$pkgdir/usr/share/licenses/$pkgname/LICENSE"

install -Dm 644 README.md \
"$pkgdir/usr/share/doc/$pkgname/README.md"

[[ -f SECURITY.md ]] &&
install -Dm 644 SECURITY.md \
"$pkgdir/usr/share/doc/$pkgname/SECURITY.md"

[[ -f THIRD_PARTY_NOTICES.md ]] &&
install -Dm 644 THIRD_PARTY_NOTICES.md \
"$pkgdir/usr/share/doc/$pkgname/THIRD_PARTY_NOTICES.md"
}