From 6875e5b91390e1e6b7e8493068ae5812997097a0 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Thu, 24 Nov 2022 10:46:12 +0100 Subject: prepare Hydrilla package module for use from a containing git repo --- guix-module-dir/hydrilla.scm | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/guix-module-dir/hydrilla.scm b/guix-module-dir/hydrilla.scm index 1e266af..6e74a0b 100644 --- a/guix-module-dir/hydrilla.scm +++ b/guix-module-dir/hydrilla.scm @@ -10,21 +10,29 @@ (ice-9 rdelim) (ice-9 regex)) -;; We're mostly running from Makefile, so it's pretty safe to use `getcwd`. -(define %source-dir (getcwd)) +(define %source-dir + (let* ((this-file (search-path %load-path "hydrilla.scm")) + (proj-dir (dirname (dirname this-file)))) + (if (absolute-file-name? proj-dir) + proj-dir + (string-append (getcwd) "/" proj-dir)))) ;; The PKG-INFO file is generated when running `python3 -m build -s` or similar. ;; It is also automatically included in the source release tarballs. +(define %pkg-info-path + (string-append %source-dir "/src/hydrilla.egg-info/PKG-INFO")) + (define %hydrilla-version - (if (access? "src/hydrilla.egg-info/PKG-INFO" R_OK) - (let* ((port (open-input-file "src/hydrilla.egg-info/PKG-INFO")) - (process-line - (lambda (self-ref) - (let ((match-result - (string-match "^Version: (.*)" (read-line port)))) - (if match-result (match:substring match-result 1) - (self-ref self-ref)))))) - (process-line process-line)) + (if (access? %pkg-info-path R_OK) + (call-with-input-file %pkg-info-path + (lambda (port) + (let ((process-line + (lambda (self-ref) + (let ((match-result + (string-match "^Version: (.*)" (read-line port)))) + (if match-result (match:substring match-result 1) + (self-ref self-ref)))))) + (process-line process-line)))) "unknown")) (define source-tarball-name -- cgit v1.2.3