Skip to content

Commit ec91fe7

Browse files
committed
llama.cpp: 4574, add model_converters variant
Closes: https://trac.macports.org/ticket/71927
1 parent 2a79050 commit ec91fe7

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

llm/llama.cpp/Portfile

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ PortGroup github 1.0
55
PortGroup cmake 1.1
66
PortGroup legacysupport 1.1
77

8-
github.setup ggerganov llama.cpp 4534 b
8+
github.setup ggerganov llama.cpp 4574 b
99
github.tarball_from archive
10-
set git-commit 955a6c2
10+
set git-commit 7fee288
1111
# This line is for displaying commit in CLI only
1212
revision 0
1313
categories llm
@@ -19,9 +19,9 @@ long_description The main goal of ${name} is to enable LLM inference with
1919
setup and state-of-the-art performance on a wide variety of hardware\
2020
- locally and in the cloud.
2121

22-
checksums rmd160 771fa15d2c7b6a3ef9114fd3c0afb676e0ba6559 \
23-
sha256 f4b57daa8d6bfe957f08a79f02ea9d24018ce9e73663c35a5c21f31ed3ccfcb8 \
24-
size 20496342
22+
checksums rmd160 047ed3d0c1252e83dd78ade21175899e2c7c4b05 \
23+
sha256 ce168eccb03da802c39486ab6b18dd225027d5c34cfbc5f46fec1870a1bdd624 \
24+
size 20504479
2525

2626
# error: 'filesystem' file not found on 10.14
2727
legacysupport.newest_darwin_requires_legacy \
@@ -41,8 +41,7 @@ post-patch {
4141

4242
compiler.cxx_standard 2017
4343

44-
configure.args-append -LAH \
45-
-DGGML_LTO=ON \
44+
configure.args-append -DGGML_LTO=ON \
4645
-DGGML_CCACHE=OFF \
4746
-DGGML_OPENMP=OFF \
4847
-DLLAMA_CURL=ON
@@ -60,6 +59,10 @@ if {${os.platform} eq "darwin" && ${os.subplatform} eq "macosx" && \
6059
-DGGML_METAL_EMBED_LIBRARY=OFF
6160
}
6261

62+
post-destroot {
63+
delete {*}[glob -directory ${destroot}${prefix}/bin/ convert*.py]
64+
}
65+
6366
variant blas description {Uses BLAS, improves performance} {
6467
configure.args-append \
6568
-DGGML_BLAS=ON
@@ -90,6 +93,32 @@ variant openmp description {enable parallelism support using OpenMP} {
9093
}
9194
}
9295

96+
variant model_converters description {install extra model conversion Python scripts} {
97+
set ::python_branch 3.12
98+
set ::python_version [string map {. ""} ${::python_branch}]
99+
depends_run-append port:python${::python_version} \
100+
port:py${::python_version}-numpy \
101+
port:py${::python_version}-pytorch \
102+
port:py${::python_version}-transformers \
103+
port:py${::python_version}-gguf
104+
105+
post-patch {
106+
reinplace "s|#!/usr/bin/env python3|#!${prefix}/bin/python${::python_branch}|" {*}[glob ${worksrcpath}/convert*.py]
107+
}
108+
109+
post-destroot {
110+
xinstall -d ${destroot}${prefix}/libexec/${name}
111+
xinstall -m 755 {*}[glob ${worksrcpath}/convert*.py] ${destroot}${prefix}/libexec/${name}
112+
foreach file [glob -directory ${destroot}${prefix}/libexec/${name} *.py] {
113+
set filebasename [file rootname [file tail $file]]
114+
set link ${destroot}${prefix}/bin/[lindex [split ${name} .] 0]-[string map {_ -} ${filebasename}]
115+
set target [string replace ${file} 0 [string length ${destroot}]-1]
116+
ui_debug "Creating symlink: ${link} => ${target}"
117+
ln -s ${target} ${link}
118+
}
119+
}
120+
}
121+
93122
variant native description "Force local build and optimize for CPU" {
94123
configure.args-append \
95124
-DGGML_NATIVE=ON

0 commit comments

Comments
 (0)