summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1c0bdebe211239615e50e8196b849ea31ef68eaf (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
# Maintainer: djwarf
pkgname=switchgen-git
pkgver=0.1.0
pkgrel=1
pkgdesc="AI Image Generator using ComfyUI as a library"
arch=('x86_64')
url="https://github.com/djwarf/switchgen"
license=('MIT')
depends=(
    'python>=3.10'
    'python-gobject'
    'gtk4'
    'libadwaita'
    'python-pillow'
    'python-pytorch'
    'python-torchvision'
    'python-numpy'
    'python-scipy'
    'python-tqdm'
    'python-aiohttp'
    'python-yaml'
    'python-huggingface-hub'
    'python-einops'
    'python-transformers'
    'python-safetensors'
    'python-psutil'
    'python-requests'
)
makedepends=('python-build' 'python-installer' 'python-hatchling' 'git')
provides=('switchgen')
conflicts=('switchgen')
source=("${pkgname}::git+${url}.git")
sha256sums=('SKIP')

pkgver() {
    cd "$pkgname"
    git describe --long --tags 2>/dev/null | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' || echo "0.1.0.r$(git rev-list --count HEAD).g$(git rev-parse --short HEAD)"
}

prepare() {
    cd "$pkgname"
    git submodule update --init --recursive
}

build() {
    cd "$pkgname"
    python -m build --wheel --no-isolation
}

package() {
    cd "$pkgname"

    # Install Python package
    python -m installer --destdir="$pkgdir" dist/*.whl

    # Install bundled ComfyUI to /usr/share/switchgen/vendor/
    install -dm755 "$pkgdir/usr/share/switchgen/vendor"

    # Copy ComfyUI using tar (excludes .git, works in fakeroot)
    tar -C vendor --exclude='.git' -cf - ComfyUI | tar -C "$pkgdir/usr/share/switchgen/vendor" -xf -

    # Verify the copy worked
    if [ ! -f "$pkgdir/usr/share/switchgen/vendor/ComfyUI/nodes.py" ]; then
        echo "ERROR: ComfyUI copy failed!"
        exit 1
    fi

    # Install desktop file and docs
    install -Dm644 switchgen.desktop "$pkgdir/usr/share/applications/switchgen.desktop"
    install -Dm644 README.md "$pkgdir/usr/share/doc/${pkgname%-git}/README.md"
    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/${pkgname%-git}/LICENSE" 2>/dev/null || true
}