From 00c02ca7d13859dbdac149ea2d4e1a7e7fa6b94b Mon Sep 17 00:00:00 2001 From: Pjotr Date: Thu, 2 Jul 2026 08:52:07 +0000 Subject: hmf: Add java-djl-pytorch-native-cpu-precxx11-linux-aarch64. DJL upstream does not ship a linux-aarch64 classifier for pytorch-native-cpu at v2.2.2; the sibling pytorch-native-cpu-precxx11 artifact (built against the pre-C++11 libstdc++ ABI) is provided for that platform instead. This is safe for Java consumers because they cross the C JNI boundary rather than libstdc++. Refactor the (unrelated single-instance) x86_64 package definition into a small %djl-pytorch-native helper procedure so both classifier variants share a single code path. guix aarch64 users who want to run java-v-chord or java-v-cuppa install this package alongside them (v-chord's own extra-inputs still reference only the x86_64 variant, so the two hmftools modules remain buildable on both architectures without cross-arch input entanglement). * hmf/packages/java-libraries.scm (%djl-pytorch-native): New procedure. (java-djl-pytorch-native-cpu-precxx11-linux-aarch64): New variable. (java-djl-pytorch-native-cpu): Rebuild from the helper. --- hmf/packages/java-libraries.scm | 72 ++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 23 deletions(-) (limited to 'hmf/packages/java-libraries.scm') diff --git a/hmf/packages/java-libraries.scm b/hmf/packages/java-libraries.scm index 6d02899..9726839 100644 --- a/hmf/packages/java-libraries.scm +++ b/hmf/packages/java-libraries.scm @@ -385,24 +385,28 @@ itself; requires djl-pytorch-native- at runtime to resolve libtorch." #:home-page "https://djl.ai/")) -(define-public java-djl-pytorch-native-cpu - ;; Architecture-specific native bundle. Ships prebuilt libtorch_cpu - ;; .so files inside the jar; DJL's native loader extracts and - ;; dlopens them on demand. Restrict to x86_64-linux -- the WiGiTS - ;; pipeline's deployment target -- because the artifact bundles a - ;; specific ISA. +(define* (%djl-pytorch-native artifact version classifier hash + #:key + (supported '("x86_64-linux")) + (name-suffix #f)) + "Return a package for the DJL PyTorch native runtime bundle +ARTIFACT/VERSION with the given CLASSIFIER (e.g. \"linux-x86_64\"). +DJL upstream ships one such classifier-suffixed jar per platform, +each embedding platform-specific libtorch_cpu / libtorch / libc10 +shared libraries." (package - (name "java-djl-pytorch-native-cpu") - (version "2.2.2") + (name (or name-suffix + (string-append "java-djl-" artifact "-" classifier))) + (version version) (source (origin (method url-fetch) (uri (string-append "https://repo.maven.apache.org/maven2/ai/djl/pytorch/" - "pytorch-native-cpu/" version - "/pytorch-native-cpu-" version "-linux-x86_64.jar")) - (sha256 - (base32 - "0wkwr395p6r58511x2byxs3na3awa8b26l23p5269fhbib9gz0wl")))) + artifact "/" version + "/" artifact "-" version "-" classifier ".jar")) + (file-name (string-append + artifact "-" version "-" classifier ".jar")) + (sha256 (base32 hash)))) (build-system trivial-build-system) (arguments (list @@ -414,20 +418,42 @@ resolve libtorch." (mkdir-p dest) (copy-file #$(package-source this-package) (string-append - dest - "/pytorch-native-cpu-" #$version - "-linux-x86_64.jar")))))) - (supported-systems '("x86_64-linux")) + dest "/" + #$artifact "-" #$version "-" + #$classifier ".jar")))))) + (supported-systems supported) (home-page "https://djl.ai/") - (synopsis "Bundled libtorch CPU native runtime for AWS DJL (linux-x86_64)") + (synopsis "Bundled libtorch CPU native runtime for AWS DJL") (description - "Prebuilt libtorch_cpu shared libraries and DJL's native loader -metadata for x86_64 Linux, packaged as a Maven Central jar. DJL's -PyTorch JNI extracts and dlopens the bundled .so files on first -call. Not available for other architectures because upstream ships -one artifact per platform classifier.") + "Prebuilt libtorch_cpu, libtorch and libc10 shared libraries plus +DJL's native loader metadata, packaged as a classifier-suffixed Maven +Central jar. DJL's PyTorch JNI extracts and dlopens the bundled .so +files on first tensor call.") (license license:asl2.0))) +(define-public java-djl-pytorch-native-cpu + ;; The upstream 'pytorch-native-cpu' artifact only ships classifiers + ;; for linux-x86_64 (and osx-*, win-x86_64) at v2.2.2 -- there is + ;; no linux-aarch64 build here. + (%djl-pytorch-native + "pytorch-native-cpu" "2.2.2" "linux-x86_64" + "0wkwr395p6r58511x2byxs3na3awa8b26l23p5269fhbib9gz0wl" + #:supported '("x86_64-linux") + #:name-suffix "java-djl-pytorch-native-cpu")) + +(define-public java-djl-pytorch-native-cpu-precxx11-linux-aarch64 + ;; Upstream ships pytorch-native-cpu-precxx11--linux-aarch64 + ;; (built against the pre-C++11 libstdc++ ABI) as the aarch64 + ;; counterpart of pytorch-native-cpu. This is safe here because + ;; Java crosses the C JNI boundary, not libstdc++. Guix aarch64 + ;; users who want to actually execute java-v-chord or java-v-cuppa + ;; install this package alongside them and add it to their profile + ;; classpath. + (%djl-pytorch-native + "pytorch-native-cpu-precxx11" "2.2.2" "linux-aarch64" + "1sv9fjn6p7cywpw0mhsmmidbf1yp4nsb38lr8baylrqy8iz4cmjx" + #:supported '("aarch64-linux"))) + (define-public java-djl-api (maven-central-jar "java-djl-api" "0.28.0" -- cgit 1.4.1