Re: package definition question: referring to source files of another package?

2023-09-04 Thread Andy Tai
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
 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



Re: package definition question: referring to source files of another package?

2023-09-03 Thread Attila Lendvai
> 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)




Re: package definition question: referring to source files of another package?

2023-09-02 Thread Liliana Marie Prikler
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



package definition question: referring to source files of another package?

2023-09-02 Thread 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?

Thanks for info on these.