summaryrefslogtreecommitdiff
path: root/modules/python.in
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2019-06-01 23:06:30 +0200
committerRicardo Wurmus <rekado@elephly.net>2019-06-01 23:06:30 +0200
commit0b9dad593e5cec7345f33b3ce1545ef2849d3696 (patch)
treed7eee9506e867099ca651452f38395880e0141d8 /modules/python.in
parenta6a16c807797c5181f8b86e18202b3ae063f1a43 (diff)
Add simple Python executable.
* modules/python.in: New file. * modules/configure.ac: Configure it. * .gitignore: Hide generated file.
Diffstat (limited to 'modules/python.in')
-rwxr-xr-xmodules/python.in29
1 files changed, 29 insertions, 0 deletions
diff --git a/modules/python.in b/modules/python.in
new file mode 100755
index 0000000..1dad073
--- /dev/null
+++ b/modules/python.in
@@ -0,0 +1,29 @@
+#!@GUILE@ \
+--no-auto-compile -e main -s
+!#
+
+(use-modules (ice-9 match)
+ (language python spec)
+ (language python module python)
+ (system repl common)
+ (system repl repl))
+
+(define* (main #:optional (args (command-line)))
+ (match args
+ ((_ file)
+ (let ((compiled (string-append file ".go")))
+ (compile-file file
+ #:from python
+ #:output-file compiled)
+ (load-compiled compiled)))
+ ((_)
+ (repl-default-option-set! 'prompt ">>> ")
+ (set! (@@ (system repl common) repl-welcome)
+ (const (display "\
+Python on Guile, version @VERSION@
+(Hit Ctrl-D to exit.)
+")))
+ (start-repl python)
+ #t)
+ (_ (format (current-error-port)
+ "usage: ~a file.py~%" this))))