aboutsummaryrefslogtreecommitdiff
path: root/guix-module-dir/hydrilla.scm
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-11-24 10:46:12 +0100
committerWojtek Kosior <koszko@koszko.org>2022-11-24 10:46:12 +0100
commit6875e5b91390e1e6b7e8493068ae5812997097a0 (patch)
tree3fea898b4a5c26c8b614921341a1dcb7230a62c1 /guix-module-dir/hydrilla.scm
parentea0bfa9ea01f7badeeb30557e7254c3447fc4de3 (diff)
downloadhaketilo-hydrilla-6875e5b91390e1e6b7e8493068ae5812997097a0.tar.gz
haketilo-hydrilla-6875e5b91390e1e6b7e8493068ae5812997097a0.zip
prepare Hydrilla package module for use from a containing git repo
Diffstat (limited to 'guix-module-dir/hydrilla.scm')
-rw-r--r--guix-module-dir/hydrilla.scm30
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