summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 942f759fc6853e0d540c8acc485233dbe4c83d63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Maintainer: Evert Vorster <superchief@evertvorster.com>

pkgname=python-openmemory-git
_pkgname=OpenMemory
pkgver=1.3.0.r21.g30daf78
pkgrel=1
pkgdesc="OpenMemory Python SDK (git)"
arch=('any')
url="https://github.com/CaviraOSS/OpenMemory"
license=('Apache-2.0')

depends=(
  'python'
  'python-fastapi'
  'uvicorn'
  'python-pydantic'
  'python-numpy'
  'python-httpx'
  'python-google-api-python-client'
  'python-google-auth'
  'python-msal'
  'python-pygithub'
  'python-beautifulsoup4'
  'python-pypdf'
  'python-mammoth'
  'python-markdownify'
  'python-openai'
)

makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-wheel'
  'python-hatchling'
)

provides=('python-openmemory')
conflicts=('python-openmemory')

source=(
  "${_pkgname}::git+https://github.com/CaviraOSS/OpenMemory.git"
)
sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}/${_pkgname}"
  # Prefer tags if they exist; otherwise fall back to commit count + hash.
  local v
  v="$(git describe --long --tags --abbrev=7 2>/dev/null)" || true
  if [[ -n "$v" ]]; then
    # v1.3.1-12-gabcdef0 -> 1.3.1.r12.gabcdef0
    v="${v#v}"
    printf '%s\n' "${v/-/.r}" | sed 's/-/./g'
  else
    printf "0.0.0.r%s.g%s\n" \
      "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  fi
}

build() {
  cd "${srcdir}/${_pkgname}/packages/openmemory-py"

  # Ensure we never accidentally install a stale wheel from an earlier build.
  rm -rf dist build *.egg-info

  # Note: -git packages intentionally track HEAD; users can pin commits by editing source=.
  python -m build --wheel --no-isolation
}

#check() {
#  cd "${srcdir}/${_pkgname}/packages/openmemory-py"
#
#  local whls
#  mapfile -t whls < <(ls -1 dist/*.whl 2>/dev/null)
#
#  if (( ${#whls[@]} != 1 )); then
#    echo "ERROR: Expected exactly one wheel in dist/, found ${#whls[@]}."
#    ls -la dist || true
#    return 1
#  fi
#
#  # Validate the built artifact by compiling the extracted wheel contents.
#  local tmpdir
#  tmpdir="$(mktemp -d -t openmemory-wheel-check.XXXXXX)"
#  trap 'rm -rf "${tmpdir}"' RETURN
#
#  python -m zipfile -e "${whls[0]}" "${tmpdir}"
#  python -m compileall -q "${tmpdir}/openmemory"
#}

package() {
  cd "${srcdir}/${_pkgname}/packages/openmemory-py"

  local whls
  mapfile -t whls < <(ls -1 dist/*.whl 2>/dev/null)

  if (( ${#whls[@]} != 1 )); then
    echo "ERROR: Expected exactly one wheel in dist/, found ${#whls[@]}."
    ls -la dist || true
    return 1
  fi

  python -m installer --destdir="${pkgdir}" "${whls[0]}"
}