diff options
-rw-r--r-- | guix-module-dir/hydrilla.scm | 30 |
1 files 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 |