[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#45972] [PATCH] Add julia-json with dependencies
From: |
Ludovic Courtès |
Subject: |
[bug#45972] [PATCH] Add julia-json with dependencies |
Date: |
Thu, 28 Jan 2021 14:10:15 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Buon giorno!
Nicolò Balzarotti <anothersms@gmail.com> skribis:
>> My understanding is that the first patch expects the source file name to
>> match the Julia package name.
>
> That's correct, we use it in the build system.
>
>> IMO, that shouldn’t be the case.
>
> At first I wasn't sure it was ok, but it went on through the revision
> process when I submitted the first package (Compat) so I tought it was fine.
If it was me it was probably an oversight, I’m sorry about that.
>> Can we either extract the Julia package name from metadata that’s in
>> the package itself (?), or otherwise pass it to all the phases via
>> ‘julia-build-system’?
>
> Sure, I'd just read it from Package.toml (nowadays almost all the
> packages have this file, and for when it's missing we also have the
> julia-create-package-toml procedure that creates it).
>
> The file is toml, but I don't see a toml parser in guix. So, I'd use a
> function like the following:
>
> #+begin_src scheme
> (define (package.toml->name file)
> (call-with-input-file file
> (lambda (in)
> (let loop ((line (read-line in 'concat)))
> (if (eof-object? line)
> #f ;What to do?
> (let ((m (string-match "name\\s*=\\s*\"(.*)\"" line)))
> (if m (match:substring m 1)
> (loop (read-line in 'concat)))))))))
> #+end_src
Sounds reasonable to me. If I understand the toml format correctly,
“name=.*” is guaranteed to be on a line on its own, so that looks safe.
> As you can see this is very minimal/naive (takes the first name = ""
> occurrence, does not even consider comments, for which I'd add a
> negative lookahead "^(?!#)" which I can't get to work with ice-9 regex),
> but tested on a few packages it working. I don't know what to do when
> the match is not found (since it's something that might happen only
> during development, the #f fallback should not be too bad, btw, as the
> build will fail).
Yes, sounds good.
To be on the safe side, we can add a #:julia-package-name parameter to
the build system; it would default to #f, in which case the name is
extracted from the toml file.
> The other way I think this is easily solvable is by asking julia
> directly, by reading the output of:
>
> (invoke-julia "using Pkg; Pkg.TOML.parsefile("Project.toml")["name"] |>
> println")
>
> doing something like cargo's manifest-target procedure does. But it'd
> go the other way if it's ok.
Yeah, the basic “parser” seems to be good enough.
Thanks!
Ludo’.
- [bug#45972] [PATCH] Add julia-json with dependencies, Nicolò Balzarotti, 2021/01/18
- [bug#45972] [PATCH] Add julia-json with dependencies, Ludovic Courtès, 2021/01/26
- [bug#45972] Julia importer?, zimoun, 2021/01/30
- [bug#45972] Julia importer?, Nicolò Balzarotti, 2021/01/30
- [bug#45972] Julia importer?, Nicolò Balzarotti, 2021/01/30
- [bug#45972] Julia importer?, zimoun, 2021/01/31
- [bug#45972] Julia importer?, Nicolò Balzarotti, 2021/01/31