GNU bug report logs -
#55139
package-location is wrong for transformed packages
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Wed, 08 Jun 2022 17:29:08 -0400
with message-id <87tu8uj13v.fsf <at> gmail.com>
and subject line Re: bug#55139: package-location is wrong for transformed packages
has caused the debbugs.gnu.org bug report #55139,
regarding package-location is wrong for transformed packages
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
55139: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55139
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
Hi Guix!
--8<---------------cut here---------------start------------->8---
> ,import (gnu packages) (guix packages)
> (car (find-packages-by-name "python2-pyalsaaudio"))
$1 = #<package python2-pyalsaaudio <at> 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):
--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).
Thanks,
Maxim
[Message part 3 (message/rfc822, inline)]
Hi Ludovic,
Ludovic Courtès <ludo <at> gnu.org> writes:
> Hi!
>
> Maxim Cournoyer <maxim.cournoyer <at> gmail.com> skribis:
>
>> Yeah, I ended up with this [0]:
>>
>> (define (locate-package-via-git name)
>> "Return the location object corresponding to package NAME, searched via git."
>> (let* ((input-pipe (open-pipe* OPEN_READ
>> "git" "grep" "-n" "--column"
>> (format #f "^(define-public ~a$" name)))
>> (output (get-string-all input-pipe)) ;file:line:column:match
>> (exit-val (status:exit-val (close-pipe input-pipe))))
>> (case exit-val
>> ((0)
>> (let ((components (string-split output #\:)))
>> (location
>> (first components) ;file
>> (string->number (second components)) ;1-indexed line
>> ;; FIXME: Comment discrepancy in (guix diagnostics), which
>> ;; says the column is 0-indexed.
>> (and=> (string->number (third components)) 1-)))) ;0-indexed column
>> ((1) #f) ;no match
>> (else (error "git grep failed with status" exit-val)))))
>>
>> and it does feel silly to have to shell out to git, but it did the job.
>>
>> Thanks,
>>
>> Maxim
>>
>> [0] https://notabug.org/apteryx/guix-api-examples/src/master/purge-python2-packages.scm#L42
>
> Nice, it’s good to have these examples—and hopefully we’ll soon be able
> to remove a whole bunch of ‘python2-’ packages!
>
> As for ‘package-definition-location’, I don’t think we can reasonably do
> any better, so I’m tempted to close the bug.
OK; thanks for your input.
At least it'll be recorded somewhere for the next person stumbling on
this behavior to discover.
Maxim
This bug report was last modified 3 years and 35 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.