summaryrefslogtreecommitdiff
path: root/modules/python.in
blob: 6b572423aab77b6aeb4c2dcba92910efbd4071a0 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!@GUILE@ \
--no-auto-compile -e main -s
!#

(eval-when (expand load eval)
  (set! %load-path
    (cons "@prefix@/share/guile/site/@GUILE_EFFECTIVE_VERSION@" %load-path))
  (set! %load-compiled-path
    (cons "@libdir@/guile/@GUILE_EFFECTIVE_VERSION@/site-ccache"
          %load-compiled-path)))

(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))))