summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/language/python/compile.scm78
-rw-r--r--modules/language/python/module.scm18
-rw-r--r--modules/language/python/module/os.scm7
-rw-r--r--modules/language/python/module/os/path.scm2
-rw-r--r--modules/language/python/module/python.scm4
-rw-r--r--modules/language/python/module/sys.scm5
6 files changed, 67 insertions, 47 deletions
diff --git a/modules/language/python/compile.scm b/modules/language/python/compile.scm
index c78c868..032b1c2 100644
--- a/modules/language/python/compile.scm
+++ b/modules/language/python/compile.scm
@@ -182,14 +182,17 @@
((#:global . _)
vs)
- ((#:import (#:name ((ids ...) . as)) ...)
+ ((#:import (#:name ((ids ...) . as) ...) ...)
(let lp ((ids ids) (as as) (vs vs))
- (if (pair? as)
- (lp (cdr ids) (cdr as)
- (let ((as (car as))
- (ids (car ids)))
- (union vs (list (exp '() (if as as (car ids)))))))
- vs)))
+ (if (pair? ids)
+ (let lp2 ((ids2 (car ids)) (as2 (car as)) (vs vs))
+ (if (pair? as2)
+ (lp2 (cdr ids2) (cdr as2)
+ (let ((as2 (car as2))
+ (ids2 (car ids2)))
+ (union vs (list (exp '() (if as2 as2 (car ids2)))))))
+ (lp (cdr ids) (cdr as) vs)))
+ vs)))
((#:expr-stmt l (#:assign u ... v))
(union
@@ -943,34 +946,39 @@
l))))
- ((_ (#:name ((ids ...) . as)) ...)
+ ((_ (#:name ((ids ...) . as) ...) ...)
`(begin
,@(map
- (lambda (ids as)
- (let ((path (map (g vs exp) ids)))
- (if as
- (exp
- vs
- `(#:expr-stmt
- ((#:test (#:power #f ,as ())))
- (#:assign
- ((#:verb
- ((@ (language python module) import)
- ((@ (language python module) Module)
- ',(reverse (append '(language python module) path))
- ',(reverse path))
- ,(exp vs as)))))))
- (exp
- vs
- `(#:expr-stmt
- ((#:test (#:power #f ,(car ids) ())))
- (#:assign
- ((#:verb
- ((@ (language python module) import)
- ((@ (language python module) Module)
- ',(append '(language python module) path))
- ,(exp vs (car ids)))))))))))
- ids as))))
+ (lambda (ids as)
+ `(begin
+ ,@(map (lambda (ids as)
+ (let ((path (map (g vs exp) ids)))
+ (if as
+ (exp
+ vs
+ `(#:expr-stmt
+ ((#:test (#:power #f ,as ())))
+ (#:assign
+ ((#:verb
+ ((@ (language python module) import)
+ ((@ (language python module) Module)
+ ',(reverse (append
+ '(language python module)
+ path))
+ ',(reverse path))
+ ,(exp vs as)))))))
+ (exp
+ vs
+ `(#:expr-stmt
+ ((#:test (#:power #f ,(car ids) ())))
+ (#:assign
+ ((#:verb
+ ((@ (language python module) import)
+ ((@ (language python module) Module)
+ ',(append '(language python module) path))
+ ,(exp vs (car ids)))))))))))
+ ids as)))
+ ids as))))
(#:for
((_ e in code . #f)
@@ -1002,6 +1010,7 @@
((arg1 arg2)
(let ((v1 (gensym "va"))
(v2 (gensym "vb"))
+ (x (string->symbol x))
(lp (gensym "lp")))
`(let ((,v1 ,(exp vs arg1))
(,v2 ,(exp vs arg2)))
@@ -1014,9 +1023,10 @@
(let ((v1 (gensym "va"))
(v2 (gensym "vb"))
(st (gensym "vs"))
+ (x (string->symbol x))
(lp (gensym "lp")))
`(let ((,v1 ,(exp vs arg1))
- (,st ,(exp vs arg2))
+ (,st ,(exp vs arg2))
(,v2 ,(exp vs arg3)))
(if (> st 0)
(let ,lp ((,x ,v1))
diff --git a/modules/language/python/module.scm b/modules/language/python/module.scm
index 3453a25..aacf3a1 100644
--- a/modules/language/python/module.scm
+++ b/modules/language/python/module.scm
@@ -61,8 +61,8 @@
((ref it '__update__) pre l nm)
(rawset self id (Module pre l nm)))
#f)))
-
- (define __init__
+
+ (define __init__
(case-lambda
((self pre l nm)
(match l
@@ -85,11 +85,15 @@
(list-ref l 1)
(list-ref l 2))
'(language python module)))
- (__init__ self (reverse '(language python module)) (cdddr l) '())
- #f)
+ (__init__ self (reverse '(language python module)) (cdddr l)
+ '())
+ (__init__ self '() l '()))
(__init__ self
- (map string->symbol
- (string-split l #\.)))))))
+ (append
+ '(language python module)
+ (map string->symbol
+ (string-split l #\.))))))))
+
(define __update__
(case-lambda
((self pre l nm)
@@ -221,7 +225,7 @@
(else
#f)) a ...)))))
-(define (m? x) ((@ (language python module python) isinstance) x Module))
+(define (m? x) ((@ (language python module _python) isinstance) x Module))
(define (import-f x f . l)
(if x
(if (m? x)
diff --git a/modules/language/python/module/os.scm b/modules/language/python/module/os.scm
index d985501..afed9d1 100644
--- a/modules/language/python/module/os.scm
+++ b/modules/language/python/module/os.scm
@@ -11,6 +11,7 @@
#:use-module (language python persist)
#:use-module (language python try)
#:use-module (language python module stat)
+ #:use-module (language python module)
#:use-module (language python exceptions)
#:use-module (language python yield)
#:use-module (language python range)
@@ -36,8 +37,8 @@
setresgid setreuid setresuid getsid setsid setuid strerr
umask uname unsetenv
- path curdir pardir sep extsep altsep pathsep linesep defpath
- devnull
+ curdir pardir sep extsep altsep pathsep linesep defpath
+ devnull path
dopen close closerange device_encoding dup dup2 fchmod fchown
fdatasync fpathconf fstat fstatvfs fsynch ftruncate isatty
@@ -2296,7 +2297,6 @@
(bytevector-ieee-double-ref v 8 (native-endianness))
(bytevector-ieee-double-ref v 16 (native-endianness)))))))
-(define path "posixpath")
(define curdir ".")
(define pardir "..")
(define sep "/")
@@ -2338,3 +2338,4 @@
(define (getrandom . l)
(py-list (apply getrandom_ l)))
+(define path "posixpath")
diff --git a/modules/language/python/module/os/path.scm b/modules/language/python/module/os/path.scm
index 0c1abde..1853c86 100644
--- a/modules/language/python/module/os/path.scm
+++ b/modules/language/python/module/os/path.scm
@@ -15,7 +15,7 @@
getctime getsize isabs isfile isdir islink ismount
normcase normpath realpath relpath samefile sameopenfile
samestat split splitdrive splitext splitunc
- supports_unicode_filenames))
+ supports_unicode_filenames join))
(define-syntax-rule (aif it p x y) (let ((it p)) (if it x y)))
diff --git a/modules/language/python/module/python.scm b/modules/language/python/module/python.scm
index 3ae04e7..4c274ea 100644
--- a/modules/language/python/module/python.scm
+++ b/modules/language/python/module/python.scm
@@ -1,6 +1,7 @@
(define-module (language python module python )
#:use-module (language python module _python)
#:use-module (language python compile )
+ #:use-module (language python module )
#:use-module ((language python format2) #:select ()))
(define-syntax re-export-all
@@ -18,4 +19,7 @@
(module-re-export! (current-module) ((@ (guile) list) name))))
(resolve-interface 'iface)))]))
+(set! (@ (language python module os) path)
+ (Module '(language python module os path)))
+
(re-export-all (language python module _python))
diff --git a/modules/language/python/module/sys.scm b/modules/language/python/module/sys.scm
index 7108b45..1ca3992 100644
--- a/modules/language/python/module/sys.scm
+++ b/modules/language/python/module/sys.scm
@@ -9,7 +9,8 @@
__stdin__ __stdout__ __stderr__
exit version_info version api_version
warnoptions winver _xoption
- tarcebacklimit platform maxsize hash_info))
+ tarcebacklimit platform maxsize hash_info
+ base_prefix))
(define-syntax stdin
(lambda (x)
@@ -45,7 +46,7 @@
(define abiflags '(""))
(define argv (command-line))
(define base_exec_prefix #f)
-(define base_prefix #f)
+(define base_prefix "/usr")
(define byteorder (if (eq? (native-endianness) 'little)
"little"
"big"))