all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* package definition question: referring to source files of another package?
@ 2023-09-03  3:35 Andy Tai
  2023-09-03  4:18 ` Liliana Marie Prikler
  2023-09-03 12:12 ` Attila Lendvai
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Tai @ 2023-09-03  3:35 UTC (permalink / raw)
  To: guix-devel

Hi, this is a question for writing package definition.

In some scenarios package A may refer to source files in package B.
The question is,
1. How to reference source directory of package B from within
definition of package A?
2. can we even assume sources of Package B is available?   Normally if
package B is an input (dependency) for package A, guix would ensure
its installation directory is available, but not necessarily the
source.  So is there something that has to be done to ensure Package B
sources are somewhere?

Thanks for info on these.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: package definition question: referring to source files of another package?
  2023-09-03  3:35 package definition question: referring to source files of another package? Andy Tai
@ 2023-09-03  4:18 ` Liliana Marie Prikler
  2023-09-05  6:28   ` Andy Tai
  2023-09-03 12:12 ` Attila Lendvai
  1 sibling, 1 reply; 4+ messages in thread
From: Liliana Marie Prikler @ 2023-09-03  4:18 UTC (permalink / raw)
  To: Andy Tai, guix-devel

Am Samstag, dem 02.09.2023 um 20:35 -0700 schrieb Andy Tai:
> Hi, this is a question for writing package definition.
> 
> In some scenarios package A may refer to source files in package B.
> The question is, 
> 1. How to reference source directory of package B from within
> definition of package A?
> 2. can we even assume sources of Package B is available?   Normally
> if package B is an input (dependency) for package A, guix would
> ensure its installation directory is available, but not necessarily
> the source.  So is there something that has to be done to ensure
> Package B sources are somewhere?
You can use (package-source B) both within source and inputs.  The only
caveat here is that A and B should best be located in the same file;
things break badly if they are split and introduce cyclic references.
Note that the and part is more likely than you think, since the thunked
nature of inputs normally makes them harmless.

Cheers


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: package definition question: referring to source files of another package?
  2023-09-03  3:35 package definition question: referring to source files of another package? Andy Tai
  2023-09-03  4:18 ` Liliana Marie Prikler
@ 2023-09-03 12:12 ` Attila Lendvai
  1 sibling, 0 replies; 4+ messages in thread
From: Attila Lendvai @ 2023-09-03 12:12 UTC (permalink / raw)
  To: Andy Tai; +Cc: guix-devel

> In some scenarios package A may refer to source files in package B.

depending on where and what you need, you can do something like this in a GEXP context:

(define (upstream-file relative-path)
  (let ((git-origin
         (let ((commit "v0.13.2"))
           (origin
             (method git-fetch)
             (uri (git-reference
                   (url ...)
                   (commit commit)))
             (file-name (git-file-name "foo-bar" commit))
             (sha256
              (base32 ...))))))
    (file-append git-origin relative-path)))

#~(let ((x #$(upstream-file "/some-path"))) ...)


this way the versioning of the two packages are not tied together, which may or may not be what you want from a semantics perspective.

-- 
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“There are some ideas so wrong that only a very intelligent person could believe in them.”
	— George Orwell (1903–1950)



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: package definition question: referring to source files of another package?
  2023-09-03  4:18 ` Liliana Marie Prikler
@ 2023-09-05  6:28   ` Andy Tai
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Tai @ 2023-09-05  6:28 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: guix-devel

Thanks. this is the pattern that seems to work, posted here for reference:
(define-public tensorflow-lite
  (package
    (name "tensorflow-lite")
     ...
    (arguments
     `(#:configure-flags

       (list ...
        (string-append "-Dgemmlowp_SOURCE_DIR=" (assoc-ref
%build-inputs "gemmlowp-src"))
...

    (inputs
     `(
       ("gemmlowp-src"
          ,(package-source gemmlowp))
...

where A is tensorflow-lite and B is gemmlowp

On Sat, Sep 2, 2023 at 9:18 PM Liliana Marie Prikler
<liliana.prikler@gmail.com> wrote:
> Am Samstag, dem 02.09.2023 um 20:35 -0700 schrieb Andy Tai:
> > In some scenarios package A may refer to source files in package B.
> > The question is,
> > 1. How to reference source directory of package B from within
> > definition of package A?
> You can use (package-source B) both within source and inputs.  The only
> caveat here is that A and B should best be located in the same file;
> things break badly if they are split and introduce cyclic references.
> Note that the and part is more likely than you think, since the thunked
> nature of inputs normally makes them harmless.
>
> Cheers


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-05  6:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-03  3:35 package definition question: referring to source files of another package? Andy Tai
2023-09-03  4:18 ` Liliana Marie Prikler
2023-09-05  6:28   ` Andy Tai
2023-09-03 12:12 ` Attila Lendvai

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.