bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55139: package-location is wrong for transformed packages


From: Liliana Marie Prikler
Subject: bug#55139: package-location is wrong for transformed packages
Date: Wed, 27 Apr 2022 14:23:20 +0200
User-agent: Evolution 3.42.1

Am Dienstag, dem 26.04.2022 um 21:48 -0400 schrieb Maxim Cournoyer:
> Hi Guix!
> 
> --8<---------------cut here---------------start------------->8---
> > ,import (gnu packages) (guix packages)
> > (car (find-packages-by-name "python2-pyalsaaudio"))
> $1 = #<package python2-pyalsaaudio@0.8.4 gnu/packages/audio.scm:4327
> 7f2b76fab160>
> > (package-definition-location-code package $1)
> $2 = #f
> > (package-definition-location $2)
> $3 = #<<location> file: "gnu/packages/audio.scm" line: 4327 column:
> 2>
> --8<---------------cut here---------------end--------------->8---
> 
> This is wrong though, and gives the location of the parent package
> (the one it inherited from).  This seems to be made on purpose (?)
> given the code in (gnu build-system python):
I'm pretty sure that this is done so that `guix edit' points you to the
package you want to edit rather than its wrapper.  While thus
incorrect, it is most often what you want.  Also, the wrapper should be
in its vicinity (usually the next package).

> --8<---------------cut here---------------start------------->8---
> (package/inherit p
>         (location (package-location p))
> 
>         ^ Here, we explicitly set the location to that of its parent.
>         
>         (name (let ((name (package-name p)))
>                 (string-append new-prefix
>                                (if (string-prefix? old-prefix name)
>                                    (substring name
>                                               (string-length old-
> prefix))
>                                    name))))
>         (arguments
>          (let ((python (if (promise? python)
>                            (force python)
>                            python)))
>            (ensure-keyword-arguments (package-arguments p)
>                                      `(#:python ,python)))))
> --8<---------------cut here---------------end--------------->8---
> 
> Another related issue for package-with-python2 packages:
> 
> --8<---------------cut here---------------start------------->8---
> > (package-definition-location-code $1)
> $4 = #f
> --8<---------------cut here---------------end--------------->8---
> 
> I was expecting to use this to get rid of all leaf Python 2 packages,
> but it seems that may not work (as easily as I'd hoped).
Note, that you can use guix graphs to detect leaves and then grep for
the variable name.  This still requires you to use Emacs for deleting
some three lines rather than doing so programmatically.

However, given that you have the location, you could try to filter out
the variable name, then detect whether it's in a package-with-python2
call within the same file.

Finally, you can try to just locally comment out that setter and it
might return the "true" path.  Note that I haven't tested this.  Since
you're probably using this for a more or less one-time script anyway, I
wouldn't be too bothered about it being a dirty hack.

Cheers :)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]