Subject: bug#52684: [BUG] Multiple Packages Failing to Build

From: Christopher Rodriguez <[email-masked]>
Date: Wed, 22 Dec 2021 14:59:09 -0500

I've been digging through the source, and it seems as though 
`python-build-system` does not actually set the $GUIX_PYTHONPATH 
variable in the environment. That variable seems to only be set by 
`python-2.7` and its derivatives, including `python3.9`, during a step 
after the install process.

I don't know if this is intended. If it is, that would mean that 
(currently) there is no easy way to set the $GUIX_PYTHONPATH variable 
outside of installing `python` in a profile. That would certainly be the 
most expedient way forward (and how it would be done on traditional 
distros).

Right now, beets is still calling the version of python in `/gnu/store`, 
but since it isn't installed alongside `beets` as a propagated-input the 
post-install step which sets that variable (which is called 
`install-sitecustomize.py` and relies of the package version of the 
python package being installed) is never run, and therefore the 
environment variable remains unset in the profile.

Both `guix install python` and `export 
GUIX_PYTHONPATH=/gnu/..../site-packages` work to allow the environment 
variable to be set. But it might be better and more future-proof to just 
install python in the profile as a dependency, since the program itself 
actually depends on `python` anyway.

What do You think?

Here is the relevant code, from /gnu/packages/python.scm.

```scheme

;Top of file

(define* (customize-site version)
   "Generate a install-sitecustomize.py phase, using VERSION."
   `(lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
      (let* ((out (assoc-ref outputs "out"))
             (site-packages (string-append
                             out "/lib/python"
                             ,(version-major+minor version)
                             "/site-packages"))
             (sitecustomize.py (assoc-ref (or native-inputs inputs)
                                          "sitecustomize.py"))
             (dest (string-append site-packages "/sitecustomize.py")))
        (mkdir-p site-packages)
        (copy-file sitecustomize.py dest)
        ;; Set the correct permissions on the installed file, else the 
byte 

        ;; compilation phase fails with a permission denied error. 

        (chmod dest #o644))))

---8<-----------------------------------------------------------------
; python2.7 definition
	...
	...
          (add-after 'install 'install-sitecustomize.py
            ,(customize-site version)))))

```