From 0b9dad593e5cec7345f33b3ce1545ef2849d3696 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sat, 1 Jun 2019 23:06:30 +0200 Subject: Add simple Python executable. * modules/python.in: New file. * modules/configure.ac: Configure it. * .gitignore: Hide generated file. --- .gitignore | 2 +- modules/configure.ac | 1 + modules/python.in | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 modules/python.in diff --git a/.gitignore b/.gitignore index 30bd0f0..67a44e8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,4 @@ modules/configure modules/env modules/libtool modules/m4/ - +modules/python diff --git a/modules/configure.ac b/modules/configure.ac index 5245123..9d483d0 100644 --- a/modules/configure.ac +++ b/modules/configure.ac @@ -13,6 +13,7 @@ GUILE_PKG([3.0 2.2 2.1 2.0]) GUILE_PROGS AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([python], [chmod +x python]) AC_CONFIG_FILES([env], [chmod +x env]) AC_OUTPUT 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)))) -- cgit v1.2.3