Subject: [PATCH 2/2] gnu: python-hy: Report version.

From: Jack Hill <[email-masked]>
Date: Tue, 7 Mar 2023 14:57:36 -0500

* gnu/packages/python-xyz.scm (python-hy)[arguments]{phases}: Add
set-version and remove-installed-build-scripts.
---
 gnu/packages/python-xyz.scm | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 7a1866314e..88138db1f4 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -58,7 +58,7 @@
 ;;; Copyright © 2015, 2018 Pjotr Prins <[email-masked]>
 ;;; Copyright © 2019, 2020 Brett Gilio <[email-masked]>
 ;;; Copyright © 2019 Sam <[email-masked]>
-;;; Copyright © 2019 Jack Hill <[email-masked]>
+;;; Copyright © 2019, 2023 Jack Hill <[email-masked]>
 ;;; Copyright © 2019, 2020, 2021, 2022 Guillaume Le Vaillant <[email-masked]>
 ;;; Copyright © 2019, 2020 Alex Griffin <[email-masked]>
 ;;; Copyright © 2019, 2020, 2021, 2022 Pierre Langlois <[email-masked]>
@@ -15020,17 +15020,29 @@ (define-public python-hy
         (base32 "1czhh7s81sg0nrnf4zv0ydqi4f7s6sywf4ks4fd59vpx441ca39v"))))
     (build-system python-build-system)
     (arguments
-     '(#:phases
-       (modify-phases %standard-phases
-         (replace 'check
-           (lambda* (#:key tests? #:allow-other-keys)
-             (when tests?
-               (invoke "python" "-m" "pytest" "-k"
-                       (string-append   ; skip some failed tests
-                        "not test_sys_executable"
-                        " and not test_circular_macro_require"
-                        " and not test_macro_require"
-                        " and not test_requires_pollutes_core"))))))))
+     (list
+      #:phases
+      #~(modify-phases %standard-phases
+          ;; Hy includes a script that writes a version.py file the Hy uses to
+          ;; report its version. That script uses information from the git
+          ;; repository or the HY_VERSION environment variable. Therefore,
+          ;; these phases et HY_VERSION and then remove the support scripts
+          ;; which get installed in the root of the output.
+          (add-after 'unpack 'set-version
+            (lambda _
+              (setenv "HY_VERSION" #$version)))
+          (add-after 'install 'remove-installed-build-scripts
+            (lambda _
+              (delete-file-recursively (string-append #$output "/get_version"))))
+          (replace 'check
+            (lambda* (#:key tests? #:allow-other-keys)
+              (when tests?
+                (invoke "python" "-m" "pytest" "-k"
+                        (string-append   ; skip some failed tests
+                         "not test_sys_executable"
+                         " and not test_circular_macro_require"
+                         " and not test_macro_require"
+                         " and not test_requires_pollutes_core"))))))))
     (native-inputs
      (list python-pytest-7.1 python-wheel))
     (propagated-inputs
-- 
2.39.1