diff mbox series

[bug#46195] Add julia-http with dependencies

Message ID 87v9be86kf.fsf@guixSD.i-did-not-set--mail-host-address--so-tickle-me
State Accepted
Headers show
Series [bug#46195] Add julia-http with dependencies | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Nicolò Balzarotti Jan. 30, 2021, 9:21 p.m. UTC
Hi guix!
Here's my second set of patches adding Julia packages.

This time one package (julia-mbedtls-jll) requires a shared library
(mbedtls-apache).  The most recent way (threre has been a few during the
years) Julia packages use to ship binaries is by using jllwrappers
[fn:1], which generates package_jll (e.g. mbedtls-jll [fn:2]), a Julia
package which is then included by the real Julia package (e.g. mbedtls
[fn:3]).  Jllwrappers usually downloads prebuild binaries.  There's an
override mechanism (creating a folder named "override" under the julia
module dir).

They recently added an easiesr way to override this behaviour
(https://github.com/JuliaPackaging/JLLWrappers.jl/pull/27), but this
will be available on julia 1.6+.

In the meanwhile I see two ways around this:
- symlinking deps into
  /gnu/store/...julia-packagename-jll/[...]/override
- patching both jllwrappers to support a custom override path, and then
  patching the jllwrapper call inside each package-jll so that the
  library/binary is searched in the correct directory.

I do like this second approach more (but I don't have a strong opinion
on this), so in this patchset I patched @generate_wrapper_header macro,
so that it takes an optional parameter with the overidden library path.
While we wait for julia 1.6, the way to use this is (like I'm doing in
mbedtls-jll) to add the path to the library the generate_wrapper_header
call, and everything works fine.  I also added the relative
documentation.  If you think symlinking is a better approach, let me
know so that I can update this patch set.

(Also, somehow I managed to add to errors in previous patches (wrong
arugment name in build system, wrong file name in julia-adapt, which I
fixed now.  I'm really sorry)

Thanks again!

Nicolò

[fn:1] https://github.com/JuliaPackaging/JLLWrappers.jl
[fn:2] https://github.com/JuliaBinaryWrappers/MbedTLS_jll.jl
[fn:3]
https://github.com/JuliaLang/MbedTLS.jl/blob/ec0d189551406b883259872611d913defb5cd423/Project.toml#L8

Comments

Ludovic Courtès March 20, 2021, 9:32 p.m. UTC | #1
Hi Nicolò,

Nicolò Balzarotti <anothersms@gmail.com> skribis:

> This time one package (julia-mbedtls-jll) requires a shared library
> (mbedtls-apache).  The most recent way (threre has been a few during the
> years) Julia packages use to ship binaries is by using jllwrappers
> [fn:1], which generates package_jll (e.g. mbedtls-jll [fn:2]), a Julia
> package which is then included by the real Julia package (e.g. mbedtls
> [fn:3]).  Jllwrappers usually downloads prebuild binaries.  There's an
> override mechanism (creating a folder named "override" under the julia
> module dir).

So JLL is a “foreign function interface” (FFI), right?

> They recently added an easiesr way to override this behaviour
> (https://github.com/JuliaPackaging/JLLWrappers.jl/pull/27), but this
> will be available on julia 1.6+.
>
> In the meanwhile I see two ways around this:
> - symlinking deps into
>   /gnu/store/...julia-packagename-jll/[...]/override
> - patching both jllwrappers to support a custom override path, and then
>   patching the jllwrapper call inside each package-jll so that the
>   library/binary is searched in the correct directory.
>
> I do like this second approach more (but I don't have a strong opinion
> on this), so in this patchset I patched @generate_wrapper_header macro,
> so that it takes an optional parameter with the overidden library path.
> While we wait for julia 1.6, the way to use this is (like I'm doing in
> mbedtls-jll) to add the path to the library the generate_wrapper_header
> call, and everything works fine.  I also added the relative
> documentation.  If you think symlinking is a better approach, let me
> know so that I can update this patch set.

Sounds reasonable to me.

I pushed the whole series, tweaking one or two commit logs; I also took
the liberty to adjust this example:

> +The package @code{MbetTLS} can be taken as an example:
> +@lisp
> +(add-after 'unpack 'override-binary-path
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             (map
> +              (lambda (wrapper)
> +                (substitute* wrapper
> +                  (("generate_wrapper_header.*")
> +                   (string-append
> +                    "generate_wrapper_header(\"MbedTLS\", \""
> +                    (assoc-ref inputs "mbedtls-apache") "\")\n"))))
> +              ;; There's a Julia file for each platform, override them all
> +              (find-files "src/wrappers/" "\\.jl$"))
> +             #t))
> +@end lisp

… where I “fixed” indentation, used ‘for-each’ instead of ‘map’, and
removed the trailing #t (it’s obsolescent).

Thank you, and apologies for the delay!

Ludo’.
Nicolò Balzarotti March 20, 2021, 10:33 p.m. UTC | #2
Ludovic Courtès <ludo@gnu.org> writes:
Hi!
>
> So JLL is a “foreign function interface” (FFI), right?
>

Well, not exactly (if the meaning of FFI is: a way to call foreign
functions).  Julia Base has the @ccall macro for calling C functions.

Library_jll.jl is a standard naming for a wrapper for a specific library,
and it is usually generated by the package JLLWrappers.jl

JLL stands for DLL (dynamic link library) with the D replaced with
Julia's J, so you know that by installing a _jll package you are not
installing a pure Julia package, but a package with some binary
dependencies.

> … where I “fixed” indentation, used ‘for-each’ instead of ‘map’, and
> removed the trailing #t (it’s obsolescent).

Thanks!

> Thank you, and apologies for the delay!
>
No problem, I'll prepare next set of Julia patches then :)

Thanks, Nicolò
Nicolò Balzarotti March 20, 2021, 10:37 p.m. UTC | #3
> Julia Base has the @ccall macro for calling C functions.

Oops, it's not a macro, it's a keyword (ccall not @ccall)
diff mbox series

Patch

From 5131c1274f7b30e7e04a831533b9bee193df429a Mon Sep 17 00:00:00 2001
From: nixo <nicolo@nixo.xyz>
Date: Tue, 19 Jan 2021 13:29:00 +0100
Subject: [PATCH 10/10] gnu: Add julia-http.

* gnu/packages/julia-xyz.scm (julia-http): New variable.
---
 gnu/packages/julia-xyz.scm | 58 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/gnu/packages/julia-xyz.scm b/gnu/packages/julia-xyz.scm
index a3c5c55a86..0d35cbde57 100644
--- a/gnu/packages/julia-xyz.scm
+++ b/gnu/packages/julia-xyz.scm
@@ -176,6 +176,64 @@  scaled by a constant factor.  Consequently, they have a fixed number of
 digits (bits) after the decimal (radix) point.")
     (license license:expat)))
 
+(define-public julia-http
+  (package
+    (name "julia-http")
+    (version "0.9.2")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/JuliaWeb/HTTP.jl")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0ij0yci13c46p92m4zywvcs02nn8pm0abyfffiyhxvva6hq48lyl"))))
+    (build-system julia-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-before 'install 'disable-network-tests
+           (lambda _
+             (substitute* "test/runtests.jl"
+               (("\"async.jl") "# \"async.jl")
+               (("\"client.jl") "# \"client.jl"))
+             (substitute* "test/aws4.jl"
+               (("@testset.*HTTP.request with AWS authentication.*" all)
+                (string-append all "return\n")))
+             (substitute* "test/insert_layers.jl"
+               (("@testset.*Inserted final layer runs handler.*" all)
+                (string-append all "return\n")))
+             (substitute* "test/multipart.jl"
+               (("@testset \"Setting of Content-Type.*" all)
+                (string-append all "return\n"))
+               (("@testset \"Deprecation of .*" all)
+                (string-append all "return\n")))
+             (substitute* "test/websockets.jl"
+               (("@testset.*External Host.*" all)
+                (string-append all "return\n")))
+             (substitute* "test/messages.jl"
+               (("@testset.*Read methods.*" all)
+                (string-append all "return\n"))
+               (("@testset.*Body - .*" all)
+                (string-append all "return\n"))
+               (("@testset.*Write to file.*" all)
+                (string-append all "return\n")))
+             #t)))))
+    (propagated-inputs
+     `(("julia-inifile" ,julia-inifile)
+       ("julia-mbedtls" ,julia-mbedtls)
+       ("julia-uris" ,julia-uris)))
+    ;; required for tests
+    (inputs
+     `(("julia-json" ,julia-json)
+       ("julia-bufferedstreams" ,julia-bufferedstreams)))
+    (home-page "https://juliaweb.github.io/HTTP.jl/")
+    (synopsis "HTTP support for Julia")
+    (description "@code{HTTP.jl} is a Julia library for HTTP Messages,
+implementing both a client and a server.")
+    (license license:expat)))
+
 (define-public julia-inifile
   (package
     (name "julia-inifile")
-- 
2.30.0