Subject: Re: [PATCH 081/602] gnu: renpy: Build with Python 3.

From: Maxim Cournoyer <[email-masked]>
Date: Fri, 17 Jun 2022 01:09:05 -0400

Hi Liliana,

We have a nice opportunity at the moment to truly phase out Python 2
from Guix, with just a handful packages remaining that still depend on
it, so I'd like to focus on options other than re-introducing Python 2
dependencies at first.

I tried updating the package like so:

--8<---------------cut here---------------start------------->8---
diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index 4c1b97f041..89602dc127 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -1208,7 +1208,8 @@ (define-public python-pygame
 
 (define-public python-pygame-sdl2
   (let ((real-version "2.1.0")
-        (renpy-version "7.4.11"))
+        ;; Use a pre-release version to match that of Renpy.
+        (renpy-version "8.0.0"))
     (package
       (inherit python-pygame)
       (name "python-pygame-sdl2")
@@ -1216,17 +1217,16 @@ (define-public python-pygame-sdl2
       (source
        (origin
          (method url-fetch)
-         (uri (string-append "https://www.renpy.org/dl/" renpy-version
+         (uri (string-append "https://www.renpy.org/dl/prerelease-8"
                              "/pygame_sdl2-" version ".tar.gz"))
-         (sha256 (base32 "0nxvca16299jx6sp0ys29rqixcs21ymhqwjfkbchhss0yar7qjgz"))
+         (sha256 (base32 "1ml3650czvzi0k9ap12zz7ykldhzzk0251ncl62wdmncfqfq98wd"))
          (modules '((guix build utils)))
          (snippet
           '(begin
              ;; drop generated sources
              (delete-file-recursively "gen")
              (delete-file-recursively "gen3")
-             (delete-file-recursively "gen-static")
-             #t))))
+             (delete-file-recursively "gen-static")))))
       (build-system python-build-system)
       (arguments
        `(#:tests? #f                ; tests require pygame to be installed first
@@ -1243,8 +1243,7 @@ (define-public python-pygame-sdl2
                                       (assoc-ref inputs "sdl-union")
                                       "/lib -Wl,-rpath,"
                                       (assoc-ref inputs "sdl-union")
-                                      "/lib -Wl,--enable-new-dtags -lSDL2"))
-               #t)))))
+                                      "/lib -Wl,--enable-new-dtags -lSDL2")))))))
       (inputs
        (list (sdl-union (list sdl2 sdl2-image sdl2-mixer sdl2-ttf))))
       (native-inputs
@@ -1260,22 +1259,23 @@ (define-public python-pygame-sdl2
 (define-public renpy
   (package
     (name "renpy")
-    (version "7.4.11")
-    (source
-     (origin
-       (method url-fetch)
-       (uri (string-append "https://www.renpy.org/dl/" version
-                           "/renpy-" version "-source.tar.bz2"))
-       (sha256 (base32 "0zkhg2sd2hglm9dkansf4h8sq7lm7iqslzl763ambp4kyfdvd07q"))
-       (modules '((guix build utils)))
-       (patches
-        (search-patches
-         "renpy-use-system-fribidi.patch"))
-       (snippet
-        '(with-directory-excursion "module"
-           ;; drop fribidi sources
-           (delete-file-recursively "fribidi-src")
-           #t))))
+    ;; Use a pre-release version to avoid Python 2, which the last stable 7.5
+    ;; release is still using.
+    (version "8.0.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://www.renpy.org/dl/prerelease-8"
+                                  "/renpy-" version "-source.tar.bz2"))
+              (modules '((guix build utils)))
+              (snippet
+               '(with-directory-excursion "module"
+                  ;; drop fribidi sources
+                  (delete-file-recursively "fribidi-src")))
+              (sha256
+               (base32
+                "0bxihc8lkjmp769i4ih74si76i0lvdw86dg5j005kbj4m4cpvvax"))
+              (patches
+               (search-patches "renpy-use-system-fribidi.patch"))))
     (build-system python-build-system)
     (arguments
      `(#:tests? #f                      ; Ren'py doesn't seem to package tests
@@ -1299,7 +1299,7 @@ (define-public renpy
                                         "/bin/cython"))
              (setenv "RENPY_DEPS_INSTALL" (string-join (map cdr inputs) ":"))))
          (replace 'build
-           (lambda* (#:key inputs outputs #:allow-other-keys #:rest args)
+           (lambda args
              ;; The "module" subdirectory contains a python (really cython)
              ;; project, which is built using a script, that is thankfully
              ;; named "setup.py".
--8<---------------cut here---------------end--------------->8---

It currently fails to build due to a new dependency, 'tinyfiledialogs':

--8<---------------cut here---------------start------------->8---
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fno-semantic-interposition -fPIC -I. -I/gnu/store/rvjwhr9ib88fm3s2h04n8jl4qpnb54rl-sdl-union-1.2.15/include -I/gnu/store/p7iq81hxxyk9zy7a9dngbf16zm8d4klx-libpng-1.6.37/include -I/gnu/store/rvjwhr9ib88fm3s2h04n8jl4qpnb54rl-sdl-union-1.2.15/include/SDL2 -I/gnu/store/ak70pk2hjks17cx7zjdmdmzpcpiy9gpi-freetype-2.10.4/include/freetype2 -I/gnu/store/jgmr3siy9dr8snlym3dfjbj0gmjzm2zk-ffmpeg-4.4.2/include -I/gnu/store/sh6j1xz8fz7a23x5y2w05rzxjamq4x7y-glew-2.1.0/include -I/gnu/store/9bx852151mzmmbpm92q46zk104qnan1d-python-pygame-sdl2-2.1.0-for-renpy-8.0.0/include/python3.9 -I/gnu/store/65i3nhcwmz0p8rqbg48gaavyky4g4hwk-python-3.9.9/include/python3.9 -c gen3/_renpytfd.c -o build/temp.linux-x86_64-3.9/gen3/_renpytfd.o -std=gnu99 -Wno-unused-function
gen3/_renpytfd.c:618:10: fatal error: tinyfiledialogs/tinyfiledialogs.h: No such file or directory
  618 | #include "tinyfiledialogs/tinyfiledialogs.h"
--8<---------------cut here---------------end--------------->8---

> OTOH if our stance is that we really
> don't want any python 2 stuff in Guix and rather have people use time
> machine, I think we should loudly break the package (by removing it)
> rather than silently.

That appears to be exactly what NixOS has done:

$ nix edit nixpkgs#renpy
error: renpy has been removed from nixpkgs, it was unmaintained and the
latest packaged version required python2

I think finishing the update started above would be a better option than
removing it, if we have the bandwidth to tackle the update.  Would you
like to give it a try?

Thanks,

Maxim