Subject: Re: bug#38148: [PATCH 1/2] gnu: Add python-pyqtwebengine.

From: Mike Rosset <[email-masked]>
Date: Mon, 13 Jan 2020 16:42:47 -0800

>> +         ;; store.
>> +         (add-before 'configure 'substitute-source
>> +           (lambda* (#:key inputs  #:allow-other-keys)
>> +             (let* ((qtbase (assoc-ref inputs "qtbase"))
>> +                    (qtprinter.h (string-append "\"" qtbase "/include/qt5/QtPrintSupport/qprinter.h\"")))
>> +               (substitute* "sip/QtPrintSupport/qprinter.sip"
>> +                 (("<qprinter.h>")
>> +                  qtprinter.h))
>> +               #t)))
>>           (replace 'configure
>>             (lambda* (#:key inputs outputs #:allow-other-keys)
>>               (let* ((out (assoc-ref outputs "out"))
>> @@ -1986,6 +1998,91 @@ framework.  The bindings are implemented as a set of Python modules and
>>  contain over 620 classes.")
>>      (license license:gpl3)))
>
> Please apply the above pyqt change to a separate commit.

I missed this comment with my new series. If this really needs to be
done, I'll have to redo all of the commits and resend the series. Can
this be avoided if possible?

> +    (arguments
>> +     `(#:modules ((srfi srfi-1)
>> +                  ,@%gnu-build-system-modules)
>> +       #:phases
>> +       (modify-phases %standard-phases
>> +         (replace 'configure
>> +           (lambda* (#:key inputs outputs #:allow-other-keys)
>> +             (let* ((out (assoc-ref outputs "out"))
>> +                    (sipdir (string-append out "/share/sip"))
>> +                    (pyqt-sipdir (string-append
>> +                                  (assoc-ref inputs "python-pyqt") "/share/sip"))
>> +                    (python (assoc-ref inputs "python"))
>> +                    (python-version
>> +                     (last (string-split python #\-)))
>> +                    (python-major+minor
>> +                     (string-join
>> +                      (take (string-split python-version #\.) 2)
>> +                      "."))
>
> Use version-major+minor from (guix utils) instead?

This is not an easy fix, I actually snarfed this from python-pyqt. In
fact most of the python packages in this file use this
method. Unfortunately version-major+minor cannot take an input, it needs
to take a guix package record.

This creates some scoping issues, in order to get the version for
python. you would need to do something like

semi pseudo code.
--8<---------------cut here---------------start------------->8---
(begin (use-modules (gnu packages python)) (version-major+minor python))
--8<---------------cut here---------------end--------------->8---

This approach in theory works only when the input is python. But take
the scenario were the input changes to a specific python version. Then
our above code will still work but no longer produce the correct path.

How python-build-system handles this. Is the same way as this let. In
fact it looks like they wer copied verbatim.

Unfortunately these python packages don't use python setuptools. So
gnu-build-system is used instead. Even if we could use
python-build-system. This would just make the code more ascetically
pleasing. The underlying code would still be the same.

The string parsing is not pretty, but it at least functional. If the
input version changes the so probably will the path.

Mike