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

From: Ludovic Courtès <[email-masked]>
Date: Mon, 02 May 2022 22:57:45 +0200

Hi,

Maxim Cournoyer <[email-masked]> skribis:

>> ,import (gnu packages) (guix packages)
>> (car (find-packages-by-name "python2-pyalsaaudio"))
> $1 = #<package [email-masked] 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>
>
>
> 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):
>
> (package/inherit p
>         (location (package-location p))
>
>         ^ Here, we explicitly set the location to that of its parent.

Indeed, that’s on purpose; the rationale is that it’s more useful to see
the location of the original package (the Python 3 variant) than always
this one line in gnu/build-system/python.scm.

> Another related issue for package-with-python2 packages:
>
>> (package-definition-location-code $1)
> $4 = #f

Yes, I see it’s annoying, but that’s expected.

> 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).

You were willing to have a script that would automatically delete the
relevant lines, right?

It’s kinda silly but I think the script will have to estimate the
definition location by looking for “(define-public python2-…”.

HTH,
Ludo’.