unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Python-on-guile
@ 2021-04-23 15:00 Mikael Djurfeldt
  2021-04-23 20:35 ` Python-on-guile Zelphir Kaltstahl
                   ` (5 more replies)
  0 siblings, 6 replies; 38+ messages in thread
From: Mikael Djurfeldt @ 2021-04-23 15:00 UTC (permalink / raw)
  To: guile-user, guile-devel

Hi,

Yesterday, Andy committed new code to the compiler, some of which concerned
skipping some arity checking.

Also, Stefan meanwhile committed something called "reworked object system"
to his python-on-guile.

Sorry for coming with unspecific information (don't have time to track down
the details) but I noticed that my benchmark script written in Python, and
which computes the 20:th Ramanujan number, now runs 60% faster than before
these changes.

This means that python-on-guile running on guile3 master executes python
code only 2.6 times slower than the CPython python3 interpreter itself. :-)

Have a nice weekend all,
Mikael


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-23 15:00 Python-on-guile Mikael Djurfeldt
@ 2021-04-23 20:35 ` Zelphir Kaltstahl
  2021-04-23 20:41 ` Python-on-guile Linus Björnstam
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 38+ messages in thread
From: Zelphir Kaltstahl @ 2021-04-23 20:35 UTC (permalink / raw)
  To: guile-user

: ) Good to have an idea about how fast it is. Thank you!

On 4/23/21 5:00 PM, Mikael Djurfeldt wrote:
> Hi,
>
> Yesterday, Andy committed new code to the compiler, some of which concerned
> skipping some arity checking.
>
> Also, Stefan meanwhile committed something called "reworked object system"
> to his python-on-guile.
>
> Sorry for coming with unspecific information (don't have time to track down
> the details) but I noticed that my benchmark script written in Python, and
> which computes the 20:th Ramanujan number, now runs 60% faster than before
> these changes.
>
> This means that python-on-guile running on guile3 master executes python
> code only 2.6 times slower than the CPython python3 interpreter itself. :-)
>
> Have a nice weekend all,
> Mikael

-- 
repositories: https://notabug.org/ZelphirKaltstahl




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-23 15:00 Python-on-guile Mikael Djurfeldt
  2021-04-23 20:35 ` Python-on-guile Zelphir Kaltstahl
@ 2021-04-23 20:41 ` Linus Björnstam
  2021-04-23 21:04 ` Python-on-guile Matt Wette
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 38+ messages in thread
From: Linus Björnstam @ 2021-04-23 20:41 UTC (permalink / raw)
  To: Mikael Djurfeldt, guile-user, guile-devel

Hurra!

I noticed a couple.of weeks ago that declarative modules made it possible for me to stop using define-syntax-rule to force stupid inlining of code. The cross module inlining branch will make that even nicer. I can write cleaner code and get better error messages :)

Guile has been going in a very nice direction for some time!
-- 
  Linus Björnstam

On Fri, 23 Apr 2021, at 17:00, Mikael Djurfeldt wrote:
> Hi,
> 
> Yesterday, Andy committed new code to the compiler, some of which 
> concerned skipping some arity checking.
> 
> Also, Stefan meanwhile committed something called "reworked object 
> system" to his python-on-guile.
> 
> Sorry for coming with unspecific information (don't have time to track 
> down the details) but I noticed that my benchmark script written in 
> Python, and which computes the 20:th Ramanujan number, now runs 60% 
> faster than before these changes.
> 
> This means that python-on-guile running on guile3 master executes 
> python code only 2.6 times slower than the CPython python3 interpreter 
> itself. :-)
> 
> Have a nice weekend all,
> Mikael
> 



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-23 15:00 Python-on-guile Mikael Djurfeldt
  2021-04-23 20:35 ` Python-on-guile Zelphir Kaltstahl
  2021-04-23 20:41 ` Python-on-guile Linus Björnstam
@ 2021-04-23 21:04 ` Matt Wette
  2021-04-24  9:43   ` Python-on-guile Mikael Djurfeldt
  2021-04-24 10:04 ` Python-on-guile Mikael Djurfeldt
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 38+ messages in thread
From: Matt Wette @ 2021-04-23 21:04 UTC (permalink / raw)
  To: guile-user

On 4/23/21 8:00 AM, Mikael Djurfeldt wrote:
> Hi,
>
> Yesterday, Andy committed new code to the compiler, some of which concerned
> skipping some arity checking.
>
> Also, Stefan meanwhile committed something called "reworked object system"
> to his python-on-guile.
>
> Sorry for coming with unspecific information (don't have time to track down
> the details) but I noticed that my benchmark script written in Python, and
> which computes the 20:th Ramanujan number, now runs 60% faster than before
> these changes.
>
> This means that python-on-guile running on guile3 master executes python
> code only 2.6 times slower than the CPython python3 interpreter itself. :-)
>
> Have a nice weekend all,
> Mikael
A fun comparison might be python-on-guile3 vs Jython.





^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-23 21:04 ` Python-on-guile Matt Wette
@ 2021-04-24  9:43   ` Mikael Djurfeldt
  0 siblings, 0 replies; 38+ messages in thread
From: Mikael Djurfeldt @ 2021-04-24  9:43 UTC (permalink / raw)
  To: Matt Wette; +Cc: guile-user

[-- Attachment #1: Type: text/plain, Size: 1131 bytes --]

On my machine, Jython runs 1.4 times slower than python3, that is almost
double the speed of python-on-guile.

I attach the script which can be run by simply typing, e.g.,

  python3 ramanujan20.py

and should print out

  262656

On Fri, Apr 23, 2021 at 11:05 PM Matt Wette <matt.wette@gmail.com> wrote:

> On 4/23/21 8:00 AM, Mikael Djurfeldt wrote:
> > Hi,
> >
> > Yesterday, Andy committed new code to the compiler, some of which
> concerned
> > skipping some arity checking.
> >
> > Also, Stefan meanwhile committed something called "reworked object
> system"
> > to his python-on-guile.
> >
> > Sorry for coming with unspecific information (don't have time to track
> down
> > the details) but I noticed that my benchmark script written in Python,
> and
> > which computes the 20:th Ramanujan number, now runs 60% faster than
> before
> > these changes.
> >
> > This means that python-on-guile running on guile3 master executes python
> > code only 2.6 times slower than the CPython python3 interpreter itself.
> :-)
> >
> > Have a nice weekend all,
> > Mikael
> A fun comparison might be python-on-guile3 vs Jython.
>
>
>
>

[-- Attachment #2: ramanujan20.py --]
[-- Type: text/x-python, Size: 1725 bytes --]

#!/usr/bin/python3

#  ramanujan.py -- Compute the N:th Ramanujan number
#  
#  Copyright (C) 2018-2021 Mikael Djurfeldt
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# Version 2

# return the N:th Ramanujan number (sum of two cubes in more than one way)
#
def ramanujan (n):
    w = 0 # Ramanujan number candidate
    b0 = 1 # first second term to try
    while n > 0:
        w += 1 # try next candidate

        # increase initial b0 until 1 + b0^3 >=w
        while 1 + b0 * b0 * b0 < w:
            b0 += 1
            
        a = 1
        a3 = 1
        b = b0
        b3 = b0 * b0 * b0
        count = 0 # number of ways to write w
        while a <= b:
            s = a3 + b3
            if s < w:
                a += 1 # if sum is too small, increase a
                a3 = a * a * a
                continue
            elif s == w:
                count += 1 # found a sum!
                if count > 1:
                    n -= 1
                    break
            b -= 1 # increase b both if sum too large and to find next way to write w
            b3 = b * b * b
    return w

print (ramanujan (20))

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-23 15:00 Python-on-guile Mikael Djurfeldt
                   ` (2 preceding siblings ...)
  2021-04-23 21:04 ` Python-on-guile Matt Wette
@ 2021-04-24 10:04 ` Mikael Djurfeldt
  2021-04-24 11:26   ` Python-on-guile Stefan Israelsson Tampe
  2021-04-25 10:18 ` Python-on-guile Stefan Israelsson Tampe
  2021-04-27 12:29 ` Python-on-guile Nala Ginrut
  5 siblings, 1 reply; 38+ messages in thread
From: Mikael Djurfeldt @ 2021-04-24 10:04 UTC (permalink / raw)
  To: guile-user, guile-devel

(I should perhaps add that my script doesn't benchmark the object system
but rather loops, conditionals and integer arithmetic.)

Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com> skrev:

> Hi,
>
> Yesterday, Andy committed new code to the compiler, some of which
> concerned skipping some arity checking.
>
> Also, Stefan meanwhile committed something called "reworked object system"
> to his python-on-guile.
>
> Sorry for coming with unspecific information (don't have time to track
> down the details) but I noticed that my benchmark script written in Python,
> and which computes the 20:th Ramanujan number, now runs 60% faster than
> before these changes.
>
> This means that python-on-guile running on guile3 master executes python
> code only 2.6 times slower than the CPython python3 interpreter itself. :-)
>
> Have a nice weekend all,
> Mikael
>
>


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-24 10:04 ` Python-on-guile Mikael Djurfeldt
@ 2021-04-24 11:26   ` Stefan Israelsson Tampe
  2021-04-24 12:59     ` Python-on-guile Stefan Israelsson Tampe
  0 siblings, 1 reply; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-24 11:26 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user, guile-devel

[-- Attachment #1: Type: text/plain, Size: 1199 bytes --]

Pro tip, when running this on guile the scheme code that it compilse to is
located in log.txt.
If you ,opt the resulting code in a guile session you might be able to
pinpoint issues that
delays the code execution.

On Sat, Apr 24, 2021 at 12:04 PM Mikael Djurfeldt <mikael@djurfeldt.com>
wrote:

> (I should perhaps add that my script doesn't benchmark the object system
> but rather loops, conditionals and integer arithmetic.)
>
> Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com> skrev:
>
>> Hi,
>>
>> Yesterday, Andy committed new code to the compiler, some of which
>> concerned skipping some arity checking.
>>
>> Also, Stefan meanwhile committed something called "reworked object
>> system" to his python-on-guile.
>>
>> Sorry for coming with unspecific information (don't have time to track
>> down the details) but I noticed that my benchmark script written in Python,
>> and which computes the 20:th Ramanujan number, now runs 60% faster than
>> before these changes.
>>
>> This means that python-on-guile running on guile3 master executes python
>> code only 2.6 times slower than the CPython python3 interpreter itself. :-)
>>
>> Have a nice weekend all,
>> Mikael
>>
>>

[-- Attachment #2: Type: text/html, Size: 1931 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-24 11:26   ` Python-on-guile Stefan Israelsson Tampe
@ 2021-04-24 12:59     ` Stefan Israelsson Tampe
  2021-04-24 14:41       ` Python-on-guile Stefan Israelsson Tampe
  2021-04-25 10:54       ` Python-on-guile Dr. Arne Babenhauserheide
  0 siblings, 2 replies; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-24 12:59 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user, guile-devel

Actually changing in (language python compile),

(define (letec f)
  (let/ec x (f x))))

To

(define-syntax-rule (letec f)
  (let/ec x (f x))))

Actually lead to similar speeds as python3.



On Sat, Apr 24, 2021 at 1:26 PM Stefan Israelsson Tampe <
stefan.itampe@gmail.com> wrote:

> Pro tip, when running this on guile the scheme code that it compilse to is
> located in log.txt.
> If you ,opt the resulting code in a guile session you might be able to
> pinpoint issues that
> delays the code execution.
>
> On Sat, Apr 24, 2021 at 12:04 PM Mikael Djurfeldt <mikael@djurfeldt.com>
> wrote:
>
>> (I should perhaps add that my script doesn't benchmark the object system
>> but rather loops, conditionals and integer arithmetic.)
>>
>> Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com> skrev:
>>
>>> Hi,
>>>
>>> Yesterday, Andy committed new code to the compiler, some of which
>>> concerned skipping some arity checking.
>>>
>>> Also, Stefan meanwhile committed something called "reworked object
>>> system" to his python-on-guile.
>>>
>>> Sorry for coming with unspecific information (don't have time to track
>>> down the details) but I noticed that my benchmark script written in Python,
>>> and which computes the 20:th Ramanujan number, now runs 60% faster than
>>> before these changes.
>>>
>>> This means that python-on-guile running on guile3 master executes python
>>> code only 2.6 times slower than the CPython python3 interpreter itself. :-)
>>>
>>> Have a nice weekend all,
>>> Mikael
>>>
>>>


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-24 12:59     ` Python-on-guile Stefan Israelsson Tampe
@ 2021-04-24 14:41       ` Stefan Israelsson Tampe
  2021-04-24 15:19         ` Python-on-guile Stefan Israelsson Tampe
  2021-04-25 10:54       ` Python-on-guile Dr. Arne Babenhauserheide
  1 sibling, 1 reply; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-24 14:41 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user, guile-devel

[-- Attachment #1: Type: text/plain, Size: 2144 bytes --]

To note is that 'continue' is killing performance for python-on-guile
programs, so by changing the
code to not use continue lead to python-on-guile running twice the speed of
python3. The reason is that
the while loop is used as
(while (...)
   (let/ec continue
        ...))

And the let/ec is probably not optimally compiled. Python-on-guile will
check the loop for continue usage and if not then it will skip the let/ec.

I attached the code not using continue

On Sat, Apr 24, 2021 at 2:59 PM Stefan Israelsson Tampe <
stefan.itampe@gmail.com> wrote:

> Actually changing in (language python compile),
>
> (define (letec f)
>   (let/ec x (f x))))
>
> To
>
> (define-syntax-rule (letec f)
>   (let/ec x (f x))))
>
> Actually lead to similar speeds as python3.
>
>
>
> On Sat, Apr 24, 2021 at 1:26 PM Stefan Israelsson Tampe <
> stefan.itampe@gmail.com> wrote:
>
>> Pro tip, when running this on guile the scheme code that it compilse to
>> is located in log.txt.
>> If you ,opt the resulting code in a guile session you might be able to
>> pinpoint issues that
>> delays the code execution.
>>
>> On Sat, Apr 24, 2021 at 12:04 PM Mikael Djurfeldt <mikael@djurfeldt.com>
>> wrote:
>>
>>> (I should perhaps add that my script doesn't benchmark the object system
>>> but rather loops, conditionals and integer arithmetic.)
>>>
>>> Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com> skrev:
>>>
>>>> Hi,
>>>>
>>>> Yesterday, Andy committed new code to the compiler, some of which
>>>> concerned skipping some arity checking.
>>>>
>>>> Also, Stefan meanwhile committed something called "reworked object
>>>> system" to his python-on-guile.
>>>>
>>>> Sorry for coming with unspecific information (don't have time to track
>>>> down the details) but I noticed that my benchmark script written in Python,
>>>> and which computes the 20:th Ramanujan number, now runs 60% faster than
>>>> before these changes.
>>>>
>>>> This means that python-on-guile running on guile3 master executes
>>>> python code only 2.6 times slower than the CPython python3 interpreter
>>>> itself. :-)
>>>>
>>>> Have a nice weekend all,
>>>> Mikael
>>>>
>>>>

[-- Attachment #2: ram.py --]
[-- Type: text/x-python, Size: 1778 bytes --]

#  ramanujan.py -- Compute the N:th Ramanujan number
#  
#  Copyright (C) 2018-2021 Mikael Djurfeldt
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# Version 2

# return the N:th Ramanujan number (sum of two cubes in more than one way)
#
def ramanujan (n):
    w = 0 # Ramanujan number candidate
    b0 = 1 # first second term to try
    while n > 0:
        w += 1 # try next candidate

        # increase initial b0 until 1 + b0^3 >=w
        while 1 + b0 * b0 * b0 < w:
            b0 += 1
            
        a = 1
        a3 = 1
        b = b0
        b3 = b0 * b0 * b0
        count = 0 # number of ways to write w
        while a <= b:
            s = a3 + b3
            if s < w:
                a += 1 # if sum is too small, increase a
                a3 = a * a * a
            elif s == w:
                count += 1 # found a sum!
                if count > 1:
                    n -= 1
                    break
                b -= 1 # increase b both if sum too large and to find next way to write w
                b3 = b * b * b
            else:
                b -= 1 
                b3 = b * b * b
                
    return w

print (ramanujan (21))

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-24 14:41       ` Python-on-guile Stefan Israelsson Tampe
@ 2021-04-24 15:19         ` Stefan Israelsson Tampe
  2021-04-25  8:20           ` Python-on-guile Mikael Djurfeldt
  2021-04-25  8:46           ` Python-on-guile Stefan Israelsson Tampe
  0 siblings, 2 replies; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-24 15:19 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user, guile-devel

[-- Attachment #1: Type: text/plain, Size: 2455 bytes --]

Guile is 3x faster then fastest python-on-guile which is 2x faster then
python3 Cpython

attached is a guile corresponding program.

On Sat, Apr 24, 2021 at 4:41 PM Stefan Israelsson Tampe <
stefan.itampe@gmail.com> wrote:

> To note is that 'continue' is killing performance for python-on-guile
> programs, so by changing the
> code to not use continue lead to python-on-guile running twice the speed
> of python3. The reason is that
> the while loop is used as
> (while (...)
>    (let/ec continue
>         ...))
>
> And the let/ec is probably not optimally compiled. Python-on-guile will
> check the loop for continue usage and if not then it will skip the let/ec.
>
> I attached the code not using continue
>
> On Sat, Apr 24, 2021 at 2:59 PM Stefan Israelsson Tampe <
> stefan.itampe@gmail.com> wrote:
>
>> Actually changing in (language python compile),
>>
>> (define (letec f)
>>   (let/ec x (f x))))
>>
>> To
>>
>> (define-syntax-rule (letec f)
>>   (let/ec x (f x))))
>>
>> Actually lead to similar speeds as python3.
>>
>>
>>
>> On Sat, Apr 24, 2021 at 1:26 PM Stefan Israelsson Tampe <
>> stefan.itampe@gmail.com> wrote:
>>
>>> Pro tip, when running this on guile the scheme code that it compilse to
>>> is located in log.txt.
>>> If you ,opt the resulting code in a guile session you might be able to
>>> pinpoint issues that
>>> delays the code execution.
>>>
>>> On Sat, Apr 24, 2021 at 12:04 PM Mikael Djurfeldt <mikael@djurfeldt.com>
>>> wrote:
>>>
>>>> (I should perhaps add that my script doesn't benchmark the object
>>>> system but rather loops, conditionals and integer arithmetic.)
>>>>
>>>> Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com>
>>>> skrev:
>>>>
>>>>> Hi,
>>>>>
>>>>> Yesterday, Andy committed new code to the compiler, some of which
>>>>> concerned skipping some arity checking.
>>>>>
>>>>> Also, Stefan meanwhile committed something called "reworked object
>>>>> system" to his python-on-guile.
>>>>>
>>>>> Sorry for coming with unspecific information (don't have time to track
>>>>> down the details) but I noticed that my benchmark script written in Python,
>>>>> and which computes the 20:th Ramanujan number, now runs 60% faster than
>>>>> before these changes.
>>>>>
>>>>> This means that python-on-guile running on guile3 master executes
>>>>> python code only 2.6 times slower than the CPython python3 interpreter
>>>>> itself. :-)
>>>>>
>>>>> Have a nice weekend all,
>>>>> Mikael
>>>>>
>>>>>

[-- Attachment #2: ram.scm --]
[-- Type: text/x-scheme, Size: 1125 bytes --]

(define (ramanujan  n)
  (let lp ((w 0) (b0 1) (n n))
    (if (> n 0)
        (let ((w (+ w 1)))
          (let lp2 ((b0 b0))
            (if (< (+ 1 (* b0 b0 b0)) w)
                (lp2 (+ b0 1))
                (let lp3 ((a 1) (a3 1) (b b0) (b3 (* b0 b0 b0)) (count 0))
                  (if (<= a b)
                      (let ((s (+ a3 b3)))
                        (cond
                         ((< s w)
                          (let ((aa (+ a 1)))
                            (lp3 aa (* aa aa aa) b b3 count)))
                         ((= s w)
                          (let ((count (+ count 1)))
                            (if (> count 1)
                                (lp w b0 (- n 1))
                                (let* ((b   (- b 1))
                                       (b3  (* b b b)))
                                  (lp3 a a3 b b3 count)))))
                         (else
                          (let* ((b   (- b 1))
                                 (b3  (* b b b)))
                            (lp3 a a3 b b3 count)))))
                      (lp w b0 n))))))
        w)))

(pk (ramanujan 20))

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-24 15:19         ` Python-on-guile Stefan Israelsson Tampe
@ 2021-04-25  8:20           ` Mikael Djurfeldt
  2021-04-25 10:21             ` Python-on-guile Stefan Israelsson Tampe
  2021-04-25  8:46           ` Python-on-guile Stefan Israelsson Tampe
  1 sibling, 1 reply; 38+ messages in thread
From: Mikael Djurfeldt @ 2021-04-25  8:20 UTC (permalink / raw)
  To: Stefan Israelsson Tampe; +Cc: guile-user, guile-devel

Nice!

I guess it would be nice if "continue" *could* be compiled efficiently.
And, as you indicate, perhaps that would amount to efficiently compiling
let/ec.

Best regards,
Mikael

On Sat, Apr 24, 2021 at 5:19 PM Stefan Israelsson Tampe <
stefan.itampe@gmail.com> wrote:

> Guile is 3x faster then fastest python-on-guile which is 2x faster then
> python3 Cpython
>
> attached is a guile corresponding program.
>
> On Sat, Apr 24, 2021 at 4:41 PM Stefan Israelsson Tampe <
> stefan.itampe@gmail.com> wrote:
>
>> To note is that 'continue' is killing performance for python-on-guile
>> programs, so by changing the
>> code to not use continue lead to python-on-guile running twice the speed
>> of python3. The reason is that
>> the while loop is used as
>> (while (...)
>>    (let/ec continue
>>         ...))
>>
>> And the let/ec is probably not optimally compiled. Python-on-guile will
>> check the loop for continue usage and if not then it will skip the let/ec.
>>
>> I attached the code not using continue
>>
>> On Sat, Apr 24, 2021 at 2:59 PM Stefan Israelsson Tampe <
>> stefan.itampe@gmail.com> wrote:
>>
>>> Actually changing in (language python compile),
>>>
>>> (define (letec f)
>>>   (let/ec x (f x))))
>>>
>>> To
>>>
>>> (define-syntax-rule (letec f)
>>>   (let/ec x (f x))))
>>>
>>> Actually lead to similar speeds as python3.
>>>
>>>
>>>
>>> On Sat, Apr 24, 2021 at 1:26 PM Stefan Israelsson Tampe <
>>> stefan.itampe@gmail.com> wrote:
>>>
>>>> Pro tip, when running this on guile the scheme code that it compilse to
>>>> is located in log.txt.
>>>> If you ,opt the resulting code in a guile session you might be able to
>>>> pinpoint issues that
>>>> delays the code execution.
>>>>
>>>> On Sat, Apr 24, 2021 at 12:04 PM Mikael Djurfeldt <mikael@djurfeldt.com>
>>>> wrote:
>>>>
>>>>> (I should perhaps add that my script doesn't benchmark the object
>>>>> system but rather loops, conditionals and integer arithmetic.)
>>>>>
>>>>> Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com>
>>>>> skrev:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Yesterday, Andy committed new code to the compiler, some of which
>>>>>> concerned skipping some arity checking.
>>>>>>
>>>>>> Also, Stefan meanwhile committed something called "reworked object
>>>>>> system" to his python-on-guile.
>>>>>>
>>>>>> Sorry for coming with unspecific information (don't have time to
>>>>>> track down the details) but I noticed that my benchmark script written in
>>>>>> Python, and which computes the 20:th Ramanujan number, now runs 60% faster
>>>>>> than before these changes.
>>>>>>
>>>>>> This means that python-on-guile running on guile3 master executes
>>>>>> python code only 2.6 times slower than the CPython python3 interpreter
>>>>>> itself. :-)
>>>>>>
>>>>>> Have a nice weekend all,
>>>>>> Mikael
>>>>>>
>>>>>>


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-24 15:19         ` Python-on-guile Stefan Israelsson Tampe
  2021-04-25  8:20           ` Python-on-guile Mikael Djurfeldt
@ 2021-04-25  8:46           ` Stefan Israelsson Tampe
  1 sibling, 0 replies; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-25  8:46 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user, guile-devel

The remaining 3x between guile and python can be to either the extensive
usage of set! in python or if the number of runs in the inner loop is small
because there is a let/ec for the break and according to the standard
a catch to support the raising of StopIteration. Set! probably cannot
account for 3x speedwise, but it may
hinder optimisations that may yield a speedup of that factor.

On Sat, Apr 24, 2021 at 5:19 PM Stefan Israelsson Tampe <
stefan.itampe@gmail.com> wrote:

> Guile is 3x faster then fastest python-on-guile which is 2x faster then
> python3 Cpython
>
> attached is a guile corresponding program.
>
> On Sat, Apr 24, 2021 at 4:41 PM Stefan Israelsson Tampe <
> stefan.itampe@gmail.com> wrote:
>
>> To note is that 'continue' is killing performance for python-on-guile
>> programs, so by changing the
>> code to not use continue lead to python-on-guile running twice the speed
>> of python3. The reason is that
>> the while loop is used as
>> (while (...)
>>    (let/ec continue
>>         ...))
>>
>> And the let/ec is probably not optimally compiled. Python-on-guile will
>> check the loop for continue usage and if not then it will skip the let/ec.
>>
>> I attached the code not using continue
>>
>> On Sat, Apr 24, 2021 at 2:59 PM Stefan Israelsson Tampe <
>> stefan.itampe@gmail.com> wrote:
>>
>>> Actually changing in (language python compile),
>>>
>>> (define (letec f)
>>>   (let/ec x (f x))))
>>>
>>> To
>>>
>>> (define-syntax-rule (letec f)
>>>   (let/ec x (f x))))
>>>
>>> Actually lead to similar speeds as python3.
>>>
>>>
>>>
>>> On Sat, Apr 24, 2021 at 1:26 PM Stefan Israelsson Tampe <
>>> stefan.itampe@gmail.com> wrote:
>>>
>>>> Pro tip, when running this on guile the scheme code that it compilse to
>>>> is located in log.txt.
>>>> If you ,opt the resulting code in a guile session you might be able to
>>>> pinpoint issues that
>>>> delays the code execution.
>>>>
>>>> On Sat, Apr 24, 2021 at 12:04 PM Mikael Djurfeldt <mikael@djurfeldt.com>
>>>> wrote:
>>>>
>>>>> (I should perhaps add that my script doesn't benchmark the object
>>>>> system but rather loops, conditionals and integer arithmetic.)
>>>>>
>>>>> Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com>
>>>>> skrev:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Yesterday, Andy committed new code to the compiler, some of which
>>>>>> concerned skipping some arity checking.
>>>>>>
>>>>>> Also, Stefan meanwhile committed something called "reworked object
>>>>>> system" to his python-on-guile.
>>>>>>
>>>>>> Sorry for coming with unspecific information (don't have time to
>>>>>> track down the details) but I noticed that my benchmark script written in
>>>>>> Python, and which computes the 20:th Ramanujan number, now runs 60% faster
>>>>>> than before these changes.
>>>>>>
>>>>>> This means that python-on-guile running on guile3 master executes
>>>>>> python code only 2.6 times slower than the CPython python3 interpreter
>>>>>> itself. :-)
>>>>>>
>>>>>> Have a nice weekend all,
>>>>>> Mikael
>>>>>>
>>>>>>


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-23 15:00 Python-on-guile Mikael Djurfeldt
                   ` (3 preceding siblings ...)
  2021-04-24 10:04 ` Python-on-guile Mikael Djurfeldt
@ 2021-04-25 10:18 ` Stefan Israelsson Tampe
  2021-04-27 12:29 ` Python-on-guile Nala Ginrut
  5 siblings, 0 replies; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-25 10:18 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user, guile-devel

[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

Python List lookup is 2x slower now than cpython. Tuple lookup is slightly
faster.

On Fri, 23 Apr 2021, 17:01 Mikael Djurfeldt <mikael@djurfeldt.com> wrote:

> Hi,
>
> Yesterday, Andy committed new code to the compiler, some of which
> concerned skipping some arity checking.
>
> Also, Stefan meanwhile committed something called "reworked object system"
> to his python-on-guile.
>
> Sorry for coming with unspecific information (don't have time to track
> down the details) but I noticed that my benchmark script written in Python,
> and which computes the 20:th Ramanujan number, now runs 60% faster than
> before these changes.
>
> This means that python-on-guile running on guile3 master executes python
> code only 2.6 times slower than the CPython python3 interpreter itself. :-)
>
> Have a nice weekend all,
> Mikael
>
>

[-- Attachment #2: Type: text/html, Size: 1251 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-25  8:20           ` Python-on-guile Mikael Djurfeldt
@ 2021-04-25 10:21             ` Stefan Israelsson Tampe
  0 siblings, 0 replies; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-25 10:21 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user, guile-devel

It is not the break let/ex that slows it down. But for wha it's worth we do
not do a let/ec if no break is used. Now.

On Sun, 25 Apr 2021, 10:20 Mikael Djurfeldt <mikael@djurfeldt.com> wrote:

> Nice!
>
> I guess it would be nice if "continue" *could* be compiled efficiently.
> And, as you indicate, perhaps that would amount to efficiently compiling
> let/ec.
>
> Best regards,
> Mikael
>
> On Sat, Apr 24, 2021 at 5:19 PM Stefan Israelsson Tampe <
> stefan.itampe@gmail.com> wrote:
>
>> Guile is 3x faster then fastest python-on-guile which is 2x faster then
>> python3 Cpython
>>
>> attached is a guile corresponding program.
>>
>> On Sat, Apr 24, 2021 at 4:41 PM Stefan Israelsson Tampe <
>> stefan.itampe@gmail.com> wrote:
>>
>>> To note is that 'continue' is killing performance for python-on-guile
>>> programs, so by changing the
>>> code to not use continue lead to python-on-guile running twice the speed
>>> of python3. The reason is that
>>> the while loop is used as
>>> (while (...)
>>>    (let/ec continue
>>>         ...))
>>>
>>> And the let/ec is probably not optimally compiled. Python-on-guile will
>>> check the loop for continue usage and if not then it will skip the let/ec.
>>>
>>> I attached the code not using continue
>>>
>>> On Sat, Apr 24, 2021 at 2:59 PM Stefan Israelsson Tampe <
>>> stefan.itampe@gmail.com> wrote:
>>>
>>>> Actually changing in (language python compile),
>>>>
>>>> (define (letec f)
>>>>   (let/ec x (f x))))
>>>>
>>>> To
>>>>
>>>> (define-syntax-rule (letec f)
>>>>   (let/ec x (f x))))
>>>>
>>>> Actually lead to similar speeds as python3.
>>>>
>>>>
>>>>
>>>> On Sat, Apr 24, 2021 at 1:26 PM Stefan Israelsson Tampe <
>>>> stefan.itampe@gmail.com> wrote:
>>>>
>>>>> Pro tip, when running this on guile the scheme code that it compilse
>>>>> to is located in log.txt.
>>>>> If you ,opt the resulting code in a guile session you might be able to
>>>>> pinpoint issues that
>>>>> delays the code execution.
>>>>>
>>>>> On Sat, Apr 24, 2021 at 12:04 PM Mikael Djurfeldt <
>>>>> mikael@djurfeldt.com> wrote:
>>>>>
>>>>>> (I should perhaps add that my script doesn't benchmark the object
>>>>>> system but rather loops, conditionals and integer arithmetic.)
>>>>>>
>>>>>> Den fre 23 apr. 2021 17:00Mikael Djurfeldt <mikael@djurfeldt.com>
>>>>>> skrev:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> Yesterday, Andy committed new code to the compiler, some of which
>>>>>>> concerned skipping some arity checking.
>>>>>>>
>>>>>>> Also, Stefan meanwhile committed something called "reworked object
>>>>>>> system" to his python-on-guile.
>>>>>>>
>>>>>>> Sorry for coming with unspecific information (don't have time to
>>>>>>> track down the details) but I noticed that my benchmark script written in
>>>>>>> Python, and which computes the 20:th Ramanujan number, now runs 60% faster
>>>>>>> than before these changes.
>>>>>>>
>>>>>>> This means that python-on-guile running on guile3 master executes
>>>>>>> python code only 2.6 times slower than the CPython python3 interpreter
>>>>>>> itself. :-)
>>>>>>>
>>>>>>> Have a nice weekend all,
>>>>>>> Mikael
>>>>>>>
>>>>>>>


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-24 12:59     ` Python-on-guile Stefan Israelsson Tampe
  2021-04-24 14:41       ` Python-on-guile Stefan Israelsson Tampe
@ 2021-04-25 10:54       ` Dr. Arne Babenhauserheide
  2021-04-25 11:54         ` Python-on-guile Vivien Kraus via General Guile related discussions
  1 sibling, 1 reply; 38+ messages in thread
From: Dr. Arne Babenhauserheide @ 2021-04-25 10:54 UTC (permalink / raw)
  To: Stefan Israelsson Tampe; +Cc: guile-user, guile-devel

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]


Stefan Israelsson Tampe <stefan.itampe@gmail.com> writes:

> (define-syntax-rule (letec f)
>   (let/ec x (f x))))
>
> Actually lead to similar speeds as python3.

Please keep in mind that this is math. There are parts of Python that
are heavily optimized, for example reading strings from disk. Guile will
likely have a hard time to compete with that.

But for math Guile is quite a bit faster than Python :-)

(next frontier: compete with math that’s implemented via numpy — you
can find RPython implementations of the basics of numpy in the
pypy-sources:
https://foss.heptapod.net/pypy/pypy/-/tree/branch/default/pypy/module/micronumpy
)

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-25 10:54       ` Python-on-guile Dr. Arne Babenhauserheide
@ 2021-04-25 11:54         ` Vivien Kraus via General Guile related discussions
  0 siblings, 0 replies; 38+ messages in thread
From: Vivien Kraus via General Guile related discussions @ 2021-04-25 11:54 UTC (permalink / raw)
  To: Dr. Arne Babenhauserheide, Stefan Israelsson Tampe
  Cc: guile-user, guile-devel

Hello,

Le dimanche 25 avril 2021 à 12:54 +0200, Dr. Arne Babenhauserheide a
écrit :
> (next frontier: compete with math that’s implemented via numpy — you
> can find RPython implementations of the basics of numpy in the
> pypy-sources:
> https://foss.heptapod.net/pypy/pypy/-/tree/branch/default/pypy/module/micronumpy
> )

I think it would be wiser to use guile arrays to implement the same
things as numpy.




^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Python-on-guile
  2021-04-23 15:00 Python-on-guile Mikael Djurfeldt
                   ` (4 preceding siblings ...)
  2021-04-25 10:18 ` Python-on-guile Stefan Israelsson Tampe
@ 2021-04-27 12:29 ` Nala Ginrut
  5 siblings, 0 replies; 38+ messages in thread
From: Nala Ginrut @ 2021-04-27 12:29 UTC (permalink / raw)
  To: mikael; +Cc: guile-user, guile-devel

Nice to know it!
I still don't have time to polish my guile-lua-rebirth. Anyway, it's really
good news to see the transpiler has a good performance on Guile.!

Best regards.


On Fri, Apr 23, 2021 at 11:01 PM Mikael Djurfeldt <mikael@djurfeldt.com>
wrote:

> Hi,
>
> Yesterday, Andy committed new code to the compiler, some of which
> concerned skipping some arity checking.
>
> Also, Stefan meanwhile committed something called "reworked object system"
> to his python-on-guile.
>
> Sorry for coming with unspecific information (don't have time to track
> down the details) but I noticed that my benchmark script written in Python,
> and which computes the 20:th Ramanujan number, now runs 60% faster than
> before these changes.
>
> This means that python-on-guile running on guile3 master executes python
> code only 2.6 times slower than the CPython python3 interpreter itself. :-)
>
> Have a nice weekend all,
> Mikael
>
>


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
       [not found]                                         ` <CAGua6m0d=L9b9MEMYekX0tL0PO3k+ZR+LP=7YYQojzr0VYdkmw@mail.gmail.com>
@ 2020-02-19  7:30                                           ` david larsson
  0 siblings, 0 replies; 38+ messages in thread
From: david larsson @ 2020-02-19  7:30 UTC (permalink / raw)
  To: Stefan Israelsson Tampe <stefan.itampe@gmail.com>

On 2020-02-18 20:05, Stefan Israelsson Tampe wrote:
> This looks like problems loading the stis-parser module, can you add
> that manually to the load list as well?
> 
> test to see that you can do
> 
> (use-modules (parser stis-parser lang python3-parser))
> 
> Regards
> Stefan

That did it, thanks! It compiles and installs for 
commit=226d33163e7f1e305c0b6e2ada37209513377dff

I added /usr/local/share/guile/site/2.2 where the parser and persist 
modules are located.

By default I only had the following for some reason(running PureOS):
scheme@(guile-user)> %load-path
$1 = ("/usr/share/guile/2.2" "/usr/share/guile/site/2.2" 
"/usr/share/guile/site" "/usr/share/guile")

Now I hope Ill be able to update the Guix packages for python-on-guile, 
guile-persist, and stis-parser, using the same commits.

Thanks again for your help!

Regards,
David

> 
> On Tue, Feb 18, 2020 at 11:46 AM david larsson
> <david.larsson@selfhosted.xyz> wrote:
> 
>> On 2020-02-13 08:41, Stefan Israelsson Tampe wrote:
>>> Hmm, seams guile has a problem finding guile-persists modules, as
>> you
>>> would probably get the same error if you do
>>> (use-modules (persist persistence))
>>> 
>>> Try source the guile-persist and add it to the load path directory
>>> (you probably need to do the same for stis-parser but there you
>> should
>>> source the module directory in stis-parser directory)
>>> 
>>> regards
>>> Stefan
>> 
>> I was able to run "(use-modules (persist persistence))" from a guile
>> 
>> prompt after adding the persist module to the load path and
>> exporting
>> LD_LIBRARY_PATH set to /usr/local/lib/guile/2.2/extensions.
>> 
>> Now Im getting this error on make:
>> 
>> -----------------
>> Makefile:1390: warning: overriding recipe for target 'python'
>> Makefile:771: warning: ignoring old recipe for target 'python'
>> GEN      language/python/eval.go
>> guile: warning: failed to install locale
>> warning: failed to install locale: Invalid argument
>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>> Syntax error:
>> /usr/share/guile/site/parser/stis-parser/lang/python3/tool.scm:37:2:
>> 
>> source expression failed to match any pattern in form (<p-cc> <S>
>> <Cut>
>> <CC> c)
>> make: *** [Makefile:1385: language/python/eval.go] Error 1
>> -----------------
>> 
>> Regards,
>> David
>> 
>>> 
>>> On Thu, Feb 13, 2020 at 8:31 AM david larsson
>>> <david.larsson@selfhosted.xyz> wrote:
>>> 
>>>> On 2020-02-12 21:14, Stefan Israelsson Tampe wrote:
>>>>> I saw from the stacktrace that the repo uses a not available
>>>> module. I
>>>>> dried to fix that and missed pushing it. I agave now pushed so
>> you
>>>>> could try to pull and compile again
>>>> 
>>>> Yep, now it works.
>>>> 
>>>> guile-persist builds on commit
>>>> 751c8834b401e81b6ea058a05861ebaf0b659f9d
>>>> stis-parser builds on commit
>>>> 8d49401e238ae703a466b5b98d3068e4fa974f2c
>>>> 
>>>> It's just the python-on-guile that fails now, for commit:
>>>> 226d33163e7f1e305c0b6e2ada37209513377dff
>>>> 
>>>> with:
>>>> ----------------
>>>> Makefile:1390: warning: overriding recipe for target 'python'
>>>> Makefile:771: warning: ignoring old recipe for target 'python'
>>>> GEN      oop/pf-objects.go
>>>> guile: warning: failed to install locale
>>>> warning: failed to install locale: Invalid argument
>>>> Backtrace:
>>>> In ice-9/boot-9.scm:
>>>> 2312:4 19 (save-module-excursion #<procedure 55e6116127c0 at
>>>> lang?>)
>>>> In language/scheme/compile-tree-il.scm:
>>>> 31:15 18 (_)
>>>> In ice-9/psyntax.scm:
>>>> 1235:36 17 (expand-top-sequence ((define-module (oop #) # (# ?)
>>>> ?)) ?)
>>>> 1182:24 16 (parse _ (("placeholder" placeholder)) ((top) #(# #
>>>> ?)) ?)
>>>> 285:10 15 (parse _ (("placeholder" placeholder)) (()) _ c&e (#
>>>> #) #)
>>>> In ice-9/eval.scm:
>>>> 293:34 14 (_ #<module (#{ g77}#) 55e6116dc0a0>)
>>>> In ice-9/boot-9.scm:
>>>> 2874:4 13 (define-module* _ #:filename _ #:pure _ #:version _ #
>>>> _ ?)
>>>> 2071:24 12 (call-with-deferred-observers #<procedure 55e611488910
>>>> ?>)
>>>> 2887:24 11 (_)
>>>> 222:29 10 (map1 (((oop goops)) ((oop dict) #:renamer #<proce?>)
>>>> ?))
>>>> 222:29  9 (map1 (((oop dict) #:renamer #<procedure 55e6116da?>)
>>>> ?))
>>>> 222:29  8 (map1 (((ice-9 vlist)) ((ice-9 match)) ((system # #))
>>>> ?))
>>>> 222:29  7 (map1 (((ice-9 match)) ((system base message)) ((# ?))
>>>> ?))
>>>> 222:29  6 (map1 (((system base message)) ((language python #)) #
>>>> ?))
>>>> 222:29  5 (map1 (((language python guilemod)) ((ice-9 #)) ((#
>>>> ?))))
>>>> 222:29  4 (map1 (((ice-9 pretty-print)) ((persist
>>>> persistance))))
>>>> 222:17  3 (map1 (((persist persistance))))
>>>> 2803:6  2 (resolve-interface _ #:select _ #:hide _ #:prefix _ #
>>>> _ ?)
>>>> In unknown file:
>>>> 1 (scm-error misc-error #f "~A ~S" ("no code for modu?"
>>>> ?) ?)
>>>> In ice-9/boot-9.scm:
>>>> 752:25  0 (dispatch-exception _ _ _)
>>>> 
>>>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>>>> no code for module (persist persistance)
>>>> make: *** [Makefile:1385: oop/pf-objects.go] Error 1
>>>> -----------------
>>>> 
>>>> Regards,
>>>> David
>>>> 
>>>>> 
>>>>> On Wed, Feb 12, 2020 at 9:00 PM david larsson
>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>> 
>>>>>> On 2020-02-12 20:52, Stefan Israelsson Tampe wrote:
>>>>>>> Okey, thanks, try to checkout a new version of guile-persists
>>>> and
>>>>>> try
>>>>>>> again
>>>>>> 
>>>>>> The commit the error message below is from is the most recent
>>>>>> version
>>>>>> AFAICT, from "22hours ago":
>>>> https://gitlab.com/tampe/guile-persist
>>>>>> commit 659abf1dc64c1aa9d9e4c27fe349100dc908ee6c
>>>>>> 
>>>>>> Regards,
>>>>>> David
>>>>>> 
>>>>>>> 
>>>>>>> On Wed, Feb 12, 2020 at 8:47 PM david larsson
>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>> 
>>>>>>>> On 2020-02-12 18:18, Stefan Israelsson Tampe wrote:
>>>>>>>>> you should update the guile-persist repo and also
>> stis-parser,
>>>>>>>> there
>>>>>>>>> was some cond-expand issues in those as well
>>>>>>>> 
>>>>>>>> Ok. I tried that. stis-parser now built fine on commit
>>>>>>>> 8d49401e238ae703a466b5b98d3068e4fa974f2c
>>>>>>>> 
>>>>>>>> but guile-persist failed on make for commit:
>>>>>>>> 659abf1dc64c1aa9d9e4c27fe349100dc908ee6c
>>>>>>>> 
>>>>>>>> ---------------------
>>>>>>>> make  all-recursive
>>>>>>>> make[1]: Entering directory
>>>>>>>> '/home/user1/VirtualHome/src/guile-persist'
>>>>>>>> Making all in src/
>>>>>>>> make[2]: Entering directory
>>>>>>>> '/home/user1/VirtualHome/src/guile-persist/src'
>>>>>>>> make  all-am
>>>>>>>> make[3]: Entering directory
>>>>>>>> '/home/user1/VirtualHome/src/guile-persist/src'
>>>>>>>> make[3]: Nothing to be done for 'all-am'.
>>>>>>>> make[3]: Leaving directory
>>>>>>>> '/home/user1/VirtualHome/src/guile-persist/src'
>>>>>>>> make[2]: Leaving directory
>>>>>>>> '/home/user1/VirtualHome/src/guile-persist/src'
>>>>>>>> make[2]: Entering directory
>>>>>>>> '/home/user1/VirtualHome/src/guile-persist'
>>>>>>>> GEN      persist/slask.go
>>>>>>>> guile: warning: failed to install locale
>>>>>>>> warning: failed to install locale: Invalid argument
>>>>>>>> wrote `persist/slask.go'
>>>>>>>> GEN      persist/primitive.go
>>>>>>>> guile: warning: failed to install locale
>>>>>>>> warning: failed to install locale: Invalid argument
>>>>>>>> wrote `persist/primitive.go'
>>>>>>>> GEN      persist/persistance.go
>>>>>>>> guile: warning: failed to install locale
>>>>>>>> warning: failed to install locale: Invalid argument
>>>>>>>> Backtrace:
>>>>>>>> In ice-9/psyntax.scm:
>>>>>>>> 1235:36 19 (expand-top-sequence ((define-module (persist #) #
>> #
>>>>>>>> ?)) ?)
>>>>>>>> 1182:24 18 (parse _ (("placeholder" placeholder)) ((top) #(#
>> #
>>>>>>>> ?)) ?)
>>>>>>>> 285:10 17 (parse _ (("placeholder" placeholder)) (()) _ c&e
>> (#
>>>>>>>> #) #)
>>>>>>>> In ice-9/eval.scm:
>>>>>>>> 293:34 16 (_ #<module (#{ g77}#) 55f2082600a0>)
>>>>>>>> In ice-9/boot-9.scm:
>>>>>>>> 2874:4 15 (define-module* _ #:filename _ #:pure _ #:version _
>> #
>>>>>>>> _ ?)
>>>>>>>> 2071:24 14 (call-with-deferred-observers #<procedure
>>>> 55f20800c0f0
>>>>>>>> ?>)
>>>>>>>> 2887:24 13 (_)
>>>>>>>> 222:29 12 (map1 (((system vm loader)) ((system vm program))
>> (#)
>>>>>>>> ?))
>>>>>>>> 222:29 11 (map1 (((system vm program)) ((system vm debug))
>>>> ((?))
>>>>>>>> ?))
>>>>>>>> 222:29 10 (map1 (((system vm debug)) ((system vm dwarf)) ((#
>>>> ?))
>>>>>>>> ?))
>>>>>>>> 222:29  9 (map1 (((system vm dwarf)) ((ice-9 match)) ((ice-9
>>>> ?))
>>>>>>>> ?))
>>>>>>>> 222:29  8 (map1 (((ice-9 match)) ((ice-9 vlist)) ((ice-9 #))
>>>> (#)
>>>>>>>> ?))
>>>>>>>> 222:29  7 (map1 (((ice-9 vlist)) ((ice-9 control)) ((ice-9
>> #))
>>>> #
>>>>>>>> ?))
>>>>>>>> 222:29  6 (map1 (((ice-9 control)) ((ice-9 pretty-print))
>> ((?))
>>>>>>>> ?))
>>>>>>>> 222:29  5 (map1 (((ice-9 pretty-print)) ((oop goops)) ((oop
>> #))
>>>>>>>> ?))
>>>>>>>> 222:29  4 (map1 (((oop goops)) ((oop dict)) ((persist #))
>> ((?))
>>>>>>>> ?))
>>>>>>>> 222:17  3 (map1 (((oop dict)) ((persist primitive)) ((# #))
>> (#)
>>>>>>>> #))
>>>>>>>> 2803:6  2 (resolve-interface _ #:select _ #:hide _ #:prefix _
>> #
>>>>>>>> _ ?)
>>>>>>>> In unknown file:
>>>>>>>> 1 (scm-error misc-error #f "~A ~S" ("no code for modu?"
>>>>>>>> ?) ?)
>>>>>>>> In ice-9/boot-9.scm:
>>>>>>>> 752:25  0 (dispatch-exception _ _ _)
>>>>>>>> 
>>>>>>>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>>>>>>>> no code for module (oop dict)
>>>>>>>> make[2]: *** [Makefile:945: persist/persistance.go] Error 1
>>>>>>>> make[2]: Leaving directory
>>>>>>>> '/home/user1/VirtualHome/src/guile-persist'
>>>>>>>> make[1]: *** [Makefile:519: all-recursive] Error 1
>>>>>>>> make[1]: Leaving directory
>>>>>>>> '/home/user1/VirtualHome/src/guile-persist'
>>>>>>>> make: *** [Makefile:399: all] Error 2
>>>>>>>> -------------------------
>>>>>>>> 
>>>>>>>> The error seems very related to the make error for
>>>>>> python-on-guile.
>>>>>>>> 
>>>>>>>> Regards,
>>>>>>>> David
>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> On Wed, Feb 12, 2020 at 4:26 PM david larsson
>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>> 
>>>>>>>>>> On 2020-02-12 10:59, Stefan Israelsson Tampe wrote:
>>>>>>>>>>> no code for module (persist persistance)
>>>>>>>>>>> 
>>>>>>>>>>> can you use  (persist persistance)  e.g. from the guile
>>>> shell,
>>>>>>>>>>> 
>>>>>>>>>>>> (use-modules  (persist persistance) )
>>>>>>>>>> 
>>>>>>>>>> Nope, that gives the same error. I had some issue when
>>>>>> compiling
>>>>>>>> the
>>>>>>>>>> 
>>>>>>>>>> stis-parser and/or guile-persist as well and solved it by
>>>>>> adding
>>>>>>>> a
>>>>>>>>>> symlink in /usr/local/include/ something. So Ill look into
>>>>>>>> whether I
>>>>>>>>>> 
>>>>>>>>>> have some path/environment variable issue on my machine. Im
>>>>>>>> running
>>>>>>>>>> PureOS which I think tracks Debian stable, so some stuff
>> can
>>>> be
>>>>>>>>>> pretty
>>>>>>>>>> old and maybe thats the reason.
>>>>>>>>>> 
>>>>>>>>>> Regards,
>>>>>>>>>> David
>>>>>>>>>> 
>>>>>>>>>>> ...
>>>>>>>>>>> 
>>>>>>>>>>> /Stefan
>>>>>>>>>>> 
>>>>>>>>>>> On Wed, Feb 12, 2020 at 10:18 AM david larsson
>>>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>>>> 
>>>>>>>>>>>> On 2020-02-11 21:57, Stefan Israelsson Tampe wrote:
>>>>>>>>>>>>> This error is fixed in repository
>>>>>>>>>>>>> /Stefan
>>>>>>>>>>>> 
>>>>>>>>>>>> Thanks. That solved that part. Now Im getting this error
>> on
>>>>>>>> make:
>>>>>>>>>>>> 
>>>>>>>>>>>> (commit 226d33163e7f1e305c0b6e2ada37209513377dff)
>>>>>>>>>>>> ----------------------
>>>>>>>>>>>> 
>>>>>>>>>>>> Makefile:1390: warning: overriding recipe for target
>>>> 'python'
>>>>>>>>>>>> Makefile:771: warning: ignoring old recipe for target
>>>>>> 'python'
>>>>>>>>>>>> GEN      oop/pf-objects.go
>>>>>>>>>>>> guile: warning: failed to install locale
>>>>>>>>>>>> warning: failed to install locale: Invalid argument
>>>>>>>>>>>> Backtrace:
>>>>>>>>>>>> In ice-9/boot-9.scm:
>>>>>>>>>>>> 2312:4 19 (save-module-excursion #<procedure 55a897256bc0
>>>> at
>>>>>>>>>>>> lang?>)
>>>>>>>>>>>> In language/scheme/compile-tree-il.scm:
>>>>>>>>>>>> 31:15 18 (_)
>>>>>>>>>>>> In ice-9/psyntax.scm:
>>>>>>>>>>>> 1235:36 17 (expand-top-sequence ((define-module (oop #) #
>>>> (#
>>>>>> ?)
>>>>>>>>>>>> ?)) ?)
>>>>>>>>>>>> 1182:24 16 (parse _ (("placeholder" placeholder)) ((top)
>>>> #(#
>>>>>> #
>>>>>>>>>>>> ?)) ?)
>>>>>>>>>>>> 285:10 15 (parse _ (("placeholder" placeholder)) (()) _
>> c&e
>>>>>> (#
>>>>>>>>>>>> #) #)
>>>>>>>>>>>> In ice-9/eval.scm:
>>>>>>>>>>>> 293:34 14 (_ #<module (#{ g77}#) 55a8972dd0a0>)
>>>>>>>>>>>> In ice-9/boot-9.scm:
>>>>>>>>>>>> 2874:4 13 (define-module* _ #:filename _ #:pure _
>> #:version
>>>> _
>>>>>> #
>>>>>>>>>>>> _ ?)
>>>>>>>>>>>> 2071:24 12 (call-with-deferred-observers #<procedure
>>>>>>>> 55a897086910
>>>>>>>>>>>> ?>)
>>>>>>>>>>>> 2887:24 11 (_)
>>>>>>>>>>>> 222:29 10 (map1 (((oop goops)) ((oop dict) #:renamer
>>>>>> #<proce?>)
>>>>>>>>>>>> ?))
>>>>>>>>>>>> 222:29  9 (map1 (((oop dict) #:renamer #<procedure
>>>>>> 55a8972fb?>)
>>>>>>>>>>>> ?))
>>>>>>>>>>>> 222:29  8 (map1 (((ice-9 vlist)) ((ice-9 match)) ((system
>> #
>>>>>> #))
>>>>>>>>>>>> ?))
>>>>>>>>>>>> 222:29  7 (map1 (((ice-9 match)) ((system base message))
>>>> ((#
>>>>>>>> ?))
>>>>>>>>>>>> ?))
>>>>>>>>>>>> 222:29  6 (map1 (((system base message)) ((language
>> python
>>>>>> #))
>>>>>>>> #
>>>>>>>>>>>> ?))
>>>>>>>>>>>> 222:29  5 (map1 (((language python guilemod)) ((ice-9 #))
>>>> ((#
>>>>>>>>>>>> ?))))
>>>>>>>>>>>> 222:29  4 (map1 (((ice-9 pretty-print)) ((persist
>>>>>>>>>>>> persistance))))
>>>>>>>>>>>> 222:17  3 (map1 (((persist persistance))))
>>>>>>>>>>>> 2803:6  2 (resolve-interface _ #:select _ #:hide _
>> #:prefix
>>>> _
>>>>>> #
>>>>>>>>>>>> _ ?)
>>>>>>>>>>>> In unknown file:
>>>>>>>>>>>> 1 (scm-error misc-error #f "~A ~S" ("no code for modu?"
>>>>>>>>>>>> ?) ?)
>>>>>>>>>>>> In ice-9/boot-9.scm:
>>>>>>>>>>>> 752:25  0 (dispatch-exception _ _ _)
>>>>>>>>>>>> 
>>>>>>>>>>>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>>>>>>>>>>>> no code for module (persist persistance)
>>>>>>>>>>>> make: *** [Makefile:1385: oop/pf-objects.go] Error 1
>>>>>>>>>>>> 
>>>>>>>>>>>> ----------------------
>>>>>>>>>>>> 
>>>>>>>>>>>> Regards,
>>>>>>>>>>>> David
>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> On Tue, Feb 11, 2020 at 8:17 AM david larsson
>>>>>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>>> On 2020-02-10 21:11, Stefan Israelsson Tampe wrote:
>>>>>>>>>>>>>>> I have now added the bytes constructor that was not
>>>>>> working.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Thanks!
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> To compile from source please try use the git
>> repository
>>>>>> at:
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> https://gitlab.com/python-on-guile/python-on-guile/
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> see readme for how to compile and what dependencies
>> you
>>>>>>>> have.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> I was able to build and install:
>>>>>>>>>>>>>> - guile-persist: commit
>>>>>>>>>> ebebb66ae6d6c47dbc406cdbcaccb5ffed2e463a
>>>>>>>>>>>>>> - stis-parser: commit
>>>>>>>> 7673dd576abb445fbcfce8c4b6ae961ee860902e
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> but for python-on-guile Im getting this error on make:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> --------------
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Makefile:1390: warning: overriding recipe for target
>>>>>> 'python'
>>>>>>>>>>>>>> Makefile:771: warning: ignoring old recipe for target
>>>>>>>> 'python'
>>>>>>>>>>>>>> GEN      language/python/guilemod.go
>>>>>>>>>>>>>> guile: warning: failed to install locale
>>>>>>>>>>>>>> warning: failed to install locale: Invalid argument
>>>>>>>>>>>>>> ice-9/boot-9.scm:752:25: In procedure
>> dispatch-exception:
>>>>>>>>>>>>>> Syntax error:
>>>>>>>>>>>>>> language/python/guilemod.scm:271:0: cond-expand:
>>>>>> unfulfilled
>>>>>>>>>>>>>> cond-expand
>>>>>>>>>>>>>> in form (cond-expand (guile-3.0 (define-set-M
>>>>>>>>>> lookup-warning-type
>>>>>>>>>>>>>> lookup-warning-type) (define-set-M warning warning)
>> (set!
>>>>>>>>>>>>>> %warning-types
>>>>>>>>>>>>>> w-types)) (guile-2.0 or guile-2.2 (define-M
>>>> %warning-types
>>>>>>>>>>>> w-types)
>>>>>>>>>>>>>> (define-exp-M lookup-warning-type (lambda (name)
>> "Return
>>>>>> the
>>>>>>>>>>>> warning
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> type NAME or `#f' if not found." ((M find) (lambda (wt)
>>>>>> (eq?
>>>>>>>>>> name
>>>>>>>>>>>>>> ((M
>>>>>>>>>>>>>> warning-type-name) wt))) (M %warning-types))))))
>>>>>>>>>>>>>> make: *** [Makefile:1385: language/python/guilemod.go]
>>>>>> Error
>>>>>>>> 1
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> ---------------
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Im compiling with guile2.2
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Regards,
>>>>>>>>>>>>>> David
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>> Stefan
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> On Mon, Feb 10, 2020 at 1:14 PM david larsson
>>>>>>>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> On 2020-02-09 21:36, Stefan Israelsson Tampe wrote:
>>>>>>>>>>>>>>>>> in sys that is
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> On Sun, Feb 9, 2020 at 9:36 PM Stefan Israelsson
>> Tampe
>>>>>>>>>>>>>>>>> <stefan.itampe@gmail.com> wrote:
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> OKey, I changed the values from immutable lists to
>>>>>> lists.
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Great!
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> On Sun, Feb 9, 2020 at 9:27 PM Stefan Israelsson
>>>> Tampe
>>>>>>>>>>>>>>>>>> <stefan.itampe@gmail.com> wrote:
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> Note that a lot of things are untested because I'm
>>>>>> alone
>>>>>>>> on
>>>>>>>>>>>> the
>>>>>>>>>>>>>>>>>> development.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Ok, I understand.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> I haven't been able to build a recent version, but if
>>>> you
>>>>>>>> can
>>>>>>>>>>>>>> share
>>>>>>>>>>>>>>>> some
>>>>>>>>>>>>>>>> updated instructions, then I could perhaps help out
>>>> with
>>>>>>>> some
>>>>>>>>>>>>>>>> occasional
>>>>>>>>>>>>>>>> testing. I have only managed to build from the old
>>>> commit
>>>>>>>>>>>> fc0d7a9
>>>>>>>>>>>>>> by
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> updating the current python-on-guile guix package
>>>>>> locally.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> netlib is not included, you can test to add the
>>>> python
>>>>>>>>>> module
>>>>>>>>>>>>>>>> file
>>>>>>>>>>>>>>>>>> to a (language python module) directory
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> What's been working for me so far is only (load
>>>>>>>>>>>>>> "path/to/file.py")
>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>> (load-compiled "path/to/file.go").
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> (use-modules (a b c)) did not work for me, except to
>>>> load
>>>>>>>>>>>> modules
>>>>>>>>>>>>>>>> already shipped with python-on-guile repo; (language
>>>>>> python
>>>>>>>>>>>>>> module
>>>>>>>>>>>>>>>> python) etc.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> I have recently added much more of the python
>> stdlib
>>>>>> aka
>>>>>>>>>> 3.7
>>>>>>>>>>>>>> but
>>>>>>>>>>>>>>>> not
>>>>>>>>>>>>>>>>>> all.
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> Not sure what you mean by .scm file and .py fle
>> when
>>>> it
>>>>>>>>>> comes
>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>>>> base64
>>>>>>>>>>>>>>>>>> using that module in scheme gives
>>>>>>>>>>>>>>>>>> scheme@(guile-user)> (b64decode (b64encode "abc"))
>>>>>>>>>>>>>>>>>> $2 = b'abc'
>>>>>>>>>>>>>>>>>> scheme@(guile-user)> (b64decode (b64encode #(1 2
>> 3)))
>>>>>>>>>>>>>>>>>> $3 = b'\x01\x02\x03'
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> Which return a bytevector if you want a string back
>>>> you
>>>>>>>>>> need
>>>>>>>>>>>> to
>>>>>>>>>>>>>>>>>> interpret the bytevector back to a string
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Im getting weird results when trying to output the
>>>> base64
>>>>>>>>>>>>>>>> representation
>>>>>>>>>>>>>>>> of a string, take btest.py:
>>>>>>>>>>>>>>>> #import sys
>>>>>>>>>>>>>>>> import base64
>>>>>>>>>>>>>>>> def mybmethod(x):
>>>>>>>>>>>>>>>> mybytes = bytes(x, "utf-8")
>>>>>>>>>>>>>>>> encodedbytes = base64.b64encode(mybytes)
>>>>>>>>>>>>>>>> myb64string = str(encodedbytes, "utf-8")
>>>>>>>>>>>>>>>> return myb64string
>>>>>>>>>>>>>>>> #print(myb64string)
>>>>>>>>>>>>>>>> #mybmethod(sys.argv[1])
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> and assume btest.scm using it with:
>>>>>>>>>>>>>>>> (add-to-load-path (dirname (current-filename)))
>>>>>>>>>>>>>>>> (use-modules (language python module python))
>>>>>>>>>>>>>>>> (load "btest.py")
>>>>>>>>>>>>>>>> (define-public (mybmethodscm cmdline)
>>>>>>>>>>>>>>>> (display (mybmethod (cadr cmdline))))
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> With this it will not work to run the scheme file
>> with
>>>>>>>>>>>>>>>> guile -e mybmethodscm btest.scm dfasdf
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> The error I got indicated that btest.py uses the
>> bytes
>>>>>>>>>>>> procedure
>>>>>>>>>>>>>>>> from
>>>>>>>>>>>>>>>> within python-on-guile instead of from the python3
>>>> base64
>>>>>>>>>> lib:
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> -------------------
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> In
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> /home/user1/VirtualHome/src/code_guile/python-on-guile-test/btest.scm:
>>>>>>>>>>>>>>>> 18:11  4 (mybmethodscm _)
>>>>>>>>>>>>>>>> In btest.py:
>>>>>>>>>>>>>>>> 10:584  3 (_ "dfasdf" . _)
>>>>>>>>>>>>>>>> In oop/pf-objects.scm:
>>>>>>>>>>>>>>>> 584:15  2 (create-object _ _)
>>>>>>>>>>>>>>>> 567:11  1 (the-create-object _ _)
>>>>>>>>>>>>>>>> In language/python/bytes.scm:
>>>>>>>>>>>>>>>> 99:6  0 Exception thrown while printing backtrace:
>>>>>>>>>>>>>>>> Unbound slot in object Error while printing
>> exception.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> language/python/bytes.scm:99:6: Wrong number of
>>>> arguments
>>>>>>>> to
>>>>>>>>>>>>>>>> #<procedure
>>>>>>>>>>>>>>>> 7f2bab5d4560 at language/python/bytes.scm:92:0 (self)
>> |
>>>>>>>> (self
>>>>>>>>>>>> s)>
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> -------------------
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> For a moment though, I could run:
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> guile -e mybmethodscm btest.scm dfasdf | rev | base64
>>>> -d
>>>>>> |
>>>>>>>>>> rev
>>>>>>>>>>>>>>>> # gives: dfasdf
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> which was also strange.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> modules are a bit difficult as I use the guile
>> module
>>>>>>>>>> system
>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>>>>> python modules are different.
>>>>>>>>>>>>>>>>>> So nested modules needs some work. The best is to
>>>> test
>>>>>>>> and
>>>>>>>>>>>> see.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Ok, got it!
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> I will look into the sys thingies
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>> Stefan
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> On Sun, Feb 9, 2020 at 8:40 PM david larsson
>>>>>>>>>>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>>>>>>>>>>> Thanks for your explanations, but unfortunately I
>>>> still
>>>>>>>>>> can't
>>>>>>>>>>>>>>>> figure
>>>>>>>>>>>>>>>>>> out
>>>>>>>>>>>>>>>>>> how to use this except in the simplest of cases.
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> I am using the guix package python-on-guile
>>>>>>>> 0.1.0-3.00a51a2
>>>>>>>>>> -
>>>>>>>>>>>>>>>> maybe
>>>>>>>>>>>>>>>>>> thats outdated?
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> The simple things I have managed to do, are like:
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> (add-to-load-path (dirname (current-filename)))
>>>>>>>>>>>>>>>>>> (load-compiled python-test.go)
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> where python-test.go is compiled with:
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> guild compile python-test.py
>> --output=python-test.go
>>>>>>>>>>>>>>>>>> --from=python
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> and contains simple things, like:
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> f(s):
>>>>>>>>>>>>>>>>>> a = s + 1
>>>>>>>>>>>>>>>>>> return a
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> but if I add statements to python-test.py like:
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> import netaddr
>>>>>>>>>>>>>>>>>> def myfun(a)
>>>>>>>>>>>>>>>>>> <something using netaddr>
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> (netaddr is a module installed via: pip3 install
>>>> --user
>>>>>>>>>>>>>> netaddr)
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> I receive an error about not finding the module.
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> I am able to add only the modules which exist in
>> the
>>>>>>>>>>>>>>>> python-on-guile
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> repo, like:
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> import sys
>>>>>>>>>>>>>>>>>> import base64
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> but Im getting errors, for example Im not able to
>> use
>>>>>>>>>> things
>>>>>>>>>>>>>> from
>>>>>>>>>>>>>>>>>> sys,
>>>>>>>>>>>>>>>>>> like:
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> sys.path.append(<somepath>)
>>>>>>>>>>>>>>>>>> sys.path.insert(0, <somepath>)
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> I was able to use some things from base64 but I
>> only
>>>>>>>>>> received
>>>>>>>>>>>>>>>> weird
>>>>>>>>>>>>>>>>>> results when converting between bytevectors and
>>>> strings
>>>>>>>>>>>> between
>>>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>>>>> .scm
>>>>>>>>>>>>>>>>>> file and .py file. What works fine using python3
>>>>>>>>>>>> python-test.py
>>>>>>>>>>>>>>>> do
>>>>>>>>>>>>>>>>>> not
>>>>>>>>>>>>>>>>>> usually work when passing either a bytevector or
>>>> string
>>>>>>>> to
>>>>>>>>>>>> the
>>>>>>>>>>>>>>>> same
>>>>>>>>>>>>>>>>>> go-compiled file from the .scm file using the
>>>>>>>> python-code.
>>>>>>>>>>>> Not
>>>>>>>>>>>>>>>> sure
>>>>>>>>>>>>>>>>>> whether there's a problem using python3 vs python2
>>>>>> here?
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> Essentially, what Im looking for is how to proceed
>> if
>>>> I
>>>>>>>>>> want
>>>>>>>>>>>> to
>>>>>>>>>>>>>>>> use
>>>>>>>>>>>>>>>>>> modules installed via the pip package manager from
>>>>>> guile,
>>>>>>>>>> and
>>>>>>>>>>>>>>>> what
>>>>>>>>>>>>>>>>>> paths
>>>>>>>>>>>>>>>>>> and imports I need to make, and how I might need to
>>>>>> wrap
>>>>>>>>>> them
>>>>>>>>>>>>>>>>>> correctly
>>>>>>>>>>>>>>>>>> in the scheme and python files to invoke a pip
>>>> package
>>>>>>>>>>>>>> procedure
>>>>>>>>>>>>>>>>>> from
>>>>>>>>>>>>>>>>>> guile.
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> Best regards,
>>>>>>>>>>>>>>>>>> David
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
>>>>>>>>>>>>>>>>>>> I'm the author of that lib.
>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> 1)
>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> The main bindings are reachable through (language
>>>>>> python
>>>>>>>>>>>>>> module
>>>>>>>>>>>>>>>>>>> python)
>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> So you could now go ahead and do
>>>>>>>>>>>>>>>>>>>> (use-modules (language python module python))
>>>>>>>>>>>>>>>>>>>> ;L python
>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> And you will get a python shell that works quite
>> ok
>>>>>> for
>>>>>>>>>> one
>>>>>>>>>>>>>>>> liners
>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> 2)
>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> If you write a module and place it in a/b/c.py
>>>>>>>>>>>>>>>>>>> you can use the classes and functions theirin by
>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> (use-modules (a b c))
>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> 3)
>>>>>>>>>>>>>>>>>>> you can load a .py file as (i hope this work)
>>>>>>>>>>>>>>>>>>> (load "a.py")
>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> 4)
>>>>>>>>>>>>>>>>>>> If you place a module in (language python module
>>>> a.py)
>>>>>>>> you
>>>>>>>>>>>> can
>>>>>>>>>>>>>>>>>> import
>>>>>>>>>>>>>>>>>>> ir as a usual mode as
>>>>>>>>>>>>>>>>>>>> from a import *
>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> The documentation is for the macro framework that
>>>>>>>> enables
>>>>>>>>>>>> you
>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>>>> work
>>>>>>>>>>>>>>>>>>> with python classes and idioms like python
>>>> iteration.
>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> Hope this helps
>>>>>>>>>>>>>>>>>>> /Stefan
>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> On Sun, Feb 9, 2020 at 6:31 PM david larsson
>>>>>>>>>>>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>> Hi everyone,
>>>>>>>>>>>>>>>>>>>> I am trying to wrap my head around how to use the
>>>>>>>>>>>>>>>> python-on-guile
>>>>>>>>>>>>>>>>>>>> library, but Im struggling. Does anyone have
>>>> example
>>>>>>>> code
>>>>>>>>>>>>>> that
>>>>>>>>>>>>>>>>>> might
>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>> help, and which isn't too advanced?
>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>> All tips and suggestions appreciated!
>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>> Best regards,
>>>>>>>>>>>>>>>>>>>> David



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
       [not found]                                     ` <CAGua6m2+hEpGf8Z+CfyO+-mKH4sQF-mVb7YS1=+88hF2bRkjPw@mail.gmail.com>
@ 2020-02-18 10:45                                       ` david larsson
       [not found]                                         ` <CAGua6m0d=L9b9MEMYekX0tL0PO3k+ZR+LP=7YYQojzr0VYdkmw@mail.gmail.com>
  0 siblings, 1 reply; 38+ messages in thread
From: david larsson @ 2020-02-18 10:45 UTC (permalink / raw)
  To: Stefan Israelsson Tampe <stefan.itampe@gmail.com>

On 2020-02-13 08:41, Stefan Israelsson Tampe wrote:
> Hmm, seams guile has a problem finding guile-persists modules, as you
> would probably get the same error if you do
> (use-modules (persist persistence))
> 
> Try source the guile-persist and add it to the load path directory
> (you probably need to do the same for stis-parser but there you should
> source the module directory in stis-parser directory)
> 
> regards
> Stefan

I was able to run "(use-modules (persist persistence))" from a guile 
prompt after adding the persist module to the load path and exporting 
LD_LIBRARY_PATH set to /usr/local/lib/guile/2.2/extensions.

Now Im getting this error on make:

-----------------
Makefile:1390: warning: overriding recipe for target 'python'
Makefile:771: warning: ignoring old recipe for target 'python'
   GEN      language/python/eval.go
guile: warning: failed to install locale
warning: failed to install locale: Invalid argument
ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
Syntax error:
/usr/share/guile/site/parser/stis-parser/lang/python3/tool.scm:37:2: 
source expression failed to match any pattern in form (<p-cc> <S> <Cut> 
<CC> c)
make: *** [Makefile:1385: language/python/eval.go] Error 1
-----------------

Regards,
David

> 
> On Thu, Feb 13, 2020 at 8:31 AM david larsson
> <david.larsson@selfhosted.xyz> wrote:
> 
>> On 2020-02-12 21:14, Stefan Israelsson Tampe wrote:
>>> I saw from the stacktrace that the repo uses a not available
>> module. I
>>> dried to fix that and missed pushing it. I agave now pushed so you
>>> could try to pull and compile again
>> 
>> Yep, now it works.
>> 
>> guile-persist builds on commit
>> 751c8834b401e81b6ea058a05861ebaf0b659f9d
>> stis-parser builds on commit
>> 8d49401e238ae703a466b5b98d3068e4fa974f2c
>> 
>> It's just the python-on-guile that fails now, for commit:
>> 226d33163e7f1e305c0b6e2ada37209513377dff
>> 
>> with:
>> ----------------
>> Makefile:1390: warning: overriding recipe for target 'python'
>> Makefile:771: warning: ignoring old recipe for target 'python'
>> GEN      oop/pf-objects.go
>> guile: warning: failed to install locale
>> warning: failed to install locale: Invalid argument
>> Backtrace:
>> In ice-9/boot-9.scm:
>> 2312:4 19 (save-module-excursion #<procedure 55e6116127c0 at
>> lang?>)
>> In language/scheme/compile-tree-il.scm:
>> 31:15 18 (_)
>> In ice-9/psyntax.scm:
>> 1235:36 17 (expand-top-sequence ((define-module (oop #) # (# ?)
>> ?)) ?)
>> 1182:24 16 (parse _ (("placeholder" placeholder)) ((top) #(# #
>> ?)) ?)
>> 285:10 15 (parse _ (("placeholder" placeholder)) (()) _ c&e (#
>> #) #)
>> In ice-9/eval.scm:
>> 293:34 14 (_ #<module (#{ g77}#) 55e6116dc0a0>)
>> In ice-9/boot-9.scm:
>> 2874:4 13 (define-module* _ #:filename _ #:pure _ #:version _ #
>> _ ?)
>> 2071:24 12 (call-with-deferred-observers #<procedure 55e611488910
>> ?>)
>> 2887:24 11 (_)
>> 222:29 10 (map1 (((oop goops)) ((oop dict) #:renamer #<proce?>)
>> ?))
>> 222:29  9 (map1 (((oop dict) #:renamer #<procedure 55e6116da?>)
>> ?))
>> 222:29  8 (map1 (((ice-9 vlist)) ((ice-9 match)) ((system # #))
>> ?))
>> 222:29  7 (map1 (((ice-9 match)) ((system base message)) ((# ?))
>> ?))
>> 222:29  6 (map1 (((system base message)) ((language python #)) #
>> ?))
>> 222:29  5 (map1 (((language python guilemod)) ((ice-9 #)) ((#
>> ?))))
>> 222:29  4 (map1 (((ice-9 pretty-print)) ((persist
>> persistance))))
>> 222:17  3 (map1 (((persist persistance))))
>> 2803:6  2 (resolve-interface _ #:select _ #:hide _ #:prefix _ #
>> _ ?)
>> In unknown file:
>> 1 (scm-error misc-error #f "~A ~S" ("no code for modu?"
>> ?) ?)
>> In ice-9/boot-9.scm:
>> 752:25  0 (dispatch-exception _ _ _)
>> 
>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>> no code for module (persist persistance)
>> make: *** [Makefile:1385: oop/pf-objects.go] Error 1
>> -----------------
>> 
>> Regards,
>> David
>> 
>>> 
>>> On Wed, Feb 12, 2020 at 9:00 PM david larsson
>>> <david.larsson@selfhosted.xyz> wrote:
>>> 
>>>> On 2020-02-12 20:52, Stefan Israelsson Tampe wrote:
>>>>> Okey, thanks, try to checkout a new version of guile-persists
>> and
>>>> try
>>>>> again
>>>> 
>>>> The commit the error message below is from is the most recent
>>>> version
>>>> AFAICT, from "22hours ago":
>> https://gitlab.com/tampe/guile-persist
>>>> commit 659abf1dc64c1aa9d9e4c27fe349100dc908ee6c
>>>> 
>>>> Regards,
>>>> David
>>>> 
>>>>> 
>>>>> On Wed, Feb 12, 2020 at 8:47 PM david larsson
>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>> 
>>>>>> On 2020-02-12 18:18, Stefan Israelsson Tampe wrote:
>>>>>>> you should update the guile-persist repo and also stis-parser,
>>>>>> there
>>>>>>> was some cond-expand issues in those as well
>>>>>> 
>>>>>> Ok. I tried that. stis-parser now built fine on commit
>>>>>> 8d49401e238ae703a466b5b98d3068e4fa974f2c
>>>>>> 
>>>>>> but guile-persist failed on make for commit:
>>>>>> 659abf1dc64c1aa9d9e4c27fe349100dc908ee6c
>>>>>> 
>>>>>> ---------------------
>>>>>> make  all-recursive
>>>>>> make[1]: Entering directory
>>>>>> '/home/user1/VirtualHome/src/guile-persist'
>>>>>> Making all in src/
>>>>>> make[2]: Entering directory
>>>>>> '/home/user1/VirtualHome/src/guile-persist/src'
>>>>>> make  all-am
>>>>>> make[3]: Entering directory
>>>>>> '/home/user1/VirtualHome/src/guile-persist/src'
>>>>>> make[3]: Nothing to be done for 'all-am'.
>>>>>> make[3]: Leaving directory
>>>>>> '/home/user1/VirtualHome/src/guile-persist/src'
>>>>>> make[2]: Leaving directory
>>>>>> '/home/user1/VirtualHome/src/guile-persist/src'
>>>>>> make[2]: Entering directory
>>>>>> '/home/user1/VirtualHome/src/guile-persist'
>>>>>> GEN      persist/slask.go
>>>>>> guile: warning: failed to install locale
>>>>>> warning: failed to install locale: Invalid argument
>>>>>> wrote `persist/slask.go'
>>>>>> GEN      persist/primitive.go
>>>>>> guile: warning: failed to install locale
>>>>>> warning: failed to install locale: Invalid argument
>>>>>> wrote `persist/primitive.go'
>>>>>> GEN      persist/persistance.go
>>>>>> guile: warning: failed to install locale
>>>>>> warning: failed to install locale: Invalid argument
>>>>>> Backtrace:
>>>>>> In ice-9/psyntax.scm:
>>>>>> 1235:36 19 (expand-top-sequence ((define-module (persist #) # #
>>>>>> ?)) ?)
>>>>>> 1182:24 18 (parse _ (("placeholder" placeholder)) ((top) #(# #
>>>>>> ?)) ?)
>>>>>> 285:10 17 (parse _ (("placeholder" placeholder)) (()) _ c&e (#
>>>>>> #) #)
>>>>>> In ice-9/eval.scm:
>>>>>> 293:34 16 (_ #<module (#{ g77}#) 55f2082600a0>)
>>>>>> In ice-9/boot-9.scm:
>>>>>> 2874:4 15 (define-module* _ #:filename _ #:pure _ #:version _ #
>>>>>> _ ?)
>>>>>> 2071:24 14 (call-with-deferred-observers #<procedure
>> 55f20800c0f0
>>>>>> ?>)
>>>>>> 2887:24 13 (_)
>>>>>> 222:29 12 (map1 (((system vm loader)) ((system vm program)) (#)
>>>>>> ?))
>>>>>> 222:29 11 (map1 (((system vm program)) ((system vm debug))
>> ((?))
>>>>>> ?))
>>>>>> 222:29 10 (map1 (((system vm debug)) ((system vm dwarf)) ((#
>> ?))
>>>>>> ?))
>>>>>> 222:29  9 (map1 (((system vm dwarf)) ((ice-9 match)) ((ice-9
>> ?))
>>>>>> ?))
>>>>>> 222:29  8 (map1 (((ice-9 match)) ((ice-9 vlist)) ((ice-9 #))
>> (#)
>>>>>> ?))
>>>>>> 222:29  7 (map1 (((ice-9 vlist)) ((ice-9 control)) ((ice-9 #))
>> #
>>>>>> ?))
>>>>>> 222:29  6 (map1 (((ice-9 control)) ((ice-9 pretty-print)) ((?))
>>>>>> ?))
>>>>>> 222:29  5 (map1 (((ice-9 pretty-print)) ((oop goops)) ((oop #))
>>>>>> ?))
>>>>>> 222:29  4 (map1 (((oop goops)) ((oop dict)) ((persist #)) ((?))
>>>>>> ?))
>>>>>> 222:17  3 (map1 (((oop dict)) ((persist primitive)) ((# #)) (#)
>>>>>> #))
>>>>>> 2803:6  2 (resolve-interface _ #:select _ #:hide _ #:prefix _ #
>>>>>> _ ?)
>>>>>> In unknown file:
>>>>>> 1 (scm-error misc-error #f "~A ~S" ("no code for modu?"
>>>>>> ?) ?)
>>>>>> In ice-9/boot-9.scm:
>>>>>> 752:25  0 (dispatch-exception _ _ _)
>>>>>> 
>>>>>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>>>>>> no code for module (oop dict)
>>>>>> make[2]: *** [Makefile:945: persist/persistance.go] Error 1
>>>>>> make[2]: Leaving directory
>>>>>> '/home/user1/VirtualHome/src/guile-persist'
>>>>>> make[1]: *** [Makefile:519: all-recursive] Error 1
>>>>>> make[1]: Leaving directory
>>>>>> '/home/user1/VirtualHome/src/guile-persist'
>>>>>> make: *** [Makefile:399: all] Error 2
>>>>>> -------------------------
>>>>>> 
>>>>>> The error seems very related to the make error for
>>>> python-on-guile.
>>>>>> 
>>>>>> Regards,
>>>>>> David
>>>>>> 
>>>>>>> 
>>>>>>> On Wed, Feb 12, 2020 at 4:26 PM david larsson
>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>> 
>>>>>>>> On 2020-02-12 10:59, Stefan Israelsson Tampe wrote:
>>>>>>>>> no code for module (persist persistance)
>>>>>>>>> 
>>>>>>>>> can you use  (persist persistance)  e.g. from the guile
>> shell,
>>>>>>>>> 
>>>>>>>>>> (use-modules  (persist persistance) )
>>>>>>>> 
>>>>>>>> Nope, that gives the same error. I had some issue when
>>>> compiling
>>>>>> the
>>>>>>>> 
>>>>>>>> stis-parser and/or guile-persist as well and solved it by
>>>> adding
>>>>>> a
>>>>>>>> symlink in /usr/local/include/ something. So Ill look into
>>>>>> whether I
>>>>>>>> 
>>>>>>>> have some path/environment variable issue on my machine. Im
>>>>>> running
>>>>>>>> PureOS which I think tracks Debian stable, so some stuff can
>> be
>>>>>>>> pretty
>>>>>>>> old and maybe thats the reason.
>>>>>>>> 
>>>>>>>> Regards,
>>>>>>>> David
>>>>>>>> 
>>>>>>>>> ...
>>>>>>>>> 
>>>>>>>>> /Stefan
>>>>>>>>> 
>>>>>>>>> On Wed, Feb 12, 2020 at 10:18 AM david larsson
>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>> 
>>>>>>>>>> On 2020-02-11 21:57, Stefan Israelsson Tampe wrote:
>>>>>>>>>>> This error is fixed in repository
>>>>>>>>>>> /Stefan
>>>>>>>>>> 
>>>>>>>>>> Thanks. That solved that part. Now Im getting this error on
>>>>>> make:
>>>>>>>>>> 
>>>>>>>>>> (commit 226d33163e7f1e305c0b6e2ada37209513377dff)
>>>>>>>>>> ----------------------
>>>>>>>>>> 
>>>>>>>>>> Makefile:1390: warning: overriding recipe for target
>> 'python'
>>>>>>>>>> Makefile:771: warning: ignoring old recipe for target
>>>> 'python'
>>>>>>>>>> GEN      oop/pf-objects.go
>>>>>>>>>> guile: warning: failed to install locale
>>>>>>>>>> warning: failed to install locale: Invalid argument
>>>>>>>>>> Backtrace:
>>>>>>>>>> In ice-9/boot-9.scm:
>>>>>>>>>> 2312:4 19 (save-module-excursion #<procedure 55a897256bc0
>> at
>>>>>>>>>> lang?>)
>>>>>>>>>> In language/scheme/compile-tree-il.scm:
>>>>>>>>>> 31:15 18 (_)
>>>>>>>>>> In ice-9/psyntax.scm:
>>>>>>>>>> 1235:36 17 (expand-top-sequence ((define-module (oop #) #
>> (#
>>>> ?)
>>>>>>>>>> ?)) ?)
>>>>>>>>>> 1182:24 16 (parse _ (("placeholder" placeholder)) ((top)
>> #(#
>>>> #
>>>>>>>>>> ?)) ?)
>>>>>>>>>> 285:10 15 (parse _ (("placeholder" placeholder)) (()) _ c&e
>>>> (#
>>>>>>>>>> #) #)
>>>>>>>>>> In ice-9/eval.scm:
>>>>>>>>>> 293:34 14 (_ #<module (#{ g77}#) 55a8972dd0a0>)
>>>>>>>>>> In ice-9/boot-9.scm:
>>>>>>>>>> 2874:4 13 (define-module* _ #:filename _ #:pure _ #:version
>> _
>>>> #
>>>>>>>>>> _ ?)
>>>>>>>>>> 2071:24 12 (call-with-deferred-observers #<procedure
>>>>>> 55a897086910
>>>>>>>>>> ?>)
>>>>>>>>>> 2887:24 11 (_)
>>>>>>>>>> 222:29 10 (map1 (((oop goops)) ((oop dict) #:renamer
>>>> #<proce?>)
>>>>>>>>>> ?))
>>>>>>>>>> 222:29  9 (map1 (((oop dict) #:renamer #<procedure
>>>> 55a8972fb?>)
>>>>>>>>>> ?))
>>>>>>>>>> 222:29  8 (map1 (((ice-9 vlist)) ((ice-9 match)) ((system #
>>>> #))
>>>>>>>>>> ?))
>>>>>>>>>> 222:29  7 (map1 (((ice-9 match)) ((system base message))
>> ((#
>>>>>> ?))
>>>>>>>>>> ?))
>>>>>>>>>> 222:29  6 (map1 (((system base message)) ((language python
>>>> #))
>>>>>> #
>>>>>>>>>> ?))
>>>>>>>>>> 222:29  5 (map1 (((language python guilemod)) ((ice-9 #))
>> ((#
>>>>>>>>>> ?))))
>>>>>>>>>> 222:29  4 (map1 (((ice-9 pretty-print)) ((persist
>>>>>>>>>> persistance))))
>>>>>>>>>> 222:17  3 (map1 (((persist persistance))))
>>>>>>>>>> 2803:6  2 (resolve-interface _ #:select _ #:hide _ #:prefix
>> _
>>>> #
>>>>>>>>>> _ ?)
>>>>>>>>>> In unknown file:
>>>>>>>>>> 1 (scm-error misc-error #f "~A ~S" ("no code for modu?"
>>>>>>>>>> ?) ?)
>>>>>>>>>> In ice-9/boot-9.scm:
>>>>>>>>>> 752:25  0 (dispatch-exception _ _ _)
>>>>>>>>>> 
>>>>>>>>>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>>>>>>>>>> no code for module (persist persistance)
>>>>>>>>>> make: *** [Makefile:1385: oop/pf-objects.go] Error 1
>>>>>>>>>> 
>>>>>>>>>> ----------------------
>>>>>>>>>> 
>>>>>>>>>> Regards,
>>>>>>>>>> David
>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> On Tue, Feb 11, 2020 at 8:17 AM david larsson
>>>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>>>> 
>>>>>>>>>>>> On 2020-02-10 21:11, Stefan Israelsson Tampe wrote:
>>>>>>>>>>>>> I have now added the bytes constructor that was not
>>>> working.
>>>>>>>>>>>> 
>>>>>>>>>>>> Thanks!
>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> To compile from source please try use the git repository
>>>> at:
>>>>>>>>>>>>> 
>>>>>>>>>>>>> https://gitlab.com/python-on-guile/python-on-guile/
>>>>>>>>>>>>> 
>>>>>>>>>>>>> see readme for how to compile and what dependencies you
>>>>>> have.
>>>>>>>>>>>> 
>>>>>>>>>>>> I was able to build and install:
>>>>>>>>>>>> - guile-persist: commit
>>>>>>>> ebebb66ae6d6c47dbc406cdbcaccb5ffed2e463a
>>>>>>>>>>>> - stis-parser: commit
>>>>>> 7673dd576abb445fbcfce8c4b6ae961ee860902e
>>>>>>>>>>>> 
>>>>>>>>>>>> but for python-on-guile Im getting this error on make:
>>>>>>>>>>>> 
>>>>>>>>>>>> --------------
>>>>>>>>>>>> 
>>>>>>>>>>>> Makefile:1390: warning: overriding recipe for target
>>>> 'python'
>>>>>>>>>>>> Makefile:771: warning: ignoring old recipe for target
>>>>>> 'python'
>>>>>>>>>>>> GEN      language/python/guilemod.go
>>>>>>>>>>>> guile: warning: failed to install locale
>>>>>>>>>>>> warning: failed to install locale: Invalid argument
>>>>>>>>>>>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>>>>>>>>>>>> Syntax error:
>>>>>>>>>>>> language/python/guilemod.scm:271:0: cond-expand:
>>>> unfulfilled
>>>>>>>>>>>> cond-expand
>>>>>>>>>>>> in form (cond-expand (guile-3.0 (define-set-M
>>>>>>>> lookup-warning-type
>>>>>>>>>>>> lookup-warning-type) (define-set-M warning warning) (set!
>>>>>>>>>>>> %warning-types
>>>>>>>>>>>> w-types)) (guile-2.0 or guile-2.2 (define-M
>> %warning-types
>>>>>>>>>> w-types)
>>>>>>>>>>>> (define-exp-M lookup-warning-type (lambda (name) "Return
>>>> the
>>>>>>>>>> warning
>>>>>>>>>>>> 
>>>>>>>>>>>> type NAME or `#f' if not found." ((M find) (lambda (wt)
>>>> (eq?
>>>>>>>> name
>>>>>>>>>>>> ((M
>>>>>>>>>>>> warning-type-name) wt))) (M %warning-types))))))
>>>>>>>>>>>> make: *** [Makefile:1385: language/python/guilemod.go]
>>>> Error
>>>>>> 1
>>>>>>>>>>>> 
>>>>>>>>>>>> ---------------
>>>>>>>>>>>> 
>>>>>>>>>>>> Im compiling with guile2.2
>>>>>>>>>>>> 
>>>>>>>>>>>> Regards,
>>>>>>>>>>>> David
>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Regards
>>>>>>>>>>>>> Stefan
>>>>>>>>>>>>> 
>>>>>>>>>>>>> On Mon, Feb 10, 2020 at 1:14 PM david larsson
>>>>>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>>> On 2020-02-09 21:36, Stefan Israelsson Tampe wrote:
>>>>>>>>>>>>>>> in sys that is
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> On Sun, Feb 9, 2020 at 9:36 PM Stefan Israelsson Tampe
>>>>>>>>>>>>>>> <stefan.itampe@gmail.com> wrote:
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> OKey, I changed the values from immutable lists to
>>>> lists.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Great!
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> On Sun, Feb 9, 2020 at 9:27 PM Stefan Israelsson
>> Tampe
>>>>>>>>>>>>>>>> <stefan.itampe@gmail.com> wrote:
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Note that a lot of things are untested because I'm
>>>> alone
>>>>>> on
>>>>>>>>>> the
>>>>>>>>>>>>>>>> development.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Ok, I understand.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> I haven't been able to build a recent version, but if
>> you
>>>>>> can
>>>>>>>>>>>> share
>>>>>>>>>>>>>> some
>>>>>>>>>>>>>> updated instructions, then I could perhaps help out
>> with
>>>>>> some
>>>>>>>>>>>>>> occasional
>>>>>>>>>>>>>> testing. I have only managed to build from the old
>> commit
>>>>>>>>>> fc0d7a9
>>>>>>>>>>>> by
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> updating the current python-on-guile guix package
>>>> locally.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> netlib is not included, you can test to add the
>> python
>>>>>>>> module
>>>>>>>>>>>>>> file
>>>>>>>>>>>>>>>> to a (language python module) directory
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> What's been working for me so far is only (load
>>>>>>>>>>>> "path/to/file.py")
>>>>>>>>>>>>>> and
>>>>>>>>>>>>>> (load-compiled "path/to/file.go").
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> (use-modules (a b c)) did not work for me, except to
>> load
>>>>>>>>>> modules
>>>>>>>>>>>>>> already shipped with python-on-guile repo; (language
>>>> python
>>>>>>>>>>>> module
>>>>>>>>>>>>>> python) etc.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> I have recently added much more of the python stdlib
>>>> aka
>>>>>>>> 3.7
>>>>>>>>>>>> but
>>>>>>>>>>>>>> not
>>>>>>>>>>>>>>>> all.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Not sure what you mean by .scm file and .py fle when
>> it
>>>>>>>> comes
>>>>>>>>>>>> to
>>>>>>>>>>>>>>>> base64
>>>>>>>>>>>>>>>> using that module in scheme gives
>>>>>>>>>>>>>>>> scheme@(guile-user)> (b64decode (b64encode "abc"))
>>>>>>>>>>>>>>>> $2 = b'abc'
>>>>>>>>>>>>>>>> scheme@(guile-user)> (b64decode (b64encode #(1 2 3)))
>>>>>>>>>>>>>>>> $3 = b'\x01\x02\x03'
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Which return a bytevector if you want a string back
>> you
>>>>>>>> need
>>>>>>>>>> to
>>>>>>>>>>>>>>>> interpret the bytevector back to a string
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Im getting weird results when trying to output the
>> base64
>>>>>>>>>>>>>> representation
>>>>>>>>>>>>>> of a string, take btest.py:
>>>>>>>>>>>>>> #import sys
>>>>>>>>>>>>>> import base64
>>>>>>>>>>>>>> def mybmethod(x):
>>>>>>>>>>>>>> mybytes = bytes(x, "utf-8")
>>>>>>>>>>>>>> encodedbytes = base64.b64encode(mybytes)
>>>>>>>>>>>>>> myb64string = str(encodedbytes, "utf-8")
>>>>>>>>>>>>>> return myb64string
>>>>>>>>>>>>>> #print(myb64string)
>>>>>>>>>>>>>> #mybmethod(sys.argv[1])
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> and assume btest.scm using it with:
>>>>>>>>>>>>>> (add-to-load-path (dirname (current-filename)))
>>>>>>>>>>>>>> (use-modules (language python module python))
>>>>>>>>>>>>>> (load "btest.py")
>>>>>>>>>>>>>> (define-public (mybmethodscm cmdline)
>>>>>>>>>>>>>> (display (mybmethod (cadr cmdline))))
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> With this it will not work to run the scheme file with
>>>>>>>>>>>>>> guile -e mybmethodscm btest.scm dfasdf
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> The error I got indicated that btest.py uses the bytes
>>>>>>>>>> procedure
>>>>>>>>>>>>>> from
>>>>>>>>>>>>>> within python-on-guile instead of from the python3
>> base64
>>>>>>>> lib:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> -------------------
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> In
>>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> /home/user1/VirtualHome/src/code_guile/python-on-guile-test/btest.scm:
>>>>>>>>>>>>>> 18:11  4 (mybmethodscm _)
>>>>>>>>>>>>>> In btest.py:
>>>>>>>>>>>>>> 10:584  3 (_ "dfasdf" . _)
>>>>>>>>>>>>>> In oop/pf-objects.scm:
>>>>>>>>>>>>>> 584:15  2 (create-object _ _)
>>>>>>>>>>>>>> 567:11  1 (the-create-object _ _)
>>>>>>>>>>>>>> In language/python/bytes.scm:
>>>>>>>>>>>>>> 99:6  0 Exception thrown while printing backtrace:
>>>>>>>>>>>>>> Unbound slot in object Error while printing exception.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> language/python/bytes.scm:99:6: Wrong number of
>> arguments
>>>>>> to
>>>>>>>>>>>>>> #<procedure
>>>>>>>>>>>>>> 7f2bab5d4560 at language/python/bytes.scm:92:0 (self) |
>>>>>> (self
>>>>>>>>>> s)>
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> -------------------
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> For a moment though, I could run:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> guile -e mybmethodscm btest.scm dfasdf | rev | base64
>> -d
>>>> |
>>>>>>>> rev
>>>>>>>>>>>>>> # gives: dfasdf
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> which was also strange.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> modules are a bit difficult as I use the guile module
>>>>>>>> system
>>>>>>>>>>>> and
>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>>> python modules are different.
>>>>>>>>>>>>>>>> So nested modules needs some work. The best is to
>> test
>>>>>> and
>>>>>>>>>> see.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Ok, got it!
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> I will look into the sys thingies
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>> Stefan
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> On Sun, Feb 9, 2020 at 8:40 PM david larsson
>>>>>>>>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>>>>>>>>> Thanks for your explanations, but unfortunately I
>> still
>>>>>>>> can't
>>>>>>>>>>>>>> figure
>>>>>>>>>>>>>>>> out
>>>>>>>>>>>>>>>> how to use this except in the simplest of cases.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> I am using the guix package python-on-guile
>>>>>> 0.1.0-3.00a51a2
>>>>>>>> -
>>>>>>>>>>>>>> maybe
>>>>>>>>>>>>>>>> thats outdated?
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> The simple things I have managed to do, are like:
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> (add-to-load-path (dirname (current-filename)))
>>>>>>>>>>>>>>>> (load-compiled python-test.go)
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> where python-test.go is compiled with:
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> guild compile python-test.py --output=python-test.go
>>>>>>>>>>>>>>>> --from=python
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> and contains simple things, like:
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> f(s):
>>>>>>>>>>>>>>>> a = s + 1
>>>>>>>>>>>>>>>> return a
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> but if I add statements to python-test.py like:
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> import netaddr
>>>>>>>>>>>>>>>> def myfun(a)
>>>>>>>>>>>>>>>> <something using netaddr>
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> (netaddr is a module installed via: pip3 install
>> --user
>>>>>>>>>>>> netaddr)
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> I receive an error about not finding the module.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> I am able to add only the modules which exist in the
>>>>>>>>>>>>>> python-on-guile
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> repo, like:
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> import sys
>>>>>>>>>>>>>>>> import base64
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> but Im getting errors, for example Im not able to use
>>>>>>>> things
>>>>>>>>>>>> from
>>>>>>>>>>>>>>>> sys,
>>>>>>>>>>>>>>>> like:
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> sys.path.append(<somepath>)
>>>>>>>>>>>>>>>> sys.path.insert(0, <somepath>)
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> I was able to use some things from base64 but I only
>>>>>>>> received
>>>>>>>>>>>>>> weird
>>>>>>>>>>>>>>>> results when converting between bytevectors and
>> strings
>>>>>>>>>> between
>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>>> .scm
>>>>>>>>>>>>>>>> file and .py file. What works fine using python3
>>>>>>>>>> python-test.py
>>>>>>>>>>>>>> do
>>>>>>>>>>>>>>>> not
>>>>>>>>>>>>>>>> usually work when passing either a bytevector or
>> string
>>>>>> to
>>>>>>>>>> the
>>>>>>>>>>>>>> same
>>>>>>>>>>>>>>>> go-compiled file from the .scm file using the
>>>>>> python-code.
>>>>>>>>>> Not
>>>>>>>>>>>>>> sure
>>>>>>>>>>>>>>>> whether there's a problem using python3 vs python2
>>>> here?
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Essentially, what Im looking for is how to proceed if
>> I
>>>>>>>> want
>>>>>>>>>> to
>>>>>>>>>>>>>> use
>>>>>>>>>>>>>>>> modules installed via the pip package manager from
>>>> guile,
>>>>>>>> and
>>>>>>>>>>>>>> what
>>>>>>>>>>>>>>>> paths
>>>>>>>>>>>>>>>> and imports I need to make, and how I might need to
>>>> wrap
>>>>>>>> them
>>>>>>>>>>>>>>>> correctly
>>>>>>>>>>>>>>>> in the scheme and python files to invoke a pip
>> package
>>>>>>>>>>>> procedure
>>>>>>>>>>>>>>>> from
>>>>>>>>>>>>>>>> guile.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Best regards,
>>>>>>>>>>>>>>>> David
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
>>>>>>>>>>>>>>>>> I'm the author of that lib.
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> 1)
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> The main bindings are reachable through (language
>>>> python
>>>>>>>>>>>> module
>>>>>>>>>>>>>>>>> python)
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> So you could now go ahead and do
>>>>>>>>>>>>>>>>>> (use-modules (language python module python))
>>>>>>>>>>>>>>>>>> ;L python
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> And you will get a python shell that works quite ok
>>>> for
>>>>>>>> one
>>>>>>>>>>>>>> liners
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> 2)
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> If you write a module and place it in a/b/c.py
>>>>>>>>>>>>>>>>> you can use the classes and functions theirin by
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> (use-modules (a b c))
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> 3)
>>>>>>>>>>>>>>>>> you can load a .py file as (i hope this work)
>>>>>>>>>>>>>>>>> (load "a.py")
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> 4)
>>>>>>>>>>>>>>>>> If you place a module in (language python module
>> a.py)
>>>>>> you
>>>>>>>>>> can
>>>>>>>>>>>>>>>> import
>>>>>>>>>>>>>>>>> ir as a usual mode as
>>>>>>>>>>>>>>>>>> from a import *
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> The documentation is for the macro framework that
>>>>>> enables
>>>>>>>>>> you
>>>>>>>>>>>> to
>>>>>>>>>>>>>>>> work
>>>>>>>>>>>>>>>>> with python classes and idioms like python
>> iteration.
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> Hope this helps
>>>>>>>>>>>>>>>>> /Stefan
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> On Sun, Feb 9, 2020 at 6:31 PM david larsson
>>>>>>>>>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> Hi everyone,
>>>>>>>>>>>>>>>>>> I am trying to wrap my head around how to use the
>>>>>>>>>>>>>> python-on-guile
>>>>>>>>>>>>>>>>>> library, but Im struggling. Does anyone have
>> example
>>>>>> code
>>>>>>>>>>>> that
>>>>>>>>>>>>>>>> might
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> help, and which isn't too advanced?
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> All tips and suggestions appreciated!
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> Best regards,
>>>>>>>>>>>>>>>>>> David



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
       [not found]                                 ` <CAGua6m12ytkdDcHj+PEx615qCzaXPB4P+u-DCqWQexuRo28BWA@mail.gmail.com>
@ 2020-02-13  7:30                                   ` david larsson
       [not found]                                     ` <CAGua6m2+hEpGf8Z+CfyO+-mKH4sQF-mVb7YS1=+88hF2bRkjPw@mail.gmail.com>
  0 siblings, 1 reply; 38+ messages in thread
From: david larsson @ 2020-02-13  7:30 UTC (permalink / raw)
  To: Stefan Israelsson Tampe; +Cc: guile-user

On 2020-02-12 21:14, Stefan Israelsson Tampe wrote:
> I saw from the stacktrace that the repo uses a not available module. I
> dried to fix that and missed pushing it. I agave now pushed so you
> could try to pull and compile again

Yep, now it works.

guile-persist builds on commit 751c8834b401e81b6ea058a05861ebaf0b659f9d
stis-parser builds on commit 8d49401e238ae703a466b5b98d3068e4fa974f2c

It's just the python-on-guile that fails now, for commit:
226d33163e7f1e305c0b6e2ada37209513377dff

with:
----------------
Makefile:1390: warning: overriding recipe for target 'python'
Makefile:771: warning: ignoring old recipe for target 'python'
   GEN      oop/pf-objects.go
guile: warning: failed to install locale
warning: failed to install locale: Invalid argument
Backtrace:
In ice-9/boot-9.scm:
    2312:4 19 (save-module-excursion #<procedure 55e6116127c0 at lang?>)
In language/scheme/compile-tree-il.scm:
     31:15 18 (_)
In ice-9/psyntax.scm:
   1235:36 17 (expand-top-sequence ((define-module (oop #) # (# ?) ?)) ?)
   1182:24 16 (parse _ (("placeholder" placeholder)) ((top) #(# # ?)) ?)
    285:10 15 (parse _ (("placeholder" placeholder)) (()) _ c&e (# #) #)
In ice-9/eval.scm:
    293:34 14 (_ #<module (#{ g77}#) 55e6116dc0a0>)
In ice-9/boot-9.scm:
    2874:4 13 (define-module* _ #:filename _ #:pure _ #:version _ # _ ?)
   2071:24 12 (call-with-deferred-observers #<procedure 55e611488910 ?>)
   2887:24 11 (_)
    222:29 10 (map1 (((oop goops)) ((oop dict) #:renamer #<proce?>) ?))
    222:29  9 (map1 (((oop dict) #:renamer #<procedure 55e6116da?>) ?))
    222:29  8 (map1 (((ice-9 vlist)) ((ice-9 match)) ((system # #)) ?))
    222:29  7 (map1 (((ice-9 match)) ((system base message)) ((# ?)) ?))
    222:29  6 (map1 (((system base message)) ((language python #)) # ?))
    222:29  5 (map1 (((language python guilemod)) ((ice-9 #)) ((# ?))))
    222:29  4 (map1 (((ice-9 pretty-print)) ((persist persistance))))
    222:17  3 (map1 (((persist persistance))))
    2803:6  2 (resolve-interface _ #:select _ #:hide _ #:prefix _ # _ ?)
In unknown file:
            1 (scm-error misc-error #f "~A ~S" ("no code for modu?" ?) ?)
In ice-9/boot-9.scm:
    752:25  0 (dispatch-exception _ _ _)

ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
no code for module (persist persistance)
make: *** [Makefile:1385: oop/pf-objects.go] Error 1
-----------------

Regards,
David

> 
> On Wed, Feb 12, 2020 at 9:00 PM david larsson
> <david.larsson@selfhosted.xyz> wrote:
> 
>> On 2020-02-12 20:52, Stefan Israelsson Tampe wrote:
>>> Okey, thanks, try to checkout a new version of guile-persists and
>> try
>>> again
>> 
>> The commit the error message below is from is the most recent
>> version
>> AFAICT, from "22hours ago": https://gitlab.com/tampe/guile-persist
>> commit 659abf1dc64c1aa9d9e4c27fe349100dc908ee6c
>> 
>> Regards,
>> David
>> 
>>> 
>>> On Wed, Feb 12, 2020 at 8:47 PM david larsson
>>> <david.larsson@selfhosted.xyz> wrote:
>>> 
>>>> On 2020-02-12 18:18, Stefan Israelsson Tampe wrote:
>>>>> you should update the guile-persist repo and also stis-parser,
>>>> there
>>>>> was some cond-expand issues in those as well
>>>> 
>>>> Ok. I tried that. stis-parser now built fine on commit
>>>> 8d49401e238ae703a466b5b98d3068e4fa974f2c
>>>> 
>>>> but guile-persist failed on make for commit:
>>>> 659abf1dc64c1aa9d9e4c27fe349100dc908ee6c
>>>> 
>>>> ---------------------
>>>> make  all-recursive
>>>> make[1]: Entering directory
>>>> '/home/user1/VirtualHome/src/guile-persist'
>>>> Making all in src/
>>>> make[2]: Entering directory
>>>> '/home/user1/VirtualHome/src/guile-persist/src'
>>>> make  all-am
>>>> make[3]: Entering directory
>>>> '/home/user1/VirtualHome/src/guile-persist/src'
>>>> make[3]: Nothing to be done for 'all-am'.
>>>> make[3]: Leaving directory
>>>> '/home/user1/VirtualHome/src/guile-persist/src'
>>>> make[2]: Leaving directory
>>>> '/home/user1/VirtualHome/src/guile-persist/src'
>>>> make[2]: Entering directory
>>>> '/home/user1/VirtualHome/src/guile-persist'
>>>> GEN      persist/slask.go
>>>> guile: warning: failed to install locale
>>>> warning: failed to install locale: Invalid argument
>>>> wrote `persist/slask.go'
>>>> GEN      persist/primitive.go
>>>> guile: warning: failed to install locale
>>>> warning: failed to install locale: Invalid argument
>>>> wrote `persist/primitive.go'
>>>> GEN      persist/persistance.go
>>>> guile: warning: failed to install locale
>>>> warning: failed to install locale: Invalid argument
>>>> Backtrace:
>>>> In ice-9/psyntax.scm:
>>>> 1235:36 19 (expand-top-sequence ((define-module (persist #) # #
>>>> ?)) ?)
>>>> 1182:24 18 (parse _ (("placeholder" placeholder)) ((top) #(# #
>>>> ?)) ?)
>>>> 285:10 17 (parse _ (("placeholder" placeholder)) (()) _ c&e (#
>>>> #) #)
>>>> In ice-9/eval.scm:
>>>> 293:34 16 (_ #<module (#{ g77}#) 55f2082600a0>)
>>>> In ice-9/boot-9.scm:
>>>> 2874:4 15 (define-module* _ #:filename _ #:pure _ #:version _ #
>>>> _ ?)
>>>> 2071:24 14 (call-with-deferred-observers #<procedure 55f20800c0f0
>>>> ?>)
>>>> 2887:24 13 (_)
>>>> 222:29 12 (map1 (((system vm loader)) ((system vm program)) (#)
>>>> ?))
>>>> 222:29 11 (map1 (((system vm program)) ((system vm debug)) ((?))
>>>> ?))
>>>> 222:29 10 (map1 (((system vm debug)) ((system vm dwarf)) ((# ?))
>>>> ?))
>>>> 222:29  9 (map1 (((system vm dwarf)) ((ice-9 match)) ((ice-9 ?))
>>>> ?))
>>>> 222:29  8 (map1 (((ice-9 match)) ((ice-9 vlist)) ((ice-9 #)) (#)
>>>> ?))
>>>> 222:29  7 (map1 (((ice-9 vlist)) ((ice-9 control)) ((ice-9 #)) #
>>>> ?))
>>>> 222:29  6 (map1 (((ice-9 control)) ((ice-9 pretty-print)) ((?))
>>>> ?))
>>>> 222:29  5 (map1 (((ice-9 pretty-print)) ((oop goops)) ((oop #))
>>>> ?))
>>>> 222:29  4 (map1 (((oop goops)) ((oop dict)) ((persist #)) ((?))
>>>> ?))
>>>> 222:17  3 (map1 (((oop dict)) ((persist primitive)) ((# #)) (#)
>>>> #))
>>>> 2803:6  2 (resolve-interface _ #:select _ #:hide _ #:prefix _ #
>>>> _ ?)
>>>> In unknown file:
>>>> 1 (scm-error misc-error #f "~A ~S" ("no code for modu?"
>>>> ?) ?)
>>>> In ice-9/boot-9.scm:
>>>> 752:25  0 (dispatch-exception _ _ _)
>>>> 
>>>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>>>> no code for module (oop dict)
>>>> make[2]: *** [Makefile:945: persist/persistance.go] Error 1
>>>> make[2]: Leaving directory
>>>> '/home/user1/VirtualHome/src/guile-persist'
>>>> make[1]: *** [Makefile:519: all-recursive] Error 1
>>>> make[1]: Leaving directory
>>>> '/home/user1/VirtualHome/src/guile-persist'
>>>> make: *** [Makefile:399: all] Error 2
>>>> -------------------------
>>>> 
>>>> The error seems very related to the make error for
>> python-on-guile.
>>>> 
>>>> Regards,
>>>> David
>>>> 
>>>>> 
>>>>> On Wed, Feb 12, 2020 at 4:26 PM david larsson
>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>> 
>>>>>> On 2020-02-12 10:59, Stefan Israelsson Tampe wrote:
>>>>>>> no code for module (persist persistance)
>>>>>>> 
>>>>>>> can you use  (persist persistance)  e.g. from the guile shell,
>>>>>>> 
>>>>>>>> (use-modules  (persist persistance) )
>>>>>> 
>>>>>> Nope, that gives the same error. I had some issue when
>> compiling
>>>> the
>>>>>> 
>>>>>> stis-parser and/or guile-persist as well and solved it by
>> adding
>>>> a
>>>>>> symlink in /usr/local/include/ something. So Ill look into
>>>> whether I
>>>>>> 
>>>>>> have some path/environment variable issue on my machine. Im
>>>> running
>>>>>> PureOS which I think tracks Debian stable, so some stuff can be
>>>>>> pretty
>>>>>> old and maybe thats the reason.
>>>>>> 
>>>>>> Regards,
>>>>>> David
>>>>>> 
>>>>>>> ...
>>>>>>> 
>>>>>>> /Stefan
>>>>>>> 
>>>>>>> On Wed, Feb 12, 2020 at 10:18 AM david larsson
>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>> 
>>>>>>>> On 2020-02-11 21:57, Stefan Israelsson Tampe wrote:
>>>>>>>>> This error is fixed in repository
>>>>>>>>> /Stefan
>>>>>>>> 
>>>>>>>> Thanks. That solved that part. Now Im getting this error on
>>>> make:
>>>>>>>> 
>>>>>>>> (commit 226d33163e7f1e305c0b6e2ada37209513377dff)
>>>>>>>> ----------------------
>>>>>>>> 
>>>>>>>> Makefile:1390: warning: overriding recipe for target 'python'
>>>>>>>> Makefile:771: warning: ignoring old recipe for target
>> 'python'
>>>>>>>> GEN      oop/pf-objects.go
>>>>>>>> guile: warning: failed to install locale
>>>>>>>> warning: failed to install locale: Invalid argument
>>>>>>>> Backtrace:
>>>>>>>> In ice-9/boot-9.scm:
>>>>>>>> 2312:4 19 (save-module-excursion #<procedure 55a897256bc0 at
>>>>>>>> lang?>)
>>>>>>>> In language/scheme/compile-tree-il.scm:
>>>>>>>> 31:15 18 (_)
>>>>>>>> In ice-9/psyntax.scm:
>>>>>>>> 1235:36 17 (expand-top-sequence ((define-module (oop #) # (#
>> ?)
>>>>>>>> ?)) ?)
>>>>>>>> 1182:24 16 (parse _ (("placeholder" placeholder)) ((top) #(#
>> #
>>>>>>>> ?)) ?)
>>>>>>>> 285:10 15 (parse _ (("placeholder" placeholder)) (()) _ c&e
>> (#
>>>>>>>> #) #)
>>>>>>>> In ice-9/eval.scm:
>>>>>>>> 293:34 14 (_ #<module (#{ g77}#) 55a8972dd0a0>)
>>>>>>>> In ice-9/boot-9.scm:
>>>>>>>> 2874:4 13 (define-module* _ #:filename _ #:pure _ #:version _
>> #
>>>>>>>> _ ?)
>>>>>>>> 2071:24 12 (call-with-deferred-observers #<procedure
>>>> 55a897086910
>>>>>>>> ?>)
>>>>>>>> 2887:24 11 (_)
>>>>>>>> 222:29 10 (map1 (((oop goops)) ((oop dict) #:renamer
>> #<proce?>)
>>>>>>>> ?))
>>>>>>>> 222:29  9 (map1 (((oop dict) #:renamer #<procedure
>> 55a8972fb?>)
>>>>>>>> ?))
>>>>>>>> 222:29  8 (map1 (((ice-9 vlist)) ((ice-9 match)) ((system #
>> #))
>>>>>>>> ?))
>>>>>>>> 222:29  7 (map1 (((ice-9 match)) ((system base message)) ((#
>>>> ?))
>>>>>>>> ?))
>>>>>>>> 222:29  6 (map1 (((system base message)) ((language python
>> #))
>>>> #
>>>>>>>> ?))
>>>>>>>> 222:29  5 (map1 (((language python guilemod)) ((ice-9 #)) ((#
>>>>>>>> ?))))
>>>>>>>> 222:29  4 (map1 (((ice-9 pretty-print)) ((persist
>>>>>>>> persistance))))
>>>>>>>> 222:17  3 (map1 (((persist persistance))))
>>>>>>>> 2803:6  2 (resolve-interface _ #:select _ #:hide _ #:prefix _
>> #
>>>>>>>> _ ?)
>>>>>>>> In unknown file:
>>>>>>>> 1 (scm-error misc-error #f "~A ~S" ("no code for modu?"
>>>>>>>> ?) ?)
>>>>>>>> In ice-9/boot-9.scm:
>>>>>>>> 752:25  0 (dispatch-exception _ _ _)
>>>>>>>> 
>>>>>>>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>>>>>>>> no code for module (persist persistance)
>>>>>>>> make: *** [Makefile:1385: oop/pf-objects.go] Error 1
>>>>>>>> 
>>>>>>>> ----------------------
>>>>>>>> 
>>>>>>>> Regards,
>>>>>>>> David
>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> On Tue, Feb 11, 2020 at 8:17 AM david larsson
>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>> 
>>>>>>>>>> On 2020-02-10 21:11, Stefan Israelsson Tampe wrote:
>>>>>>>>>>> I have now added the bytes constructor that was not
>> working.
>>>>>>>>>> 
>>>>>>>>>> Thanks!
>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> To compile from source please try use the git repository
>> at:
>>>>>>>>>>> 
>>>>>>>>>>> https://gitlab.com/python-on-guile/python-on-guile/
>>>>>>>>>>> 
>>>>>>>>>>> see readme for how to compile and what dependencies you
>>>> have.
>>>>>>>>>> 
>>>>>>>>>> I was able to build and install:
>>>>>>>>>> - guile-persist: commit
>>>>>> ebebb66ae6d6c47dbc406cdbcaccb5ffed2e463a
>>>>>>>>>> - stis-parser: commit
>>>> 7673dd576abb445fbcfce8c4b6ae961ee860902e
>>>>>>>>>> 
>>>>>>>>>> but for python-on-guile Im getting this error on make:
>>>>>>>>>> 
>>>>>>>>>> --------------
>>>>>>>>>> 
>>>>>>>>>> Makefile:1390: warning: overriding recipe for target
>> 'python'
>>>>>>>>>> Makefile:771: warning: ignoring old recipe for target
>>>> 'python'
>>>>>>>>>> GEN      language/python/guilemod.go
>>>>>>>>>> guile: warning: failed to install locale
>>>>>>>>>> warning: failed to install locale: Invalid argument
>>>>>>>>>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>>>>>>>>>> Syntax error:
>>>>>>>>>> language/python/guilemod.scm:271:0: cond-expand:
>> unfulfilled
>>>>>>>>>> cond-expand
>>>>>>>>>> in form (cond-expand (guile-3.0 (define-set-M
>>>>>> lookup-warning-type
>>>>>>>>>> lookup-warning-type) (define-set-M warning warning) (set!
>>>>>>>>>> %warning-types
>>>>>>>>>> w-types)) (guile-2.0 or guile-2.2 (define-M %warning-types
>>>>>>>> w-types)
>>>>>>>>>> (define-exp-M lookup-warning-type (lambda (name) "Return
>> the
>>>>>>>> warning
>>>>>>>>>> 
>>>>>>>>>> type NAME or `#f' if not found." ((M find) (lambda (wt)
>> (eq?
>>>>>> name
>>>>>>>>>> ((M
>>>>>>>>>> warning-type-name) wt))) (M %warning-types))))))
>>>>>>>>>> make: *** [Makefile:1385: language/python/guilemod.go]
>> Error
>>>> 1
>>>>>>>>>> 
>>>>>>>>>> ---------------
>>>>>>>>>> 
>>>>>>>>>> Im compiling with guile2.2
>>>>>>>>>> 
>>>>>>>>>> Regards,
>>>>>>>>>> David
>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> Regards
>>>>>>>>>>> Stefan
>>>>>>>>>>> 
>>>>>>>>>>> On Mon, Feb 10, 2020 at 1:14 PM david larsson
>>>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>>>> 
>>>>>>>>>>>> On 2020-02-09 21:36, Stefan Israelsson Tampe wrote:
>>>>>>>>>>>>> in sys that is
>>>>>>>>>>>>> 
>>>>>>>>>>>>> On Sun, Feb 9, 2020 at 9:36 PM Stefan Israelsson Tampe
>>>>>>>>>>>>> <stefan.itampe@gmail.com> wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>>> OKey, I changed the values from immutable lists to
>> lists.
>>>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> Great!
>>>>>>>>>>>> 
>>>>>>>>>>>>>> On Sun, Feb 9, 2020 at 9:27 PM Stefan Israelsson Tampe
>>>>>>>>>>>>>> <stefan.itampe@gmail.com> wrote:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Note that a lot of things are untested because I'm
>> alone
>>>> on
>>>>>>>> the
>>>>>>>>>>>>>> development.
>>>>>>>>>>>> 
>>>>>>>>>>>> Ok, I understand.
>>>>>>>>>>>> 
>>>>>>>>>>>> I haven't been able to build a recent version, but if you
>>>> can
>>>>>>>>>> share
>>>>>>>>>>>> some
>>>>>>>>>>>> updated instructions, then I could perhaps help out with
>>>> some
>>>>>>>>>>>> occasional
>>>>>>>>>>>> testing. I have only managed to build from the old commit
>>>>>>>> fc0d7a9
>>>>>>>>>> by
>>>>>>>>>>>> 
>>>>>>>>>>>> updating the current python-on-guile guix package
>> locally.
>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> netlib is not included, you can test to add the python
>>>>>> module
>>>>>>>>>>>> file
>>>>>>>>>>>>>> to a (language python module) directory
>>>>>>>>>>>> 
>>>>>>>>>>>> What's been working for me so far is only (load
>>>>>>>>>> "path/to/file.py")
>>>>>>>>>>>> and
>>>>>>>>>>>> (load-compiled "path/to/file.go").
>>>>>>>>>>>> 
>>>>>>>>>>>> (use-modules (a b c)) did not work for me, except to load
>>>>>>>> modules
>>>>>>>>>>>> already shipped with python-on-guile repo; (language
>> python
>>>>>>>>>> module
>>>>>>>>>>>> python) etc.
>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> I have recently added much more of the python stdlib
>> aka
>>>>>> 3.7
>>>>>>>>>> but
>>>>>>>>>>>> not
>>>>>>>>>>>>>> all.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Not sure what you mean by .scm file and .py fle when it
>>>>>> comes
>>>>>>>>>> to
>>>>>>>>>>>>>> base64
>>>>>>>>>>>>>> using that module in scheme gives
>>>>>>>>>>>>>> scheme@(guile-user)> (b64decode (b64encode "abc"))
>>>>>>>>>>>>>> $2 = b'abc'
>>>>>>>>>>>>>> scheme@(guile-user)> (b64decode (b64encode #(1 2 3)))
>>>>>>>>>>>>>> $3 = b'\x01\x02\x03'
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Which return a bytevector if you want a string back you
>>>>>> need
>>>>>>>> to
>>>>>>>>>>>>>> interpret the bytevector back to a string
>>>>>>>>>>>> 
>>>>>>>>>>>> Im getting weird results when trying to output the base64
>>>>>>>>>>>> representation
>>>>>>>>>>>> of a string, take btest.py:
>>>>>>>>>>>> #import sys
>>>>>>>>>>>> import base64
>>>>>>>>>>>> def mybmethod(x):
>>>>>>>>>>>> mybytes = bytes(x, "utf-8")
>>>>>>>>>>>> encodedbytes = base64.b64encode(mybytes)
>>>>>>>>>>>> myb64string = str(encodedbytes, "utf-8")
>>>>>>>>>>>> return myb64string
>>>>>>>>>>>> #print(myb64string)
>>>>>>>>>>>> #mybmethod(sys.argv[1])
>>>>>>>>>>>> 
>>>>>>>>>>>> and assume btest.scm using it with:
>>>>>>>>>>>> (add-to-load-path (dirname (current-filename)))
>>>>>>>>>>>> (use-modules (language python module python))
>>>>>>>>>>>> (load "btest.py")
>>>>>>>>>>>> (define-public (mybmethodscm cmdline)
>>>>>>>>>>>> (display (mybmethod (cadr cmdline))))
>>>>>>>>>>>> 
>>>>>>>>>>>> With this it will not work to run the scheme file with
>>>>>>>>>>>> guile -e mybmethodscm btest.scm dfasdf
>>>>>>>>>>>> 
>>>>>>>>>>>> The error I got indicated that btest.py uses the bytes
>>>>>>>> procedure
>>>>>>>>>>>> from
>>>>>>>>>>>> within python-on-guile instead of from the python3 base64
>>>>>> lib:
>>>>>>>>>>>> 
>>>>>>>>>>>> -------------------
>>>>>>>>>>>> 
>>>>>>>>>>>> In
>>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> /home/user1/VirtualHome/src/code_guile/python-on-guile-test/btest.scm:
>>>>>>>>>>>> 18:11  4 (mybmethodscm _)
>>>>>>>>>>>> In btest.py:
>>>>>>>>>>>> 10:584  3 (_ "dfasdf" . _)
>>>>>>>>>>>> In oop/pf-objects.scm:
>>>>>>>>>>>> 584:15  2 (create-object _ _)
>>>>>>>>>>>> 567:11  1 (the-create-object _ _)
>>>>>>>>>>>> In language/python/bytes.scm:
>>>>>>>>>>>> 99:6  0 Exception thrown while printing backtrace:
>>>>>>>>>>>> Unbound slot in object Error while printing exception.
>>>>>>>>>>>> 
>>>>>>>>>>>> language/python/bytes.scm:99:6: Wrong number of arguments
>>>> to
>>>>>>>>>>>> #<procedure
>>>>>>>>>>>> 7f2bab5d4560 at language/python/bytes.scm:92:0 (self) |
>>>> (self
>>>>>>>> s)>
>>>>>>>>>>>> 
>>>>>>>>>>>> -------------------
>>>>>>>>>>>> 
>>>>>>>>>>>> For a moment though, I could run:
>>>>>>>>>>>> 
>>>>>>>>>>>> guile -e mybmethodscm btest.scm dfasdf | rev | base64 -d
>> |
>>>>>> rev
>>>>>>>>>>>> # gives: dfasdf
>>>>>>>>>>>> 
>>>>>>>>>>>> which was also strange.
>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> modules are a bit difficult as I use the guile module
>>>>>> system
>>>>>>>>>> and
>>>>>>>>>>>> the
>>>>>>>>>>>>>> python modules are different.
>>>>>>>>>>>>>> So nested modules needs some work. The best is to test
>>>> and
>>>>>>>> see.
>>>>>>>>>>>> 
>>>>>>>>>>>> Ok, got it!
>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> I will look into the sys thingies
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>> Stefan
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> On Sun, Feb 9, 2020 at 8:40 PM david larsson
>>>>>>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>>>>>>> Thanks for your explanations, but unfortunately I still
>>>>>> can't
>>>>>>>>>>>> figure
>>>>>>>>>>>>>> out
>>>>>>>>>>>>>> how to use this except in the simplest of cases.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> I am using the guix package python-on-guile
>>>> 0.1.0-3.00a51a2
>>>>>> -
>>>>>>>>>>>> maybe
>>>>>>>>>>>>>> thats outdated?
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> The simple things I have managed to do, are like:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> (add-to-load-path (dirname (current-filename)))
>>>>>>>>>>>>>> (load-compiled python-test.go)
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> where python-test.go is compiled with:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> guild compile python-test.py --output=python-test.go
>>>>>>>>>>>>>> --from=python
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> and contains simple things, like:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> f(s):
>>>>>>>>>>>>>> a = s + 1
>>>>>>>>>>>>>> return a
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> but if I add statements to python-test.py like:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> import netaddr
>>>>>>>>>>>>>> def myfun(a)
>>>>>>>>>>>>>> <something using netaddr>
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> (netaddr is a module installed via: pip3 install --user
>>>>>>>>>> netaddr)
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> I receive an error about not finding the module.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> I am able to add only the modules which exist in the
>>>>>>>>>>>> python-on-guile
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> repo, like:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> import sys
>>>>>>>>>>>>>> import base64
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> but Im getting errors, for example Im not able to use
>>>>>> things
>>>>>>>>>> from
>>>>>>>>>>>>>> sys,
>>>>>>>>>>>>>> like:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> sys.path.append(<somepath>)
>>>>>>>>>>>>>> sys.path.insert(0, <somepath>)
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> I was able to use some things from base64 but I only
>>>>>> received
>>>>>>>>>>>> weird
>>>>>>>>>>>>>> results when converting between bytevectors and strings
>>>>>>>> between
>>>>>>>>>>>> the
>>>>>>>>>>>>>> .scm
>>>>>>>>>>>>>> file and .py file. What works fine using python3
>>>>>>>> python-test.py
>>>>>>>>>>>> do
>>>>>>>>>>>>>> not
>>>>>>>>>>>>>> usually work when passing either a bytevector or string
>>>> to
>>>>>>>> the
>>>>>>>>>>>> same
>>>>>>>>>>>>>> go-compiled file from the .scm file using the
>>>> python-code.
>>>>>>>> Not
>>>>>>>>>>>> sure
>>>>>>>>>>>>>> whether there's a problem using python3 vs python2
>> here?
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Essentially, what Im looking for is how to proceed if I
>>>>>> want
>>>>>>>> to
>>>>>>>>>>>> use
>>>>>>>>>>>>>> modules installed via the pip package manager from
>> guile,
>>>>>> and
>>>>>>>>>>>> what
>>>>>>>>>>>>>> paths
>>>>>>>>>>>>>> and imports I need to make, and how I might need to
>> wrap
>>>>>> them
>>>>>>>>>>>>>> correctly
>>>>>>>>>>>>>> in the scheme and python files to invoke a pip package
>>>>>>>>>> procedure
>>>>>>>>>>>>>> from
>>>>>>>>>>>>>> guile.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Best regards,
>>>>>>>>>>>>>> David
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
>>>>>>>>>>>>>>> I'm the author of that lib.
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 1)
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> The main bindings are reachable through (language
>> python
>>>>>>>>>> module
>>>>>>>>>>>>>>> python)
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> So you could now go ahead and do
>>>>>>>>>>>>>>>> (use-modules (language python module python))
>>>>>>>>>>>>>>>> ;L python
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> And you will get a python shell that works quite ok
>> for
>>>>>> one
>>>>>>>>>>>> liners
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 2)
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> If you write a module and place it in a/b/c.py
>>>>>>>>>>>>>>> you can use the classes and functions theirin by
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> (use-modules (a b c))
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 3)
>>>>>>>>>>>>>>> you can load a .py file as (i hope this work)
>>>>>>>>>>>>>>> (load "a.py")
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 4)
>>>>>>>>>>>>>>> If you place a module in (language python module a.py)
>>>> you
>>>>>>>> can
>>>>>>>>>>>>>> import
>>>>>>>>>>>>>>> ir as a usual mode as
>>>>>>>>>>>>>>>> from a import *
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> The documentation is for the macro framework that
>>>> enables
>>>>>>>> you
>>>>>>>>>> to
>>>>>>>>>>>>>> work
>>>>>>>>>>>>>>> with python classes and idioms like python iteration.
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> Hope this helps
>>>>>>>>>>>>>>> /Stefan
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> On Sun, Feb 9, 2020 at 6:31 PM david larsson
>>>>>>>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Hi everyone,
>>>>>>>>>>>>>>>> I am trying to wrap my head around how to use the
>>>>>>>>>>>> python-on-guile
>>>>>>>>>>>>>>>> library, but Im struggling. Does anyone have example
>>>> code
>>>>>>>>>> that
>>>>>>>>>>>>>> might
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> help, and which isn't too advanced?
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> All tips and suggestions appreciated!
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Best regards,
>>>>>>>>>>>>>>>> David



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
       [not found]                         ` <CAGua6m2SP2RZ1Ok5bG2xmoHGanmRUrfaG34yY7P8=AWs0fXw2g@mail.gmail.com>
@ 2020-02-12 19:47                           ` david larsson
       [not found]                             ` <CAGua6m1rcNZT_15LN=dWRb66E93UyLDFfdkaJjmyWYerWE9Jpg@mail.gmail.com>
  0 siblings, 1 reply; 38+ messages in thread
From: david larsson @ 2020-02-12 19:47 UTC (permalink / raw)
  To: Stefan Israelsson Tampe; +Cc: guile-user

On 2020-02-12 18:18, Stefan Israelsson Tampe wrote:
> you should update the guile-persist repo and also stis-parser, there
> was some cond-expand issues in those as well

Ok. I tried that. stis-parser now built fine on commit 
8d49401e238ae703a466b5b98d3068e4fa974f2c

but guile-persist failed on make for commit: 
659abf1dc64c1aa9d9e4c27fe349100dc908ee6c

---------------------
make  all-recursive
make[1]: Entering directory '/home/user1/VirtualHome/src/guile-persist'
Making all in src/
make[2]: Entering directory 
'/home/user1/VirtualHome/src/guile-persist/src'
make  all-am
make[3]: Entering directory 
'/home/user1/VirtualHome/src/guile-persist/src'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory 
'/home/user1/VirtualHome/src/guile-persist/src'
make[2]: Leaving directory 
'/home/user1/VirtualHome/src/guile-persist/src'
make[2]: Entering directory '/home/user1/VirtualHome/src/guile-persist'
   GEN      persist/slask.go
guile: warning: failed to install locale
warning: failed to install locale: Invalid argument
wrote `persist/slask.go'
   GEN      persist/primitive.go
guile: warning: failed to install locale
warning: failed to install locale: Invalid argument
wrote `persist/primitive.go'
   GEN      persist/persistance.go
guile: warning: failed to install locale
warning: failed to install locale: Invalid argument
Backtrace:
In ice-9/psyntax.scm:
   1235:36 19 (expand-top-sequence ((define-module (persist #) # # ?)) ?)
   1182:24 18 (parse _ (("placeholder" placeholder)) ((top) #(# # ?)) ?)
    285:10 17 (parse _ (("placeholder" placeholder)) (()) _ c&e (# #) #)
In ice-9/eval.scm:
    293:34 16 (_ #<module (#{ g77}#) 55f2082600a0>)
In ice-9/boot-9.scm:
    2874:4 15 (define-module* _ #:filename _ #:pure _ #:version _ # _ ?)
   2071:24 14 (call-with-deferred-observers #<procedure 55f20800c0f0 ?>)
   2887:24 13 (_)
    222:29 12 (map1 (((system vm loader)) ((system vm program)) (#) ?))
    222:29 11 (map1 (((system vm program)) ((system vm debug)) ((?)) ?))
    222:29 10 (map1 (((system vm debug)) ((system vm dwarf)) ((# ?)) ?))
    222:29  9 (map1 (((system vm dwarf)) ((ice-9 match)) ((ice-9 ?)) ?))
    222:29  8 (map1 (((ice-9 match)) ((ice-9 vlist)) ((ice-9 #)) (#) ?))
    222:29  7 (map1 (((ice-9 vlist)) ((ice-9 control)) ((ice-9 #)) # ?))
    222:29  6 (map1 (((ice-9 control)) ((ice-9 pretty-print)) ((?)) ?))
    222:29  5 (map1 (((ice-9 pretty-print)) ((oop goops)) ((oop #)) ?))
    222:29  4 (map1 (((oop goops)) ((oop dict)) ((persist #)) ((?)) ?))
    222:17  3 (map1 (((oop dict)) ((persist primitive)) ((# #)) (#) #))
    2803:6  2 (resolve-interface _ #:select _ #:hide _ #:prefix _ # _ ?)
In unknown file:
            1 (scm-error misc-error #f "~A ~S" ("no code for modu?" ?) ?)
In ice-9/boot-9.scm:
    752:25  0 (dispatch-exception _ _ _)

ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
no code for module (oop dict)
make[2]: *** [Makefile:945: persist/persistance.go] Error 1
make[2]: Leaving directory '/home/user1/VirtualHome/src/guile-persist'
make[1]: *** [Makefile:519: all-recursive] Error 1
make[1]: Leaving directory '/home/user1/VirtualHome/src/guile-persist'
make: *** [Makefile:399: all] Error 2
-------------------------

The error seems very related to the make error for python-on-guile.

Regards,
David

> 
> On Wed, Feb 12, 2020 at 4:26 PM david larsson
> <david.larsson@selfhosted.xyz> wrote:
> 
>> On 2020-02-12 10:59, Stefan Israelsson Tampe wrote:
>>> no code for module (persist persistance)
>>> 
>>> can you use  (persist persistance)  e.g. from the guile shell,
>>> 
>>>> (use-modules  (persist persistance) )
>> 
>> Nope, that gives the same error. I had some issue when compiling the
>> 
>> stis-parser and/or guile-persist as well and solved it by adding a
>> symlink in /usr/local/include/ something. So Ill look into whether I
>> 
>> have some path/environment variable issue on my machine. Im running
>> PureOS which I think tracks Debian stable, so some stuff can be
>> pretty
>> old and maybe thats the reason.
>> 
>> Regards,
>> David
>> 
>>> ...
>>> 
>>> /Stefan
>>> 
>>> On Wed, Feb 12, 2020 at 10:18 AM david larsson
>>> <david.larsson@selfhosted.xyz> wrote:
>>> 
>>>> On 2020-02-11 21:57, Stefan Israelsson Tampe wrote:
>>>>> This error is fixed in repository
>>>>> /Stefan
>>>> 
>>>> Thanks. That solved that part. Now Im getting this error on make:
>>>> 
>>>> (commit 226d33163e7f1e305c0b6e2ada37209513377dff)
>>>> ----------------------
>>>> 
>>>> Makefile:1390: warning: overriding recipe for target 'python'
>>>> Makefile:771: warning: ignoring old recipe for target 'python'
>>>> GEN      oop/pf-objects.go
>>>> guile: warning: failed to install locale
>>>> warning: failed to install locale: Invalid argument
>>>> Backtrace:
>>>> In ice-9/boot-9.scm:
>>>> 2312:4 19 (save-module-excursion #<procedure 55a897256bc0 at
>>>> lang?>)
>>>> In language/scheme/compile-tree-il.scm:
>>>> 31:15 18 (_)
>>>> In ice-9/psyntax.scm:
>>>> 1235:36 17 (expand-top-sequence ((define-module (oop #) # (# ?)
>>>> ?)) ?)
>>>> 1182:24 16 (parse _ (("placeholder" placeholder)) ((top) #(# #
>>>> ?)) ?)
>>>> 285:10 15 (parse _ (("placeholder" placeholder)) (()) _ c&e (#
>>>> #) #)
>>>> In ice-9/eval.scm:
>>>> 293:34 14 (_ #<module (#{ g77}#) 55a8972dd0a0>)
>>>> In ice-9/boot-9.scm:
>>>> 2874:4 13 (define-module* _ #:filename _ #:pure _ #:version _ #
>>>> _ ?)
>>>> 2071:24 12 (call-with-deferred-observers #<procedure 55a897086910
>>>> ?>)
>>>> 2887:24 11 (_)
>>>> 222:29 10 (map1 (((oop goops)) ((oop dict) #:renamer #<proce?>)
>>>> ?))
>>>> 222:29  9 (map1 (((oop dict) #:renamer #<procedure 55a8972fb?>)
>>>> ?))
>>>> 222:29  8 (map1 (((ice-9 vlist)) ((ice-9 match)) ((system # #))
>>>> ?))
>>>> 222:29  7 (map1 (((ice-9 match)) ((system base message)) ((# ?))
>>>> ?))
>>>> 222:29  6 (map1 (((system base message)) ((language python #)) #
>>>> ?))
>>>> 222:29  5 (map1 (((language python guilemod)) ((ice-9 #)) ((#
>>>> ?))))
>>>> 222:29  4 (map1 (((ice-9 pretty-print)) ((persist
>>>> persistance))))
>>>> 222:17  3 (map1 (((persist persistance))))
>>>> 2803:6  2 (resolve-interface _ #:select _ #:hide _ #:prefix _ #
>>>> _ ?)
>>>> In unknown file:
>>>> 1 (scm-error misc-error #f "~A ~S" ("no code for modu?"
>>>> ?) ?)
>>>> In ice-9/boot-9.scm:
>>>> 752:25  0 (dispatch-exception _ _ _)
>>>> 
>>>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>>>> no code for module (persist persistance)
>>>> make: *** [Makefile:1385: oop/pf-objects.go] Error 1
>>>> 
>>>> ----------------------
>>>> 
>>>> Regards,
>>>> David
>>>> 
>>>>> 
>>>>> On Tue, Feb 11, 2020 at 8:17 AM david larsson
>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>> 
>>>>>> On 2020-02-10 21:11, Stefan Israelsson Tampe wrote:
>>>>>>> I have now added the bytes constructor that was not working.
>>>>>> 
>>>>>> Thanks!
>>>>>> 
>>>>>>> 
>>>>>>> To compile from source please try use the git repository at:
>>>>>>> 
>>>>>>> https://gitlab.com/python-on-guile/python-on-guile/
>>>>>>> 
>>>>>>> see readme for how to compile and what dependencies you have.
>>>>>> 
>>>>>> I was able to build and install:
>>>>>> - guile-persist: commit
>> ebebb66ae6d6c47dbc406cdbcaccb5ffed2e463a
>>>>>> - stis-parser: commit 7673dd576abb445fbcfce8c4b6ae961ee860902e
>>>>>> 
>>>>>> but for python-on-guile Im getting this error on make:
>>>>>> 
>>>>>> --------------
>>>>>> 
>>>>>> Makefile:1390: warning: overriding recipe for target 'python'
>>>>>> Makefile:771: warning: ignoring old recipe for target 'python'
>>>>>> GEN      language/python/guilemod.go
>>>>>> guile: warning: failed to install locale
>>>>>> warning: failed to install locale: Invalid argument
>>>>>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>>>>>> Syntax error:
>>>>>> language/python/guilemod.scm:271:0: cond-expand: unfulfilled
>>>>>> cond-expand
>>>>>> in form (cond-expand (guile-3.0 (define-set-M
>> lookup-warning-type
>>>>>> lookup-warning-type) (define-set-M warning warning) (set!
>>>>>> %warning-types
>>>>>> w-types)) (guile-2.0 or guile-2.2 (define-M %warning-types
>>>> w-types)
>>>>>> (define-exp-M lookup-warning-type (lambda (name) "Return the
>>>> warning
>>>>>> 
>>>>>> type NAME or `#f' if not found." ((M find) (lambda (wt) (eq?
>> name
>>>>>> ((M
>>>>>> warning-type-name) wt))) (M %warning-types))))))
>>>>>> make: *** [Makefile:1385: language/python/guilemod.go] Error 1
>>>>>> 
>>>>>> ---------------
>>>>>> 
>>>>>> Im compiling with guile2.2
>>>>>> 
>>>>>> Regards,
>>>>>> David
>>>>>> 
>>>>>>> 
>>>>>>> Regards
>>>>>>> Stefan
>>>>>>> 
>>>>>>> On Mon, Feb 10, 2020 at 1:14 PM david larsson
>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>> 
>>>>>>>> On 2020-02-09 21:36, Stefan Israelsson Tampe wrote:
>>>>>>>>> in sys that is
>>>>>>>>> 
>>>>>>>>> On Sun, Feb 9, 2020 at 9:36 PM Stefan Israelsson Tampe
>>>>>>>>> <stefan.itampe@gmail.com> wrote:
>>>>>>>>> 
>>>>>>>>>> OKey, I changed the values from immutable lists to lists.
>>>>>>>>>> 
>>>>>>>> 
>>>>>>>> Great!
>>>>>>>> 
>>>>>>>>>> On Sun, Feb 9, 2020 at 9:27 PM Stefan Israelsson Tampe
>>>>>>>>>> <stefan.itampe@gmail.com> wrote:
>>>>>>>>>> 
>>>>>>>>>> Note that a lot of things are untested because I'm alone on
>>>> the
>>>>>>>>>> development.
>>>>>>>> 
>>>>>>>> Ok, I understand.
>>>>>>>> 
>>>>>>>> I haven't been able to build a recent version, but if you can
>>>>>> share
>>>>>>>> some
>>>>>>>> updated instructions, then I could perhaps help out with some
>>>>>>>> occasional
>>>>>>>> testing. I have only managed to build from the old commit
>>>> fc0d7a9
>>>>>> by
>>>>>>>> 
>>>>>>>> updating the current python-on-guile guix package locally.
>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> netlib is not included, you can test to add the python
>> module
>>>>>>>> file
>>>>>>>>>> to a (language python module) directory
>>>>>>>> 
>>>>>>>> What's been working for me so far is only (load
>>>>>> "path/to/file.py")
>>>>>>>> and
>>>>>>>> (load-compiled "path/to/file.go").
>>>>>>>> 
>>>>>>>> (use-modules (a b c)) did not work for me, except to load
>>>> modules
>>>>>>>> already shipped with python-on-guile repo; (language python
>>>>>> module
>>>>>>>> python) etc.
>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> I have recently added much more of the python stdlib aka
>> 3.7
>>>>>> but
>>>>>>>> not
>>>>>>>>>> all.
>>>>>>>>>> 
>>>>>>>>>> Not sure what you mean by .scm file and .py fle when it
>> comes
>>>>>> to
>>>>>>>>>> base64
>>>>>>>>>> using that module in scheme gives
>>>>>>>>>> scheme@(guile-user)> (b64decode (b64encode "abc"))
>>>>>>>>>> $2 = b'abc'
>>>>>>>>>> scheme@(guile-user)> (b64decode (b64encode #(1 2 3)))
>>>>>>>>>> $3 = b'\x01\x02\x03'
>>>>>>>>>> 
>>>>>>>>>> Which return a bytevector if you want a string back you
>> need
>>>> to
>>>>>>>>>> interpret the bytevector back to a string
>>>>>>>> 
>>>>>>>> Im getting weird results when trying to output the base64
>>>>>>>> representation
>>>>>>>> of a string, take btest.py:
>>>>>>>> #import sys
>>>>>>>> import base64
>>>>>>>> def mybmethod(x):
>>>>>>>> mybytes = bytes(x, "utf-8")
>>>>>>>> encodedbytes = base64.b64encode(mybytes)
>>>>>>>> myb64string = str(encodedbytes, "utf-8")
>>>>>>>> return myb64string
>>>>>>>> #print(myb64string)
>>>>>>>> #mybmethod(sys.argv[1])
>>>>>>>> 
>>>>>>>> and assume btest.scm using it with:
>>>>>>>> (add-to-load-path (dirname (current-filename)))
>>>>>>>> (use-modules (language python module python))
>>>>>>>> (load "btest.py")
>>>>>>>> (define-public (mybmethodscm cmdline)
>>>>>>>> (display (mybmethod (cadr cmdline))))
>>>>>>>> 
>>>>>>>> With this it will not work to run the scheme file with
>>>>>>>> guile -e mybmethodscm btest.scm dfasdf
>>>>>>>> 
>>>>>>>> The error I got indicated that btest.py uses the bytes
>>>> procedure
>>>>>>>> from
>>>>>>>> within python-on-guile instead of from the python3 base64
>> lib:
>>>>>>>> 
>>>>>>>> -------------------
>>>>>>>> 
>>>>>>>> In
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> /home/user1/VirtualHome/src/code_guile/python-on-guile-test/btest.scm:
>>>>>>>> 18:11  4 (mybmethodscm _)
>>>>>>>> In btest.py:
>>>>>>>> 10:584  3 (_ "dfasdf" . _)
>>>>>>>> In oop/pf-objects.scm:
>>>>>>>> 584:15  2 (create-object _ _)
>>>>>>>> 567:11  1 (the-create-object _ _)
>>>>>>>> In language/python/bytes.scm:
>>>>>>>> 99:6  0 Exception thrown while printing backtrace:
>>>>>>>> Unbound slot in object Error while printing exception.
>>>>>>>> 
>>>>>>>> language/python/bytes.scm:99:6: Wrong number of arguments to
>>>>>>>> #<procedure
>>>>>>>> 7f2bab5d4560 at language/python/bytes.scm:92:0 (self) | (self
>>>> s)>
>>>>>>>> 
>>>>>>>> -------------------
>>>>>>>> 
>>>>>>>> For a moment though, I could run:
>>>>>>>> 
>>>>>>>> guile -e mybmethodscm btest.scm dfasdf | rev | base64 -d |
>> rev
>>>>>>>> # gives: dfasdf
>>>>>>>> 
>>>>>>>> which was also strange.
>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> modules are a bit difficult as I use the guile module
>> system
>>>>>> and
>>>>>>>> the
>>>>>>>>>> python modules are different.
>>>>>>>>>> So nested modules needs some work. The best is to test and
>>>> see.
>>>>>>>> 
>>>>>>>> Ok, got it!
>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> I will look into the sys thingies
>>>>>>>>>> 
>>>>>>>>>> Regards
>>>>>>>>>> Stefan
>>>>>>>>>> 
>>>>>>>>>> On Sun, Feb 9, 2020 at 8:40 PM david larsson
>>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>>> Thanks for your explanations, but unfortunately I still
>> can't
>>>>>>>> figure
>>>>>>>>>> out
>>>>>>>>>> how to use this except in the simplest of cases.
>>>>>>>>>> 
>>>>>>>>>> I am using the guix package python-on-guile 0.1.0-3.00a51a2
>> -
>>>>>>>> maybe
>>>>>>>>>> thats outdated?
>>>>>>>>>> 
>>>>>>>>>> The simple things I have managed to do, are like:
>>>>>>>>>> 
>>>>>>>>>> (add-to-load-path (dirname (current-filename)))
>>>>>>>>>> (load-compiled python-test.go)
>>>>>>>>>> 
>>>>>>>>>> where python-test.go is compiled with:
>>>>>>>>>> 
>>>>>>>>>> guild compile python-test.py --output=python-test.go
>>>>>>>>>> --from=python
>>>>>>>>>> 
>>>>>>>>>> and contains simple things, like:
>>>>>>>>>> 
>>>>>>>>>> f(s):
>>>>>>>>>> a = s + 1
>>>>>>>>>> return a
>>>>>>>>>> 
>>>>>>>>>> but if I add statements to python-test.py like:
>>>>>>>>>> 
>>>>>>>>>> import netaddr
>>>>>>>>>> def myfun(a)
>>>>>>>>>> <something using netaddr>
>>>>>>>>>> 
>>>>>>>>>> (netaddr is a module installed via: pip3 install --user
>>>>>> netaddr)
>>>>>>>>>> 
>>>>>>>>>> I receive an error about not finding the module.
>>>>>>>>>> 
>>>>>>>>>> I am able to add only the modules which exist in the
>>>>>>>> python-on-guile
>>>>>>>>>> 
>>>>>>>>>> repo, like:
>>>>>>>>>> 
>>>>>>>>>> import sys
>>>>>>>>>> import base64
>>>>>>>>>> 
>>>>>>>>>> but Im getting errors, for example Im not able to use
>> things
>>>>>> from
>>>>>>>>>> sys,
>>>>>>>>>> like:
>>>>>>>>>> 
>>>>>>>>>> sys.path.append(<somepath>)
>>>>>>>>>> sys.path.insert(0, <somepath>)
>>>>>>>>>> 
>>>>>>>>>> I was able to use some things from base64 but I only
>> received
>>>>>>>> weird
>>>>>>>>>> results when converting between bytevectors and strings
>>>> between
>>>>>>>> the
>>>>>>>>>> .scm
>>>>>>>>>> file and .py file. What works fine using python3
>>>> python-test.py
>>>>>>>> do
>>>>>>>>>> not
>>>>>>>>>> usually work when passing either a bytevector or string to
>>>> the
>>>>>>>> same
>>>>>>>>>> go-compiled file from the .scm file using the python-code.
>>>> Not
>>>>>>>> sure
>>>>>>>>>> whether there's a problem using python3 vs python2 here?
>>>>>>>>>> 
>>>>>>>>>> Essentially, what Im looking for is how to proceed if I
>> want
>>>> to
>>>>>>>> use
>>>>>>>>>> modules installed via the pip package manager from guile,
>> and
>>>>>>>> what
>>>>>>>>>> paths
>>>>>>>>>> and imports I need to make, and how I might need to wrap
>> them
>>>>>>>>>> correctly
>>>>>>>>>> in the scheme and python files to invoke a pip package
>>>>>> procedure
>>>>>>>>>> from
>>>>>>>>>> guile.
>>>>>>>>>> 
>>>>>>>>>> Best regards,
>>>>>>>>>> David
>>>>>>>>>> 
>>>>>>>>>> On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
>>>>>>>>>>> I'm the author of that lib.
>>>>>>>>>>> 
>>>>>>>>>>> 1)
>>>>>>>>>>> 
>>>>>>>>>>> The main bindings are reachable through (language python
>>>>>> module
>>>>>>>>>>> python)
>>>>>>>>>>> 
>>>>>>>>>>> So you could now go ahead and do
>>>>>>>>>>>> (use-modules (language python module python))
>>>>>>>>>>>> ;L python
>>>>>>>>>>> 
>>>>>>>>>>> And you will get a python shell that works quite ok for
>> one
>>>>>>>> liners
>>>>>>>>>>> 
>>>>>>>>>>> 2)
>>>>>>>>>>> 
>>>>>>>>>>> If you write a module and place it in a/b/c.py
>>>>>>>>>>> you can use the classes and functions theirin by
>>>>>>>>>>> 
>>>>>>>>>>> (use-modules (a b c))
>>>>>>>>>>> 
>>>>>>>>>>> 3)
>>>>>>>>>>> you can load a .py file as (i hope this work)
>>>>>>>>>>> (load "a.py")
>>>>>>>>>>> 
>>>>>>>>>>> 4)
>>>>>>>>>>> If you place a module in (language python module a.py) you
>>>> can
>>>>>>>>>> import
>>>>>>>>>>> ir as a usual mode as
>>>>>>>>>>>> from a import *
>>>>>>>>>>> 
>>>>>>>>>>> The documentation is for the macro framework that enables
>>>> you
>>>>>> to
>>>>>>>>>> work
>>>>>>>>>>> with python classes and idioms like python iteration.
>>>>>>>>>>> 
>>>>>>>>>>> Hope this helps
>>>>>>>>>>> /Stefan
>>>>>>>>>>> 
>>>>>>>>>>> On Sun, Feb 9, 2020 at 6:31 PM david larsson
>>>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>>>> 
>>>>>>>>>>>> Hi everyone,
>>>>>>>>>>>> I am trying to wrap my head around how to use the
>>>>>>>> python-on-guile
>>>>>>>>>>>> library, but Im struggling. Does anyone have example code
>>>>>> that
>>>>>>>>>> might
>>>>>>>>>>>> 
>>>>>>>>>>>> help, and which isn't too advanced?
>>>>>>>>>>>> 
>>>>>>>>>>>> All tips and suggestions appreciated!
>>>>>>>>>>>> 
>>>>>>>>>>>> Best regards,
>>>>>>>>>>>> David



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
  2020-02-12  9:59                     ` python-on-guile Stefan Israelsson Tampe
@ 2020-02-12 15:26                       ` david larsson
       [not found]                         ` <CAGua6m2SP2RZ1Ok5bG2xmoHGanmRUrfaG34yY7P8=AWs0fXw2g@mail.gmail.com>
  0 siblings, 1 reply; 38+ messages in thread
From: david larsson @ 2020-02-12 15:26 UTC (permalink / raw)
  To: Stefan Israelsson Tampe
  Cc: Stefan Israelsson Tampe <stefan.itampe@gmail.com>

On 2020-02-12 10:59, Stefan Israelsson Tampe wrote:
> no code for module (persist persistance)
> 
> can you use  (persist persistance)  e.g. from the guile shell,
> 
>> (use-modules  (persist persistance) )

Nope, that gives the same error. I had some issue when compiling the 
stis-parser and/or guile-persist as well and solved it by adding a 
symlink in /usr/local/include/ something. So Ill look into whether I 
have some path/environment variable issue on my machine. Im running 
PureOS which I think tracks Debian stable, so some stuff can be pretty 
old and maybe thats the reason.

Regards,
David

> ...
> 
> /Stefan
> 
> On Wed, Feb 12, 2020 at 10:18 AM david larsson
> <david.larsson@selfhosted.xyz> wrote:
> 
>> On 2020-02-11 21:57, Stefan Israelsson Tampe wrote:
>>> This error is fixed in repository
>>> /Stefan
>> 
>> Thanks. That solved that part. Now Im getting this error on make:
>> 
>> (commit 226d33163e7f1e305c0b6e2ada37209513377dff)
>> ----------------------
>> 
>> Makefile:1390: warning: overriding recipe for target 'python'
>> Makefile:771: warning: ignoring old recipe for target 'python'
>> GEN      oop/pf-objects.go
>> guile: warning: failed to install locale
>> warning: failed to install locale: Invalid argument
>> Backtrace:
>> In ice-9/boot-9.scm:
>> 2312:4 19 (save-module-excursion #<procedure 55a897256bc0 at
>> lang?>)
>> In language/scheme/compile-tree-il.scm:
>> 31:15 18 (_)
>> In ice-9/psyntax.scm:
>> 1235:36 17 (expand-top-sequence ((define-module (oop #) # (# ?)
>> ?)) ?)
>> 1182:24 16 (parse _ (("placeholder" placeholder)) ((top) #(# #
>> ?)) ?)
>> 285:10 15 (parse _ (("placeholder" placeholder)) (()) _ c&e (#
>> #) #)
>> In ice-9/eval.scm:
>> 293:34 14 (_ #<module (#{ g77}#) 55a8972dd0a0>)
>> In ice-9/boot-9.scm:
>> 2874:4 13 (define-module* _ #:filename _ #:pure _ #:version _ #
>> _ ?)
>> 2071:24 12 (call-with-deferred-observers #<procedure 55a897086910
>> ?>)
>> 2887:24 11 (_)
>> 222:29 10 (map1 (((oop goops)) ((oop dict) #:renamer #<proce?>)
>> ?))
>> 222:29  9 (map1 (((oop dict) #:renamer #<procedure 55a8972fb?>)
>> ?))
>> 222:29  8 (map1 (((ice-9 vlist)) ((ice-9 match)) ((system # #))
>> ?))
>> 222:29  7 (map1 (((ice-9 match)) ((system base message)) ((# ?))
>> ?))
>> 222:29  6 (map1 (((system base message)) ((language python #)) #
>> ?))
>> 222:29  5 (map1 (((language python guilemod)) ((ice-9 #)) ((#
>> ?))))
>> 222:29  4 (map1 (((ice-9 pretty-print)) ((persist
>> persistance))))
>> 222:17  3 (map1 (((persist persistance))))
>> 2803:6  2 (resolve-interface _ #:select _ #:hide _ #:prefix _ #
>> _ ?)
>> In unknown file:
>> 1 (scm-error misc-error #f "~A ~S" ("no code for modu?"
>> ?) ?)
>> In ice-9/boot-9.scm:
>> 752:25  0 (dispatch-exception _ _ _)
>> 
>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>> no code for module (persist persistance)
>> make: *** [Makefile:1385: oop/pf-objects.go] Error 1
>> 
>> ----------------------
>> 
>> Regards,
>> David
>> 
>>> 
>>> On Tue, Feb 11, 2020 at 8:17 AM david larsson
>>> <david.larsson@selfhosted.xyz> wrote:
>>> 
>>>> On 2020-02-10 21:11, Stefan Israelsson Tampe wrote:
>>>>> I have now added the bytes constructor that was not working.
>>>> 
>>>> Thanks!
>>>> 
>>>>> 
>>>>> To compile from source please try use the git repository at:
>>>>> 
>>>>> https://gitlab.com/python-on-guile/python-on-guile/
>>>>> 
>>>>> see readme for how to compile and what dependencies you have.
>>>> 
>>>> I was able to build and install:
>>>> - guile-persist: commit ebebb66ae6d6c47dbc406cdbcaccb5ffed2e463a
>>>> - stis-parser: commit 7673dd576abb445fbcfce8c4b6ae961ee860902e
>>>> 
>>>> but for python-on-guile Im getting this error on make:
>>>> 
>>>> --------------
>>>> 
>>>> Makefile:1390: warning: overriding recipe for target 'python'
>>>> Makefile:771: warning: ignoring old recipe for target 'python'
>>>> GEN      language/python/guilemod.go
>>>> guile: warning: failed to install locale
>>>> warning: failed to install locale: Invalid argument
>>>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>>>> Syntax error:
>>>> language/python/guilemod.scm:271:0: cond-expand: unfulfilled
>>>> cond-expand
>>>> in form (cond-expand (guile-3.0 (define-set-M lookup-warning-type
>>>> lookup-warning-type) (define-set-M warning warning) (set!
>>>> %warning-types
>>>> w-types)) (guile-2.0 or guile-2.2 (define-M %warning-types
>> w-types)
>>>> (define-exp-M lookup-warning-type (lambda (name) "Return the
>> warning
>>>> 
>>>> type NAME or `#f' if not found." ((M find) (lambda (wt) (eq? name
>>>> ((M
>>>> warning-type-name) wt))) (M %warning-types))))))
>>>> make: *** [Makefile:1385: language/python/guilemod.go] Error 1
>>>> 
>>>> ---------------
>>>> 
>>>> Im compiling with guile2.2
>>>> 
>>>> Regards,
>>>> David
>>>> 
>>>>> 
>>>>> Regards
>>>>> Stefan
>>>>> 
>>>>> On Mon, Feb 10, 2020 at 1:14 PM david larsson
>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>> 
>>>>>> On 2020-02-09 21:36, Stefan Israelsson Tampe wrote:
>>>>>>> in sys that is
>>>>>>> 
>>>>>>> On Sun, Feb 9, 2020 at 9:36 PM Stefan Israelsson Tampe
>>>>>>> <stefan.itampe@gmail.com> wrote:
>>>>>>> 
>>>>>>>> OKey, I changed the values from immutable lists to lists.
>>>>>>>> 
>>>>>> 
>>>>>> Great!
>>>>>> 
>>>>>>>> On Sun, Feb 9, 2020 at 9:27 PM Stefan Israelsson Tampe
>>>>>>>> <stefan.itampe@gmail.com> wrote:
>>>>>>>> 
>>>>>>>> Note that a lot of things are untested because I'm alone on
>> the
>>>>>>>> development.
>>>>>> 
>>>>>> Ok, I understand.
>>>>>> 
>>>>>> I haven't been able to build a recent version, but if you can
>>>> share
>>>>>> some
>>>>>> updated instructions, then I could perhaps help out with some
>>>>>> occasional
>>>>>> testing. I have only managed to build from the old commit
>> fc0d7a9
>>>> by
>>>>>> 
>>>>>> updating the current python-on-guile guix package locally.
>>>>>> 
>>>>>>>> 
>>>>>>>> netlib is not included, you can test to add the python module
>>>>>> file
>>>>>>>> to a (language python module) directory
>>>>>> 
>>>>>> What's been working for me so far is only (load
>>>> "path/to/file.py")
>>>>>> and
>>>>>> (load-compiled "path/to/file.go").
>>>>>> 
>>>>>> (use-modules (a b c)) did not work for me, except to load
>> modules
>>>>>> already shipped with python-on-guile repo; (language python
>>>> module
>>>>>> python) etc.
>>>>>> 
>>>>>>>> 
>>>>>>>> I have recently added much more of the python stdlib aka 3.7
>>>> but
>>>>>> not
>>>>>>>> all.
>>>>>>>> 
>>>>>>>> Not sure what you mean by .scm file and .py fle when it comes
>>>> to
>>>>>>>> base64
>>>>>>>> using that module in scheme gives
>>>>>>>> scheme@(guile-user)> (b64decode (b64encode "abc"))
>>>>>>>> $2 = b'abc'
>>>>>>>> scheme@(guile-user)> (b64decode (b64encode #(1 2 3)))
>>>>>>>> $3 = b'\x01\x02\x03'
>>>>>>>> 
>>>>>>>> Which return a bytevector if you want a string back you need
>> to
>>>>>>>> interpret the bytevector back to a string
>>>>>> 
>>>>>> Im getting weird results when trying to output the base64
>>>>>> representation
>>>>>> of a string, take btest.py:
>>>>>> #import sys
>>>>>> import base64
>>>>>> def mybmethod(x):
>>>>>> mybytes = bytes(x, "utf-8")
>>>>>> encodedbytes = base64.b64encode(mybytes)
>>>>>> myb64string = str(encodedbytes, "utf-8")
>>>>>> return myb64string
>>>>>> #print(myb64string)
>>>>>> #mybmethod(sys.argv[1])
>>>>>> 
>>>>>> and assume btest.scm using it with:
>>>>>> (add-to-load-path (dirname (current-filename)))
>>>>>> (use-modules (language python module python))
>>>>>> (load "btest.py")
>>>>>> (define-public (mybmethodscm cmdline)
>>>>>> (display (mybmethod (cadr cmdline))))
>>>>>> 
>>>>>> With this it will not work to run the scheme file with
>>>>>> guile -e mybmethodscm btest.scm dfasdf
>>>>>> 
>>>>>> The error I got indicated that btest.py uses the bytes
>> procedure
>>>>>> from
>>>>>> within python-on-guile instead of from the python3 base64 lib:
>>>>>> 
>>>>>> -------------------
>>>>>> 
>>>>>> In
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> /home/user1/VirtualHome/src/code_guile/python-on-guile-test/btest.scm:
>>>>>> 18:11  4 (mybmethodscm _)
>>>>>> In btest.py:
>>>>>> 10:584  3 (_ "dfasdf" . _)
>>>>>> In oop/pf-objects.scm:
>>>>>> 584:15  2 (create-object _ _)
>>>>>> 567:11  1 (the-create-object _ _)
>>>>>> In language/python/bytes.scm:
>>>>>> 99:6  0 Exception thrown while printing backtrace:
>>>>>> Unbound slot in object Error while printing exception.
>>>>>> 
>>>>>> language/python/bytes.scm:99:6: Wrong number of arguments to
>>>>>> #<procedure
>>>>>> 7f2bab5d4560 at language/python/bytes.scm:92:0 (self) | (self
>> s)>
>>>>>> 
>>>>>> -------------------
>>>>>> 
>>>>>> For a moment though, I could run:
>>>>>> 
>>>>>> guile -e mybmethodscm btest.scm dfasdf | rev | base64 -d | rev
>>>>>> # gives: dfasdf
>>>>>> 
>>>>>> which was also strange.
>>>>>> 
>>>>>>>> 
>>>>>>>> modules are a bit difficult as I use the guile module system
>>>> and
>>>>>> the
>>>>>>>> python modules are different.
>>>>>>>> So nested modules needs some work. The best is to test and
>> see.
>>>>>> 
>>>>>> Ok, got it!
>>>>>> 
>>>>>>>> 
>>>>>>>> I will look into the sys thingies
>>>>>>>> 
>>>>>>>> Regards
>>>>>>>> Stefan
>>>>>>>> 
>>>>>>>> On Sun, Feb 9, 2020 at 8:40 PM david larsson
>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>> Thanks for your explanations, but unfortunately I still can't
>>>>>> figure
>>>>>>>> out
>>>>>>>> how to use this except in the simplest of cases.
>>>>>>>> 
>>>>>>>> I am using the guix package python-on-guile 0.1.0-3.00a51a2 -
>>>>>> maybe
>>>>>>>> thats outdated?
>>>>>>>> 
>>>>>>>> The simple things I have managed to do, are like:
>>>>>>>> 
>>>>>>>> (add-to-load-path (dirname (current-filename)))
>>>>>>>> (load-compiled python-test.go)
>>>>>>>> 
>>>>>>>> where python-test.go is compiled with:
>>>>>>>> 
>>>>>>>> guild compile python-test.py --output=python-test.go
>>>>>>>> --from=python
>>>>>>>> 
>>>>>>>> and contains simple things, like:
>>>>>>>> 
>>>>>>>> f(s):
>>>>>>>> a = s + 1
>>>>>>>> return a
>>>>>>>> 
>>>>>>>> but if I add statements to python-test.py like:
>>>>>>>> 
>>>>>>>> import netaddr
>>>>>>>> def myfun(a)
>>>>>>>> <something using netaddr>
>>>>>>>> 
>>>>>>>> (netaddr is a module installed via: pip3 install --user
>>>> netaddr)
>>>>>>>> 
>>>>>>>> I receive an error about not finding the module.
>>>>>>>> 
>>>>>>>> I am able to add only the modules which exist in the
>>>>>> python-on-guile
>>>>>>>> 
>>>>>>>> repo, like:
>>>>>>>> 
>>>>>>>> import sys
>>>>>>>> import base64
>>>>>>>> 
>>>>>>>> but Im getting errors, for example Im not able to use things
>>>> from
>>>>>>>> sys,
>>>>>>>> like:
>>>>>>>> 
>>>>>>>> sys.path.append(<somepath>)
>>>>>>>> sys.path.insert(0, <somepath>)
>>>>>>>> 
>>>>>>>> I was able to use some things from base64 but I only received
>>>>>> weird
>>>>>>>> results when converting between bytevectors and strings
>> between
>>>>>> the
>>>>>>>> .scm
>>>>>>>> file and .py file. What works fine using python3
>> python-test.py
>>>>>> do
>>>>>>>> not
>>>>>>>> usually work when passing either a bytevector or string to
>> the
>>>>>> same
>>>>>>>> go-compiled file from the .scm file using the python-code.
>> Not
>>>>>> sure
>>>>>>>> whether there's a problem using python3 vs python2 here?
>>>>>>>> 
>>>>>>>> Essentially, what Im looking for is how to proceed if I want
>> to
>>>>>> use
>>>>>>>> modules installed via the pip package manager from guile, and
>>>>>> what
>>>>>>>> paths
>>>>>>>> and imports I need to make, and how I might need to wrap them
>>>>>>>> correctly
>>>>>>>> in the scheme and python files to invoke a pip package
>>>> procedure
>>>>>>>> from
>>>>>>>> guile.
>>>>>>>> 
>>>>>>>> Best regards,
>>>>>>>> David
>>>>>>>> 
>>>>>>>> On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
>>>>>>>>> I'm the author of that lib.
>>>>>>>>> 
>>>>>>>>> 1)
>>>>>>>>> 
>>>>>>>>> The main bindings are reachable through (language python
>>>> module
>>>>>>>>> python)
>>>>>>>>> 
>>>>>>>>> So you could now go ahead and do
>>>>>>>>>> (use-modules (language python module python))
>>>>>>>>>> ;L python
>>>>>>>>> 
>>>>>>>>> And you will get a python shell that works quite ok for one
>>>>>> liners
>>>>>>>>> 
>>>>>>>>> 2)
>>>>>>>>> 
>>>>>>>>> If you write a module and place it in a/b/c.py
>>>>>>>>> you can use the classes and functions theirin by
>>>>>>>>> 
>>>>>>>>> (use-modules (a b c))
>>>>>>>>> 
>>>>>>>>> 3)
>>>>>>>>> you can load a .py file as (i hope this work)
>>>>>>>>> (load "a.py")
>>>>>>>>> 
>>>>>>>>> 4)
>>>>>>>>> If you place a module in (language python module a.py) you
>> can
>>>>>>>> import
>>>>>>>>> ir as a usual mode as
>>>>>>>>>> from a import *
>>>>>>>>> 
>>>>>>>>> The documentation is for the macro framework that enables
>> you
>>>> to
>>>>>>>> work
>>>>>>>>> with python classes and idioms like python iteration.
>>>>>>>>> 
>>>>>>>>> Hope this helps
>>>>>>>>> /Stefan
>>>>>>>>> 
>>>>>>>>> On Sun, Feb 9, 2020 at 6:31 PM david larsson
>>>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>>>> 
>>>>>>>>>> Hi everyone,
>>>>>>>>>> I am trying to wrap my head around how to use the
>>>>>> python-on-guile
>>>>>>>>>> library, but Im struggling. Does anyone have example code
>>>> that
>>>>>>>> might
>>>>>>>>>> 
>>>>>>>>>> help, and which isn't too advanced?
>>>>>>>>>> 
>>>>>>>>>> All tips and suggestions appreciated!
>>>>>>>>>> 
>>>>>>>>>> Best regards,
>>>>>>>>>> David



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
  2020-02-12  9:18                   ` python-on-guile david larsson
@ 2020-02-12  9:59                     ` Stefan Israelsson Tampe
  2020-02-12 15:26                       ` python-on-guile david larsson
  0 siblings, 1 reply; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2020-02-12  9:59 UTC (permalink / raw)
  To: david larsson; +Cc: Stefan Israelsson Tampe <stefan.itampe@gmail.com>

no code for module (persist persistance)

can you use  (persist persistance)  e.g. from the guile shell,

> (use-modules  (persist persistance) )
...

/Stefan


On Wed, Feb 12, 2020 at 10:18 AM david larsson <david.larsson@selfhosted.xyz>
wrote:

> On 2020-02-11 21:57, Stefan Israelsson Tampe wrote:
> > This error is fixed in repository
> > /Stefan
>
> Thanks. That solved that part. Now Im getting this error on make:
>
> (commit 226d33163e7f1e305c0b6e2ada37209513377dff)
> ----------------------
>
> Makefile:1390: warning: overriding recipe for target 'python'
> Makefile:771: warning: ignoring old recipe for target 'python'
>    GEN      oop/pf-objects.go
> guile: warning: failed to install locale
> warning: failed to install locale: Invalid argument
> Backtrace:
> In ice-9/boot-9.scm:
>     2312:4 19 (save-module-excursion #<procedure 55a897256bc0 at lang?>)
> In language/scheme/compile-tree-il.scm:
>      31:15 18 (_)
> In ice-9/psyntax.scm:
>    1235:36 17 (expand-top-sequence ((define-module (oop #) # (# ?) ?)) ?)
>    1182:24 16 (parse _ (("placeholder" placeholder)) ((top) #(# # ?)) ?)
>     285:10 15 (parse _ (("placeholder" placeholder)) (()) _ c&e (# #) #)
> In ice-9/eval.scm:
>     293:34 14 (_ #<module (#{ g77}#) 55a8972dd0a0>)
> In ice-9/boot-9.scm:
>     2874:4 13 (define-module* _ #:filename _ #:pure _ #:version _ # _ ?)
>    2071:24 12 (call-with-deferred-observers #<procedure 55a897086910 ?>)
>    2887:24 11 (_)
>     222:29 10 (map1 (((oop goops)) ((oop dict) #:renamer #<proce?>) ?))
>     222:29  9 (map1 (((oop dict) #:renamer #<procedure 55a8972fb?>) ?))
>     222:29  8 (map1 (((ice-9 vlist)) ((ice-9 match)) ((system # #)) ?))
>     222:29  7 (map1 (((ice-9 match)) ((system base message)) ((# ?)) ?))
>     222:29  6 (map1 (((system base message)) ((language python #)) # ?))
>     222:29  5 (map1 (((language python guilemod)) ((ice-9 #)) ((# ?))))
>     222:29  4 (map1 (((ice-9 pretty-print)) ((persist persistance))))
>     222:17  3 (map1 (((persist persistance))))
>     2803:6  2 (resolve-interface _ #:select _ #:hide _ #:prefix _ # _ ?)
> In unknown file:
>             1 (scm-error misc-error #f "~A ~S" ("no code for modu?" ?) ?)
> In ice-9/boot-9.scm:
>     752:25  0 (dispatch-exception _ _ _)
>
> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
> no code for module (persist persistance)
> make: *** [Makefile:1385: oop/pf-objects.go] Error 1
>
> ----------------------
>
> Regards,
> David
>
>
> >
> > On Tue, Feb 11, 2020 at 8:17 AM david larsson
> > <david.larsson@selfhosted.xyz> wrote:
> >
> >> On 2020-02-10 21:11, Stefan Israelsson Tampe wrote:
> >>> I have now added the bytes constructor that was not working.
> >>
> >> Thanks!
> >>
> >>>
> >>> To compile from source please try use the git repository at:
> >>>
> >>> https://gitlab.com/python-on-guile/python-on-guile/
> >>>
> >>> see readme for how to compile and what dependencies you have.
> >>
> >> I was able to build and install:
> >> - guile-persist: commit ebebb66ae6d6c47dbc406cdbcaccb5ffed2e463a
> >> - stis-parser: commit 7673dd576abb445fbcfce8c4b6ae961ee860902e
> >>
> >> but for python-on-guile Im getting this error on make:
> >>
> >> --------------
> >>
> >> Makefile:1390: warning: overriding recipe for target 'python'
> >> Makefile:771: warning: ignoring old recipe for target 'python'
> >> GEN      language/python/guilemod.go
> >> guile: warning: failed to install locale
> >> warning: failed to install locale: Invalid argument
> >> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
> >> Syntax error:
> >> language/python/guilemod.scm:271:0: cond-expand: unfulfilled
> >> cond-expand
> >> in form (cond-expand (guile-3.0 (define-set-M lookup-warning-type
> >> lookup-warning-type) (define-set-M warning warning) (set!
> >> %warning-types
> >> w-types)) (guile-2.0 or guile-2.2 (define-M %warning-types w-types)
> >> (define-exp-M lookup-warning-type (lambda (name) "Return the warning
> >>
> >> type NAME or `#f' if not found." ((M find) (lambda (wt) (eq? name
> >> ((M
> >> warning-type-name) wt))) (M %warning-types))))))
> >> make: *** [Makefile:1385: language/python/guilemod.go] Error 1
> >>
> >> ---------------
> >>
> >> Im compiling with guile2.2
> >>
> >> Regards,
> >> David
> >>
> >>>
> >>> Regards
> >>> Stefan
> >>>
> >>> On Mon, Feb 10, 2020 at 1:14 PM david larsson
> >>> <david.larsson@selfhosted.xyz> wrote:
> >>>
> >>>> On 2020-02-09 21:36, Stefan Israelsson Tampe wrote:
> >>>>> in sys that is
> >>>>>
> >>>>> On Sun, Feb 9, 2020 at 9:36 PM Stefan Israelsson Tampe
> >>>>> <stefan.itampe@gmail.com> wrote:
> >>>>>
> >>>>>> OKey, I changed the values from immutable lists to lists.
> >>>>>>
> >>>>
> >>>> Great!
> >>>>
> >>>>>> On Sun, Feb 9, 2020 at 9:27 PM Stefan Israelsson Tampe
> >>>>>> <stefan.itampe@gmail.com> wrote:
> >>>>>>
> >>>>>> Note that a lot of things are untested because I'm alone on the
> >>>>>> development.
> >>>>
> >>>> Ok, I understand.
> >>>>
> >>>> I haven't been able to build a recent version, but if you can
> >> share
> >>>> some
> >>>> updated instructions, then I could perhaps help out with some
> >>>> occasional
> >>>> testing. I have only managed to build from the old commit fc0d7a9
> >> by
> >>>>
> >>>> updating the current python-on-guile guix package locally.
> >>>>
> >>>>>>
> >>>>>> netlib is not included, you can test to add the python module
> >>>> file
> >>>>>> to a (language python module) directory
> >>>>
> >>>> What's been working for me so far is only (load
> >> "path/to/file.py")
> >>>> and
> >>>> (load-compiled "path/to/file.go").
> >>>>
> >>>> (use-modules (a b c)) did not work for me, except to load modules
> >>>> already shipped with python-on-guile repo; (language python
> >> module
> >>>> python) etc.
> >>>>
> >>>>>>
> >>>>>> I have recently added much more of the python stdlib aka 3.7
> >> but
> >>>> not
> >>>>>> all.
> >>>>>>
> >>>>>> Not sure what you mean by .scm file and .py fle when it comes
> >> to
> >>>>>> base64
> >>>>>> using that module in scheme gives
> >>>>>> scheme@(guile-user)> (b64decode (b64encode "abc"))
> >>>>>> $2 = b'abc'
> >>>>>> scheme@(guile-user)> (b64decode (b64encode #(1 2 3)))
> >>>>>> $3 = b'\x01\x02\x03'
> >>>>>>
> >>>>>> Which return a bytevector if you want a string back you need to
> >>>>>> interpret the bytevector back to a string
> >>>>
> >>>> Im getting weird results when trying to output the base64
> >>>> representation
> >>>> of a string, take btest.py:
> >>>> #import sys
> >>>> import base64
> >>>> def mybmethod(x):
> >>>> mybytes = bytes(x, "utf-8")
> >>>> encodedbytes = base64.b64encode(mybytes)
> >>>> myb64string = str(encodedbytes, "utf-8")
> >>>> return myb64string
> >>>> #print(myb64string)
> >>>> #mybmethod(sys.argv[1])
> >>>>
> >>>> and assume btest.scm using it with:
> >>>> (add-to-load-path (dirname (current-filename)))
> >>>> (use-modules (language python module python))
> >>>> (load "btest.py")
> >>>> (define-public (mybmethodscm cmdline)
> >>>> (display (mybmethod (cadr cmdline))))
> >>>>
> >>>> With this it will not work to run the scheme file with
> >>>> guile -e mybmethodscm btest.scm dfasdf
> >>>>
> >>>> The error I got indicated that btest.py uses the bytes procedure
> >>>> from
> >>>> within python-on-guile instead of from the python3 base64 lib:
> >>>>
> >>>> -------------------
> >>>>
> >>>> In
> >>>>
> >>>
> >>
> > /home/user1/VirtualHome/src/code_guile/python-on-guile-test/btest.scm:
> >>>> 18:11  4 (mybmethodscm _)
> >>>> In btest.py:
> >>>> 10:584  3 (_ "dfasdf" . _)
> >>>> In oop/pf-objects.scm:
> >>>> 584:15  2 (create-object _ _)
> >>>> 567:11  1 (the-create-object _ _)
> >>>> In language/python/bytes.scm:
> >>>> 99:6  0 Exception thrown while printing backtrace:
> >>>> Unbound slot in object Error while printing exception.
> >>>>
> >>>> language/python/bytes.scm:99:6: Wrong number of arguments to
> >>>> #<procedure
> >>>> 7f2bab5d4560 at language/python/bytes.scm:92:0 (self) | (self s)>
> >>>>
> >>>> -------------------
> >>>>
> >>>> For a moment though, I could run:
> >>>>
> >>>> guile -e mybmethodscm btest.scm dfasdf | rev | base64 -d | rev
> >>>> # gives: dfasdf
> >>>>
> >>>> which was also strange.
> >>>>
> >>>>>>
> >>>>>> modules are a bit difficult as I use the guile module system
> >> and
> >>>> the
> >>>>>> python modules are different.
> >>>>>> So nested modules needs some work. The best is to test and see.
> >>>>
> >>>> Ok, got it!
> >>>>
> >>>>>>
> >>>>>> I will look into the sys thingies
> >>>>>>
> >>>>>> Regards
> >>>>>> Stefan
> >>>>>>
> >>>>>> On Sun, Feb 9, 2020 at 8:40 PM david larsson
> >>>>>> <david.larsson@selfhosted.xyz> wrote:
> >>>>>> Thanks for your explanations, but unfortunately I still can't
> >>>> figure
> >>>>>> out
> >>>>>> how to use this except in the simplest of cases.
> >>>>>>
> >>>>>> I am using the guix package python-on-guile 0.1.0-3.00a51a2 -
> >>>> maybe
> >>>>>> thats outdated?
> >>>>>>
> >>>>>> The simple things I have managed to do, are like:
> >>>>>>
> >>>>>> (add-to-load-path (dirname (current-filename)))
> >>>>>> (load-compiled python-test.go)
> >>>>>>
> >>>>>> where python-test.go is compiled with:
> >>>>>>
> >>>>>> guild compile python-test.py --output=python-test.go
> >>>>>> --from=python
> >>>>>>
> >>>>>> and contains simple things, like:
> >>>>>>
> >>>>>> f(s):
> >>>>>> a = s + 1
> >>>>>> return a
> >>>>>>
> >>>>>> but if I add statements to python-test.py like:
> >>>>>>
> >>>>>> import netaddr
> >>>>>> def myfun(a)
> >>>>>> <something using netaddr>
> >>>>>>
> >>>>>> (netaddr is a module installed via: pip3 install --user
> >> netaddr)
> >>>>>>
> >>>>>> I receive an error about not finding the module.
> >>>>>>
> >>>>>> I am able to add only the modules which exist in the
> >>>> python-on-guile
> >>>>>>
> >>>>>> repo, like:
> >>>>>>
> >>>>>> import sys
> >>>>>> import base64
> >>>>>>
> >>>>>> but Im getting errors, for example Im not able to use things
> >> from
> >>>>>> sys,
> >>>>>> like:
> >>>>>>
> >>>>>> sys.path.append(<somepath>)
> >>>>>> sys.path.insert(0, <somepath>)
> >>>>>>
> >>>>>> I was able to use some things from base64 but I only received
> >>>> weird
> >>>>>> results when converting between bytevectors and strings between
> >>>> the
> >>>>>> .scm
> >>>>>> file and .py file. What works fine using python3 python-test.py
> >>>> do
> >>>>>> not
> >>>>>> usually work when passing either a bytevector or string to the
> >>>> same
> >>>>>> go-compiled file from the .scm file using the python-code. Not
> >>>> sure
> >>>>>> whether there's a problem using python3 vs python2 here?
> >>>>>>
> >>>>>> Essentially, what Im looking for is how to proceed if I want to
> >>>> use
> >>>>>> modules installed via the pip package manager from guile, and
> >>>> what
> >>>>>> paths
> >>>>>> and imports I need to make, and how I might need to wrap them
> >>>>>> correctly
> >>>>>> in the scheme and python files to invoke a pip package
> >> procedure
> >>>>>> from
> >>>>>> guile.
> >>>>>>
> >>>>>> Best regards,
> >>>>>> David
> >>>>>>
> >>>>>> On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
> >>>>>>> I'm the author of that lib.
> >>>>>>>
> >>>>>>> 1)
> >>>>>>>
> >>>>>>> The main bindings are reachable through (language python
> >> module
> >>>>>>> python)
> >>>>>>>
> >>>>>>> So you could now go ahead and do
> >>>>>>>> (use-modules (language python module python))
> >>>>>>>> ;L python
> >>>>>>>
> >>>>>>> And you will get a python shell that works quite ok for one
> >>>> liners
> >>>>>>>
> >>>>>>> 2)
> >>>>>>>
> >>>>>>> If you write a module and place it in a/b/c.py
> >>>>>>> you can use the classes and functions theirin by
> >>>>>>>
> >>>>>>> (use-modules (a b c))
> >>>>>>>
> >>>>>>> 3)
> >>>>>>> you can load a .py file as (i hope this work)
> >>>>>>> (load "a.py")
> >>>>>>>
> >>>>>>> 4)
> >>>>>>> If you place a module in (language python module a.py) you can
> >>>>>> import
> >>>>>>> ir as a usual mode as
> >>>>>>>> from a import *
> >>>>>>>
> >>>>>>> The documentation is for the macro framework that enables you
> >> to
> >>>>>> work
> >>>>>>> with python classes and idioms like python iteration.
> >>>>>>>
> >>>>>>> Hope this helps
> >>>>>>> /Stefan
> >>>>>>>
> >>>>>>> On Sun, Feb 9, 2020 at 6:31 PM david larsson
> >>>>>>> <david.larsson@selfhosted.xyz> wrote:
> >>>>>>>
> >>>>>>>> Hi everyone,
> >>>>>>>> I am trying to wrap my head around how to use the
> >>>> python-on-guile
> >>>>>>>> library, but Im struggling. Does anyone have example code
> >> that
> >>>>>> might
> >>>>>>>>
> >>>>>>>> help, and which isn't too advanced?
> >>>>>>>>
> >>>>>>>> All tips and suggestions appreciated!
> >>>>>>>>
> >>>>>>>> Best regards,
> >>>>>>>> David
>


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
  2020-02-11 20:57                 ` python-on-guile Stefan Israelsson Tampe
@ 2020-02-12  9:18                   ` david larsson
  2020-02-12  9:59                     ` python-on-guile Stefan Israelsson Tampe
  0 siblings, 1 reply; 38+ messages in thread
From: david larsson @ 2020-02-12  9:18 UTC (permalink / raw)
  To: Stefan Israelsson Tampe
  Cc: Stefan Israelsson Tampe <stefan.itampe@gmail.com>

On 2020-02-11 21:57, Stefan Israelsson Tampe wrote:
> This error is fixed in repository
> /Stefan

Thanks. That solved that part. Now Im getting this error on make:

(commit 226d33163e7f1e305c0b6e2ada37209513377dff)
----------------------

Makefile:1390: warning: overriding recipe for target 'python'
Makefile:771: warning: ignoring old recipe for target 'python'
   GEN      oop/pf-objects.go
guile: warning: failed to install locale
warning: failed to install locale: Invalid argument
Backtrace:
In ice-9/boot-9.scm:
    2312:4 19 (save-module-excursion #<procedure 55a897256bc0 at lang?>)
In language/scheme/compile-tree-il.scm:
     31:15 18 (_)
In ice-9/psyntax.scm:
   1235:36 17 (expand-top-sequence ((define-module (oop #) # (# ?) ?)) ?)
   1182:24 16 (parse _ (("placeholder" placeholder)) ((top) #(# # ?)) ?)
    285:10 15 (parse _ (("placeholder" placeholder)) (()) _ c&e (# #) #)
In ice-9/eval.scm:
    293:34 14 (_ #<module (#{ g77}#) 55a8972dd0a0>)
In ice-9/boot-9.scm:
    2874:4 13 (define-module* _ #:filename _ #:pure _ #:version _ # _ ?)
   2071:24 12 (call-with-deferred-observers #<procedure 55a897086910 ?>)
   2887:24 11 (_)
    222:29 10 (map1 (((oop goops)) ((oop dict) #:renamer #<proce?>) ?))
    222:29  9 (map1 (((oop dict) #:renamer #<procedure 55a8972fb?>) ?))
    222:29  8 (map1 (((ice-9 vlist)) ((ice-9 match)) ((system # #)) ?))
    222:29  7 (map1 (((ice-9 match)) ((system base message)) ((# ?)) ?))
    222:29  6 (map1 (((system base message)) ((language python #)) # ?))
    222:29  5 (map1 (((language python guilemod)) ((ice-9 #)) ((# ?))))
    222:29  4 (map1 (((ice-9 pretty-print)) ((persist persistance))))
    222:17  3 (map1 (((persist persistance))))
    2803:6  2 (resolve-interface _ #:select _ #:hide _ #:prefix _ # _ ?)
In unknown file:
            1 (scm-error misc-error #f "~A ~S" ("no code for modu?" ?) ?)
In ice-9/boot-9.scm:
    752:25  0 (dispatch-exception _ _ _)

ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
no code for module (persist persistance)
make: *** [Makefile:1385: oop/pf-objects.go] Error 1

----------------------

Regards,
David


> 
> On Tue, Feb 11, 2020 at 8:17 AM david larsson
> <david.larsson@selfhosted.xyz> wrote:
> 
>> On 2020-02-10 21:11, Stefan Israelsson Tampe wrote:
>>> I have now added the bytes constructor that was not working.
>> 
>> Thanks!
>> 
>>> 
>>> To compile from source please try use the git repository at:
>>> 
>>> https://gitlab.com/python-on-guile/python-on-guile/
>>> 
>>> see readme for how to compile and what dependencies you have.
>> 
>> I was able to build and install:
>> - guile-persist: commit ebebb66ae6d6c47dbc406cdbcaccb5ffed2e463a
>> - stis-parser: commit 7673dd576abb445fbcfce8c4b6ae961ee860902e
>> 
>> but for python-on-guile Im getting this error on make:
>> 
>> --------------
>> 
>> Makefile:1390: warning: overriding recipe for target 'python'
>> Makefile:771: warning: ignoring old recipe for target 'python'
>> GEN      language/python/guilemod.go
>> guile: warning: failed to install locale
>> warning: failed to install locale: Invalid argument
>> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
>> Syntax error:
>> language/python/guilemod.scm:271:0: cond-expand: unfulfilled
>> cond-expand
>> in form (cond-expand (guile-3.0 (define-set-M lookup-warning-type
>> lookup-warning-type) (define-set-M warning warning) (set!
>> %warning-types
>> w-types)) (guile-2.0 or guile-2.2 (define-M %warning-types w-types)
>> (define-exp-M lookup-warning-type (lambda (name) "Return the warning
>> 
>> type NAME or `#f' if not found." ((M find) (lambda (wt) (eq? name
>> ((M
>> warning-type-name) wt))) (M %warning-types))))))
>> make: *** [Makefile:1385: language/python/guilemod.go] Error 1
>> 
>> ---------------
>> 
>> Im compiling with guile2.2
>> 
>> Regards,
>> David
>> 
>>> 
>>> Regards
>>> Stefan
>>> 
>>> On Mon, Feb 10, 2020 at 1:14 PM david larsson
>>> <david.larsson@selfhosted.xyz> wrote:
>>> 
>>>> On 2020-02-09 21:36, Stefan Israelsson Tampe wrote:
>>>>> in sys that is
>>>>> 
>>>>> On Sun, Feb 9, 2020 at 9:36 PM Stefan Israelsson Tampe
>>>>> <stefan.itampe@gmail.com> wrote:
>>>>> 
>>>>>> OKey, I changed the values from immutable lists to lists.
>>>>>> 
>>>> 
>>>> Great!
>>>> 
>>>>>> On Sun, Feb 9, 2020 at 9:27 PM Stefan Israelsson Tampe
>>>>>> <stefan.itampe@gmail.com> wrote:
>>>>>> 
>>>>>> Note that a lot of things are untested because I'm alone on the
>>>>>> development.
>>>> 
>>>> Ok, I understand.
>>>> 
>>>> I haven't been able to build a recent version, but if you can
>> share
>>>> some
>>>> updated instructions, then I could perhaps help out with some
>>>> occasional
>>>> testing. I have only managed to build from the old commit fc0d7a9
>> by
>>>> 
>>>> updating the current python-on-guile guix package locally.
>>>> 
>>>>>> 
>>>>>> netlib is not included, you can test to add the python module
>>>> file
>>>>>> to a (language python module) directory
>>>> 
>>>> What's been working for me so far is only (load
>> "path/to/file.py")
>>>> and
>>>> (load-compiled "path/to/file.go").
>>>> 
>>>> (use-modules (a b c)) did not work for me, except to load modules
>>>> already shipped with python-on-guile repo; (language python
>> module
>>>> python) etc.
>>>> 
>>>>>> 
>>>>>> I have recently added much more of the python stdlib aka 3.7
>> but
>>>> not
>>>>>> all.
>>>>>> 
>>>>>> Not sure what you mean by .scm file and .py fle when it comes
>> to
>>>>>> base64
>>>>>> using that module in scheme gives
>>>>>> scheme@(guile-user)> (b64decode (b64encode "abc"))
>>>>>> $2 = b'abc'
>>>>>> scheme@(guile-user)> (b64decode (b64encode #(1 2 3)))
>>>>>> $3 = b'\x01\x02\x03'
>>>>>> 
>>>>>> Which return a bytevector if you want a string back you need to
>>>>>> interpret the bytevector back to a string
>>>> 
>>>> Im getting weird results when trying to output the base64
>>>> representation
>>>> of a string, take btest.py:
>>>> #import sys
>>>> import base64
>>>> def mybmethod(x):
>>>> mybytes = bytes(x, "utf-8")
>>>> encodedbytes = base64.b64encode(mybytes)
>>>> myb64string = str(encodedbytes, "utf-8")
>>>> return myb64string
>>>> #print(myb64string)
>>>> #mybmethod(sys.argv[1])
>>>> 
>>>> and assume btest.scm using it with:
>>>> (add-to-load-path (dirname (current-filename)))
>>>> (use-modules (language python module python))
>>>> (load "btest.py")
>>>> (define-public (mybmethodscm cmdline)
>>>> (display (mybmethod (cadr cmdline))))
>>>> 
>>>> With this it will not work to run the scheme file with
>>>> guile -e mybmethodscm btest.scm dfasdf
>>>> 
>>>> The error I got indicated that btest.py uses the bytes procedure
>>>> from
>>>> within python-on-guile instead of from the python3 base64 lib:
>>>> 
>>>> -------------------
>>>> 
>>>> In
>>>> 
>>> 
>> 
> /home/user1/VirtualHome/src/code_guile/python-on-guile-test/btest.scm:
>>>> 18:11  4 (mybmethodscm _)
>>>> In btest.py:
>>>> 10:584  3 (_ "dfasdf" . _)
>>>> In oop/pf-objects.scm:
>>>> 584:15  2 (create-object _ _)
>>>> 567:11  1 (the-create-object _ _)
>>>> In language/python/bytes.scm:
>>>> 99:6  0 Exception thrown while printing backtrace:
>>>> Unbound slot in object Error while printing exception.
>>>> 
>>>> language/python/bytes.scm:99:6: Wrong number of arguments to
>>>> #<procedure
>>>> 7f2bab5d4560 at language/python/bytes.scm:92:0 (self) | (self s)>
>>>> 
>>>> -------------------
>>>> 
>>>> For a moment though, I could run:
>>>> 
>>>> guile -e mybmethodscm btest.scm dfasdf | rev | base64 -d | rev
>>>> # gives: dfasdf
>>>> 
>>>> which was also strange.
>>>> 
>>>>>> 
>>>>>> modules are a bit difficult as I use the guile module system
>> and
>>>> the
>>>>>> python modules are different.
>>>>>> So nested modules needs some work. The best is to test and see.
>>>> 
>>>> Ok, got it!
>>>> 
>>>>>> 
>>>>>> I will look into the sys thingies
>>>>>> 
>>>>>> Regards
>>>>>> Stefan
>>>>>> 
>>>>>> On Sun, Feb 9, 2020 at 8:40 PM david larsson
>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>> Thanks for your explanations, but unfortunately I still can't
>>>> figure
>>>>>> out
>>>>>> how to use this except in the simplest of cases.
>>>>>> 
>>>>>> I am using the guix package python-on-guile 0.1.0-3.00a51a2 -
>>>> maybe
>>>>>> thats outdated?
>>>>>> 
>>>>>> The simple things I have managed to do, are like:
>>>>>> 
>>>>>> (add-to-load-path (dirname (current-filename)))
>>>>>> (load-compiled python-test.go)
>>>>>> 
>>>>>> where python-test.go is compiled with:
>>>>>> 
>>>>>> guild compile python-test.py --output=python-test.go
>>>>>> --from=python
>>>>>> 
>>>>>> and contains simple things, like:
>>>>>> 
>>>>>> f(s):
>>>>>> a = s + 1
>>>>>> return a
>>>>>> 
>>>>>> but if I add statements to python-test.py like:
>>>>>> 
>>>>>> import netaddr
>>>>>> def myfun(a)
>>>>>> <something using netaddr>
>>>>>> 
>>>>>> (netaddr is a module installed via: pip3 install --user
>> netaddr)
>>>>>> 
>>>>>> I receive an error about not finding the module.
>>>>>> 
>>>>>> I am able to add only the modules which exist in the
>>>> python-on-guile
>>>>>> 
>>>>>> repo, like:
>>>>>> 
>>>>>> import sys
>>>>>> import base64
>>>>>> 
>>>>>> but Im getting errors, for example Im not able to use things
>> from
>>>>>> sys,
>>>>>> like:
>>>>>> 
>>>>>> sys.path.append(<somepath>)
>>>>>> sys.path.insert(0, <somepath>)
>>>>>> 
>>>>>> I was able to use some things from base64 but I only received
>>>> weird
>>>>>> results when converting between bytevectors and strings between
>>>> the
>>>>>> .scm
>>>>>> file and .py file. What works fine using python3 python-test.py
>>>> do
>>>>>> not
>>>>>> usually work when passing either a bytevector or string to the
>>>> same
>>>>>> go-compiled file from the .scm file using the python-code. Not
>>>> sure
>>>>>> whether there's a problem using python3 vs python2 here?
>>>>>> 
>>>>>> Essentially, what Im looking for is how to proceed if I want to
>>>> use
>>>>>> modules installed via the pip package manager from guile, and
>>>> what
>>>>>> paths
>>>>>> and imports I need to make, and how I might need to wrap them
>>>>>> correctly
>>>>>> in the scheme and python files to invoke a pip package
>> procedure
>>>>>> from
>>>>>> guile.
>>>>>> 
>>>>>> Best regards,
>>>>>> David
>>>>>> 
>>>>>> On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
>>>>>>> I'm the author of that lib.
>>>>>>> 
>>>>>>> 1)
>>>>>>> 
>>>>>>> The main bindings are reachable through (language python
>> module
>>>>>>> python)
>>>>>>> 
>>>>>>> So you could now go ahead and do
>>>>>>>> (use-modules (language python module python))
>>>>>>>> ;L python
>>>>>>> 
>>>>>>> And you will get a python shell that works quite ok for one
>>>> liners
>>>>>>> 
>>>>>>> 2)
>>>>>>> 
>>>>>>> If you write a module and place it in a/b/c.py
>>>>>>> you can use the classes and functions theirin by
>>>>>>> 
>>>>>>> (use-modules (a b c))
>>>>>>> 
>>>>>>> 3)
>>>>>>> you can load a .py file as (i hope this work)
>>>>>>> (load "a.py")
>>>>>>> 
>>>>>>> 4)
>>>>>>> If you place a module in (language python module a.py) you can
>>>>>> import
>>>>>>> ir as a usual mode as
>>>>>>>> from a import *
>>>>>>> 
>>>>>>> The documentation is for the macro framework that enables you
>> to
>>>>>> work
>>>>>>> with python classes and idioms like python iteration.
>>>>>>> 
>>>>>>> Hope this helps
>>>>>>> /Stefan
>>>>>>> 
>>>>>>> On Sun, Feb 9, 2020 at 6:31 PM david larsson
>>>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>>>> 
>>>>>>>> Hi everyone,
>>>>>>>> I am trying to wrap my head around how to use the
>>>> python-on-guile
>>>>>>>> library, but Im struggling. Does anyone have example code
>> that
>>>>>> might
>>>>>>>> 
>>>>>>>> help, and which isn't too advanced?
>>>>>>>> 
>>>>>>>> All tips and suggestions appreciated!
>>>>>>>> 
>>>>>>>> Best regards,
>>>>>>>> David



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
  2020-02-11  7:17               ` python-on-guile david larsson
  2020-02-11 10:44                 ` python-on-guile Stefan Israelsson Tampe
@ 2020-02-11 20:57                 ` Stefan Israelsson Tampe
  2020-02-12  9:18                   ` python-on-guile david larsson
  1 sibling, 1 reply; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2020-02-11 20:57 UTC (permalink / raw)
  To: david larsson; +Cc: Stefan Israelsson Tampe <stefan.itampe@gmail.com>

This error is fixed in repository
/Stefan

On Tue, Feb 11, 2020 at 8:17 AM david larsson <david.larsson@selfhosted.xyz>
wrote:

> On 2020-02-10 21:11, Stefan Israelsson Tampe wrote:
> > I have now added the bytes constructor that was not working.
>
> Thanks!
>
> >
> > To compile from source please try use the git repository at:
> >
> > https://gitlab.com/python-on-guile/python-on-guile/
> >
> > see readme for how to compile and what dependencies you have.
>
> I was able to build and install:
>    - guile-persist: commit ebebb66ae6d6c47dbc406cdbcaccb5ffed2e463a
>    - stis-parser: commit 7673dd576abb445fbcfce8c4b6ae961ee860902e
>
> but for python-on-guile Im getting this error on make:
>
> --------------
>
> Makefile:1390: warning: overriding recipe for target 'python'
> Makefile:771: warning: ignoring old recipe for target 'python'
>    GEN      language/python/guilemod.go
> guile: warning: failed to install locale
> warning: failed to install locale: Invalid argument
> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
> Syntax error:
> language/python/guilemod.scm:271:0: cond-expand: unfulfilled cond-expand
> in form (cond-expand (guile-3.0 (define-set-M lookup-warning-type
> lookup-warning-type) (define-set-M warning warning) (set! %warning-types
> w-types)) (guile-2.0 or guile-2.2 (define-M %warning-types w-types)
> (define-exp-M lookup-warning-type (lambda (name) "Return the warning
> type NAME or `#f' if not found." ((M find) (lambda (wt) (eq? name ((M
> warning-type-name) wt))) (M %warning-types))))))
> make: *** [Makefile:1385: language/python/guilemod.go] Error 1
>
> ---------------
>
> Im compiling with guile2.2
>
> Regards,
> David
>
> >
> > Regards
> > Stefan
> >
> > On Mon, Feb 10, 2020 at 1:14 PM david larsson
> > <david.larsson@selfhosted.xyz> wrote:
> >
> >> On 2020-02-09 21:36, Stefan Israelsson Tampe wrote:
> >>> in sys that is
> >>>
> >>> On Sun, Feb 9, 2020 at 9:36 PM Stefan Israelsson Tampe
> >>> <stefan.itampe@gmail.com> wrote:
> >>>
> >>>> OKey, I changed the values from immutable lists to lists.
> >>>>
> >>
> >> Great!
> >>
> >>>> On Sun, Feb 9, 2020 at 9:27 PM Stefan Israelsson Tampe
> >>>> <stefan.itampe@gmail.com> wrote:
> >>>>
> >>>> Note that a lot of things are untested because I'm alone on the
> >>>> development.
> >>
> >> Ok, I understand.
> >>
> >> I haven't been able to build a recent version, but if you can share
> >> some
> >> updated instructions, then I could perhaps help out with some
> >> occasional
> >> testing. I have only managed to build from the old commit fc0d7a9 by
> >>
> >> updating the current python-on-guile guix package locally.
> >>
> >>>>
> >>>> netlib is not included, you can test to add the python module
> >> file
> >>>> to a (language python module) directory
> >>
> >> What's been working for me so far is only (load "path/to/file.py")
> >> and
> >> (load-compiled "path/to/file.go").
> >>
> >> (use-modules (a b c)) did not work for me, except to load modules
> >> already shipped with python-on-guile repo; (language python module
> >> python) etc.
> >>
> >>>>
> >>>> I have recently added much more of the python stdlib aka 3.7 but
> >> not
> >>>> all.
> >>>>
> >>>> Not sure what you mean by .scm file and .py fle when it comes to
> >>>> base64
> >>>> using that module in scheme gives
> >>>> scheme@(guile-user)> (b64decode (b64encode "abc"))
> >>>> $2 = b'abc'
> >>>> scheme@(guile-user)> (b64decode (b64encode #(1 2 3)))
> >>>> $3 = b'\x01\x02\x03'
> >>>>
> >>>> Which return a bytevector if you want a string back you need to
> >>>> interpret the bytevector back to a string
> >>
> >> Im getting weird results when trying to output the base64
> >> representation
> >> of a string, take btest.py:
> >> #import sys
> >> import base64
> >> def mybmethod(x):
> >> mybytes = bytes(x, "utf-8")
> >> encodedbytes = base64.b64encode(mybytes)
> >> myb64string = str(encodedbytes, "utf-8")
> >> return myb64string
> >> #print(myb64string)
> >> #mybmethod(sys.argv[1])
> >>
> >> and assume btest.scm using it with:
> >> (add-to-load-path (dirname (current-filename)))
> >> (use-modules (language python module python))
> >> (load "btest.py")
> >> (define-public (mybmethodscm cmdline)
> >> (display (mybmethod (cadr cmdline))))
> >>
> >> With this it will not work to run the scheme file with
> >> guile -e mybmethodscm btest.scm dfasdf
> >>
> >> The error I got indicated that btest.py uses the bytes procedure
> >> from
> >> within python-on-guile instead of from the python3 base64 lib:
> >>
> >> -------------------
> >>
> >> In
> >>
> > /home/user1/VirtualHome/src/code_guile/python-on-guile-test/btest.scm:
> >> 18:11  4 (mybmethodscm _)
> >> In btest.py:
> >> 10:584  3 (_ "dfasdf" . _)
> >> In oop/pf-objects.scm:
> >> 584:15  2 (create-object _ _)
> >> 567:11  1 (the-create-object _ _)
> >> In language/python/bytes.scm:
> >> 99:6  0 Exception thrown while printing backtrace:
> >> Unbound slot in object Error while printing exception.
> >>
> >> language/python/bytes.scm:99:6: Wrong number of arguments to
> >> #<procedure
> >> 7f2bab5d4560 at language/python/bytes.scm:92:0 (self) | (self s)>
> >>
> >> -------------------
> >>
> >> For a moment though, I could run:
> >>
> >> guile -e mybmethodscm btest.scm dfasdf | rev | base64 -d | rev
> >> # gives: dfasdf
> >>
> >> which was also strange.
> >>
> >>>>
> >>>> modules are a bit difficult as I use the guile module system and
> >> the
> >>>> python modules are different.
> >>>> So nested modules needs some work. The best is to test and see.
> >>
> >> Ok, got it!
> >>
> >>>>
> >>>> I will look into the sys thingies
> >>>>
> >>>> Regards
> >>>> Stefan
> >>>>
> >>>> On Sun, Feb 9, 2020 at 8:40 PM david larsson
> >>>> <david.larsson@selfhosted.xyz> wrote:
> >>>> Thanks for your explanations, but unfortunately I still can't
> >> figure
> >>>> out
> >>>> how to use this except in the simplest of cases.
> >>>>
> >>>> I am using the guix package python-on-guile 0.1.0-3.00a51a2 -
> >> maybe
> >>>> thats outdated?
> >>>>
> >>>> The simple things I have managed to do, are like:
> >>>>
> >>>> (add-to-load-path (dirname (current-filename)))
> >>>> (load-compiled python-test.go)
> >>>>
> >>>> where python-test.go is compiled with:
> >>>>
> >>>> guild compile python-test.py --output=python-test.go
> >>>> --from=python
> >>>>
> >>>> and contains simple things, like:
> >>>>
> >>>> f(s):
> >>>> a = s + 1
> >>>> return a
> >>>>
> >>>> but if I add statements to python-test.py like:
> >>>>
> >>>> import netaddr
> >>>> def myfun(a)
> >>>> <something using netaddr>
> >>>>
> >>>> (netaddr is a module installed via: pip3 install --user netaddr)
> >>>>
> >>>> I receive an error about not finding the module.
> >>>>
> >>>> I am able to add only the modules which exist in the
> >> python-on-guile
> >>>>
> >>>> repo, like:
> >>>>
> >>>> import sys
> >>>> import base64
> >>>>
> >>>> but Im getting errors, for example Im not able to use things from
> >>>> sys,
> >>>> like:
> >>>>
> >>>> sys.path.append(<somepath>)
> >>>> sys.path.insert(0, <somepath>)
> >>>>
> >>>> I was able to use some things from base64 but I only received
> >> weird
> >>>> results when converting between bytevectors and strings between
> >> the
> >>>> .scm
> >>>> file and .py file. What works fine using python3 python-test.py
> >> do
> >>>> not
> >>>> usually work when passing either a bytevector or string to the
> >> same
> >>>> go-compiled file from the .scm file using the python-code. Not
> >> sure
> >>>> whether there's a problem using python3 vs python2 here?
> >>>>
> >>>> Essentially, what Im looking for is how to proceed if I want to
> >> use
> >>>> modules installed via the pip package manager from guile, and
> >> what
> >>>> paths
> >>>> and imports I need to make, and how I might need to wrap them
> >>>> correctly
> >>>> in the scheme and python files to invoke a pip package procedure
> >>>> from
> >>>> guile.
> >>>>
> >>>> Best regards,
> >>>> David
> >>>>
> >>>> On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
> >>>>> I'm the author of that lib.
> >>>>>
> >>>>> 1)
> >>>>>
> >>>>> The main bindings are reachable through (language python module
> >>>>> python)
> >>>>>
> >>>>> So you could now go ahead and do
> >>>>>> (use-modules (language python module python))
> >>>>>> ;L python
> >>>>>
> >>>>> And you will get a python shell that works quite ok for one
> >> liners
> >>>>>
> >>>>> 2)
> >>>>>
> >>>>> If you write a module and place it in a/b/c.py
> >>>>> you can use the classes and functions theirin by
> >>>>>
> >>>>> (use-modules (a b c))
> >>>>>
> >>>>> 3)
> >>>>> you can load a .py file as (i hope this work)
> >>>>> (load "a.py")
> >>>>>
> >>>>> 4)
> >>>>> If you place a module in (language python module a.py) you can
> >>>> import
> >>>>> ir as a usual mode as
> >>>>>> from a import *
> >>>>>
> >>>>> The documentation is for the macro framework that enables you to
> >>>> work
> >>>>> with python classes and idioms like python iteration.
> >>>>>
> >>>>> Hope this helps
> >>>>> /Stefan
> >>>>>
> >>>>> On Sun, Feb 9, 2020 at 6:31 PM david larsson
> >>>>> <david.larsson@selfhosted.xyz> wrote:
> >>>>>
> >>>>>> Hi everyone,
> >>>>>> I am trying to wrap my head around how to use the
> >> python-on-guile
> >>>>>> library, but Im struggling. Does anyone have example code that
> >>>> might
> >>>>>>
> >>>>>> help, and which isn't too advanced?
> >>>>>>
> >>>>>> All tips and suggestions appreciated!
> >>>>>>
> >>>>>> Best regards,
> >>>>>> David
>


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
  2020-02-11  7:17               ` python-on-guile david larsson
@ 2020-02-11 10:44                 ` Stefan Israelsson Tampe
  2020-02-11 20:57                 ` python-on-guile Stefan Israelsson Tampe
  1 sibling, 0 replies; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2020-02-11 10:44 UTC (permalink / raw)
  To: david larsson; +Cc: Stefan Israelsson Tampe <stefan.itampe@gmail.com>

Good that you are trying end test it for guile 2.2, there is a missing part
in a cond-expand e.g. code that expands differently for different versions.
I am currently at guile 3.0.0 . I'll fix it when I get home tonight.

Regards
Stefan

On Tue, Feb 11, 2020 at 8:17 AM david larsson <david.larsson@selfhosted.xyz>
wrote:

> On 2020-02-10 21:11, Stefan Israelsson Tampe wrote:
> > I have now added the bytes constructor that was not working.
>
> Thanks!
>
> >
> > To compile from source please try use the git repository at:
> >
> > https://gitlab.com/python-on-guile/python-on-guile/
> >
> > see readme for how to compile and what dependencies you have.
>
> I was able to build and install:
>    - guile-persist: commit ebebb66ae6d6c47dbc406cdbcaccb5ffed2e463a
>    - stis-parser: commit 7673dd576abb445fbcfce8c4b6ae961ee860902e
>
> but for python-on-guile Im getting this error on make:
>
> --------------
>
> Makefile:1390: warning: overriding recipe for target 'python'
> Makefile:771: warning: ignoring old recipe for target 'python'
>    GEN      language/python/guilemod.go
> guile: warning: failed to install locale
> warning: failed to install locale: Invalid argument
> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
> Syntax error:
> language/python/guilemod.scm:271:0: cond-expand: unfulfilled cond-expand
> in form (cond-expand (guile-3.0 (define-set-M lookup-warning-type
> lookup-warning-type) (define-set-M warning warning) (set! %warning-types
> w-types)) (guile-2.0 or guile-2.2 (define-M %warning-types w-types)
> (define-exp-M lookup-warning-type (lambda (name) "Return the warning
> type NAME or `#f' if not found." ((M find) (lambda (wt) (eq? name ((M
> warning-type-name) wt))) (M %warning-types))))))
> make: *** [Makefile:1385: language/python/guilemod.go] Error 1
>
> ---------------
>
> Im compiling with guile2.2
>
> Regards,
> David
>
> >
> > Regards
> > Stefan
> >
> > On Mon, Feb 10, 2020 at 1:14 PM david larsson
> > <david.larsson@selfhosted.xyz> wrote:
> >
> >> On 2020-02-09 21:36, Stefan Israelsson Tampe wrote:
> >>> in sys that is
> >>>
> >>> On Sun, Feb 9, 2020 at 9:36 PM Stefan Israelsson Tampe
> >>> <stefan.itampe@gmail.com> wrote:
> >>>
> >>>> OKey, I changed the values from immutable lists to lists.
> >>>>
> >>
> >> Great!
> >>
> >>>> On Sun, Feb 9, 2020 at 9:27 PM Stefan Israelsson Tampe
> >>>> <stefan.itampe@gmail.com> wrote:
> >>>>
> >>>> Note that a lot of things are untested because I'm alone on the
> >>>> development.
> >>
> >> Ok, I understand.
> >>
> >> I haven't been able to build a recent version, but if you can share
> >> some
> >> updated instructions, then I could perhaps help out with some
> >> occasional
> >> testing. I have only managed to build from the old commit fc0d7a9 by
> >>
> >> updating the current python-on-guile guix package locally.
> >>
> >>>>
> >>>> netlib is not included, you can test to add the python module
> >> file
> >>>> to a (language python module) directory
> >>
> >> What's been working for me so far is only (load "path/to/file.py")
> >> and
> >> (load-compiled "path/to/file.go").
> >>
> >> (use-modules (a b c)) did not work for me, except to load modules
> >> already shipped with python-on-guile repo; (language python module
> >> python) etc.
> >>
> >>>>
> >>>> I have recently added much more of the python stdlib aka 3.7 but
> >> not
> >>>> all.
> >>>>
> >>>> Not sure what you mean by .scm file and .py fle when it comes to
> >>>> base64
> >>>> using that module in scheme gives
> >>>> scheme@(guile-user)> (b64decode (b64encode "abc"))
> >>>> $2 = b'abc'
> >>>> scheme@(guile-user)> (b64decode (b64encode #(1 2 3)))
> >>>> $3 = b'\x01\x02\x03'
> >>>>
> >>>> Which return a bytevector if you want a string back you need to
> >>>> interpret the bytevector back to a string
> >>
> >> Im getting weird results when trying to output the base64
> >> representation
> >> of a string, take btest.py:
> >> #import sys
> >> import base64
> >> def mybmethod(x):
> >> mybytes = bytes(x, "utf-8")
> >> encodedbytes = base64.b64encode(mybytes)
> >> myb64string = str(encodedbytes, "utf-8")
> >> return myb64string
> >> #print(myb64string)
> >> #mybmethod(sys.argv[1])
> >>
> >> and assume btest.scm using it with:
> >> (add-to-load-path (dirname (current-filename)))
> >> (use-modules (language python module python))
> >> (load "btest.py")
> >> (define-public (mybmethodscm cmdline)
> >> (display (mybmethod (cadr cmdline))))
> >>
> >> With this it will not work to run the scheme file with
> >> guile -e mybmethodscm btest.scm dfasdf
> >>
> >> The error I got indicated that btest.py uses the bytes procedure
> >> from
> >> within python-on-guile instead of from the python3 base64 lib:
> >>
> >> -------------------
> >>
> >> In
> >>
> > /home/user1/VirtualHome/src/code_guile/python-on-guile-test/btest.scm:
> >> 18:11  4 (mybmethodscm _)
> >> In btest.py:
> >> 10:584  3 (_ "dfasdf" . _)
> >> In oop/pf-objects.scm:
> >> 584:15  2 (create-object _ _)
> >> 567:11  1 (the-create-object _ _)
> >> In language/python/bytes.scm:
> >> 99:6  0 Exception thrown while printing backtrace:
> >> Unbound slot in object Error while printing exception.
> >>
> >> language/python/bytes.scm:99:6: Wrong number of arguments to
> >> #<procedure
> >> 7f2bab5d4560 at language/python/bytes.scm:92:0 (self) | (self s)>
> >>
> >> -------------------
> >>
> >> For a moment though, I could run:
> >>
> >> guile -e mybmethodscm btest.scm dfasdf | rev | base64 -d | rev
> >> # gives: dfasdf
> >>
> >> which was also strange.
> >>
> >>>>
> >>>> modules are a bit difficult as I use the guile module system and
> >> the
> >>>> python modules are different.
> >>>> So nested modules needs some work. The best is to test and see.
> >>
> >> Ok, got it!
> >>
> >>>>
> >>>> I will look into the sys thingies
> >>>>
> >>>> Regards
> >>>> Stefan
> >>>>
> >>>> On Sun, Feb 9, 2020 at 8:40 PM david larsson
> >>>> <david.larsson@selfhosted.xyz> wrote:
> >>>> Thanks for your explanations, but unfortunately I still can't
> >> figure
> >>>> out
> >>>> how to use this except in the simplest of cases.
> >>>>
> >>>> I am using the guix package python-on-guile 0.1.0-3.00a51a2 -
> >> maybe
> >>>> thats outdated?
> >>>>
> >>>> The simple things I have managed to do, are like:
> >>>>
> >>>> (add-to-load-path (dirname (current-filename)))
> >>>> (load-compiled python-test.go)
> >>>>
> >>>> where python-test.go is compiled with:
> >>>>
> >>>> guild compile python-test.py --output=python-test.go
> >>>> --from=python
> >>>>
> >>>> and contains simple things, like:
> >>>>
> >>>> f(s):
> >>>> a = s + 1
> >>>> return a
> >>>>
> >>>> but if I add statements to python-test.py like:
> >>>>
> >>>> import netaddr
> >>>> def myfun(a)
> >>>> <something using netaddr>
> >>>>
> >>>> (netaddr is a module installed via: pip3 install --user netaddr)
> >>>>
> >>>> I receive an error about not finding the module.
> >>>>
> >>>> I am able to add only the modules which exist in the
> >> python-on-guile
> >>>>
> >>>> repo, like:
> >>>>
> >>>> import sys
> >>>> import base64
> >>>>
> >>>> but Im getting errors, for example Im not able to use things from
> >>>> sys,
> >>>> like:
> >>>>
> >>>> sys.path.append(<somepath>)
> >>>> sys.path.insert(0, <somepath>)
> >>>>
> >>>> I was able to use some things from base64 but I only received
> >> weird
> >>>> results when converting between bytevectors and strings between
> >> the
> >>>> .scm
> >>>> file and .py file. What works fine using python3 python-test.py
> >> do
> >>>> not
> >>>> usually work when passing either a bytevector or string to the
> >> same
> >>>> go-compiled file from the .scm file using the python-code. Not
> >> sure
> >>>> whether there's a problem using python3 vs python2 here?
> >>>>
> >>>> Essentially, what Im looking for is how to proceed if I want to
> >> use
> >>>> modules installed via the pip package manager from guile, and
> >> what
> >>>> paths
> >>>> and imports I need to make, and how I might need to wrap them
> >>>> correctly
> >>>> in the scheme and python files to invoke a pip package procedure
> >>>> from
> >>>> guile.
> >>>>
> >>>> Best regards,
> >>>> David
> >>>>
> >>>> On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
> >>>>> I'm the author of that lib.
> >>>>>
> >>>>> 1)
> >>>>>
> >>>>> The main bindings are reachable through (language python module
> >>>>> python)
> >>>>>
> >>>>> So you could now go ahead and do
> >>>>>> (use-modules (language python module python))
> >>>>>> ;L python
> >>>>>
> >>>>> And you will get a python shell that works quite ok for one
> >> liners
> >>>>>
> >>>>> 2)
> >>>>>
> >>>>> If you write a module and place it in a/b/c.py
> >>>>> you can use the classes and functions theirin by
> >>>>>
> >>>>> (use-modules (a b c))
> >>>>>
> >>>>> 3)
> >>>>> you can load a .py file as (i hope this work)
> >>>>> (load "a.py")
> >>>>>
> >>>>> 4)
> >>>>> If you place a module in (language python module a.py) you can
> >>>> import
> >>>>> ir as a usual mode as
> >>>>>> from a import *
> >>>>>
> >>>>> The documentation is for the macro framework that enables you to
> >>>> work
> >>>>> with python classes and idioms like python iteration.
> >>>>>
> >>>>> Hope this helps
> >>>>> /Stefan
> >>>>>
> >>>>> On Sun, Feb 9, 2020 at 6:31 PM david larsson
> >>>>> <david.larsson@selfhosted.xyz> wrote:
> >>>>>
> >>>>>> Hi everyone,
> >>>>>> I am trying to wrap my head around how to use the
> >> python-on-guile
> >>>>>> library, but Im struggling. Does anyone have example code that
> >>>> might
> >>>>>>
> >>>>>> help, and which isn't too advanced?
> >>>>>>
> >>>>>> All tips and suggestions appreciated!
> >>>>>>
> >>>>>> Best regards,
> >>>>>> David
>


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
  2020-02-10 20:11             ` python-on-guile Stefan Israelsson Tampe
@ 2020-02-11  7:17               ` david larsson
  2020-02-11 10:44                 ` python-on-guile Stefan Israelsson Tampe
  2020-02-11 20:57                 ` python-on-guile Stefan Israelsson Tampe
  0 siblings, 2 replies; 38+ messages in thread
From: david larsson @ 2020-02-11  7:17 UTC (permalink / raw)
  To: Stefan Israelsson Tampe
  Cc: Stefan Israelsson Tampe <stefan.itampe@gmail.com>

On 2020-02-10 21:11, Stefan Israelsson Tampe wrote:
> I have now added the bytes constructor that was not working.

Thanks!

> 
> To compile from source please try use the git repository at:
> 
> https://gitlab.com/python-on-guile/python-on-guile/
> 
> see readme for how to compile and what dependencies you have.

I was able to build and install:
   - guile-persist: commit ebebb66ae6d6c47dbc406cdbcaccb5ffed2e463a
   - stis-parser: commit 7673dd576abb445fbcfce8c4b6ae961ee860902e

but for python-on-guile Im getting this error on make:

--------------

Makefile:1390: warning: overriding recipe for target 'python'
Makefile:771: warning: ignoring old recipe for target 'python'
   GEN      language/python/guilemod.go
guile: warning: failed to install locale
warning: failed to install locale: Invalid argument
ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
Syntax error:
language/python/guilemod.scm:271:0: cond-expand: unfulfilled cond-expand 
in form (cond-expand (guile-3.0 (define-set-M lookup-warning-type 
lookup-warning-type) (define-set-M warning warning) (set! %warning-types 
w-types)) (guile-2.0 or guile-2.2 (define-M %warning-types w-types) 
(define-exp-M lookup-warning-type (lambda (name) "Return the warning 
type NAME or `#f' if not found." ((M find) (lambda (wt) (eq? name ((M 
warning-type-name) wt))) (M %warning-types))))))
make: *** [Makefile:1385: language/python/guilemod.go] Error 1

---------------

Im compiling with guile2.2

Regards,
David

> 
> Regards
> Stefan
> 
> On Mon, Feb 10, 2020 at 1:14 PM david larsson
> <david.larsson@selfhosted.xyz> wrote:
> 
>> On 2020-02-09 21:36, Stefan Israelsson Tampe wrote:
>>> in sys that is
>>> 
>>> On Sun, Feb 9, 2020 at 9:36 PM Stefan Israelsson Tampe
>>> <stefan.itampe@gmail.com> wrote:
>>> 
>>>> OKey, I changed the values from immutable lists to lists.
>>>> 
>> 
>> Great!
>> 
>>>> On Sun, Feb 9, 2020 at 9:27 PM Stefan Israelsson Tampe
>>>> <stefan.itampe@gmail.com> wrote:
>>>> 
>>>> Note that a lot of things are untested because I'm alone on the
>>>> development.
>> 
>> Ok, I understand.
>> 
>> I haven't been able to build a recent version, but if you can share
>> some
>> updated instructions, then I could perhaps help out with some
>> occasional
>> testing. I have only managed to build from the old commit fc0d7a9 by
>> 
>> updating the current python-on-guile guix package locally.
>> 
>>>> 
>>>> netlib is not included, you can test to add the python module
>> file
>>>> to a (language python module) directory
>> 
>> What's been working for me so far is only (load "path/to/file.py")
>> and
>> (load-compiled "path/to/file.go").
>> 
>> (use-modules (a b c)) did not work for me, except to load modules
>> already shipped with python-on-guile repo; (language python module
>> python) etc.
>> 
>>>> 
>>>> I have recently added much more of the python stdlib aka 3.7 but
>> not
>>>> all.
>>>> 
>>>> Not sure what you mean by .scm file and .py fle when it comes to
>>>> base64
>>>> using that module in scheme gives
>>>> scheme@(guile-user)> (b64decode (b64encode "abc"))
>>>> $2 = b'abc'
>>>> scheme@(guile-user)> (b64decode (b64encode #(1 2 3)))
>>>> $3 = b'\x01\x02\x03'
>>>> 
>>>> Which return a bytevector if you want a string back you need to
>>>> interpret the bytevector back to a string
>> 
>> Im getting weird results when trying to output the base64
>> representation
>> of a string, take btest.py:
>> #import sys
>> import base64
>> def mybmethod(x):
>> mybytes = bytes(x, "utf-8")
>> encodedbytes = base64.b64encode(mybytes)
>> myb64string = str(encodedbytes, "utf-8")
>> return myb64string
>> #print(myb64string)
>> #mybmethod(sys.argv[1])
>> 
>> and assume btest.scm using it with:
>> (add-to-load-path (dirname (current-filename)))
>> (use-modules (language python module python))
>> (load "btest.py")
>> (define-public (mybmethodscm cmdline)
>> (display (mybmethod (cadr cmdline))))
>> 
>> With this it will not work to run the scheme file with
>> guile -e mybmethodscm btest.scm dfasdf
>> 
>> The error I got indicated that btest.py uses the bytes procedure
>> from
>> within python-on-guile instead of from the python3 base64 lib:
>> 
>> -------------------
>> 
>> In
>> 
> /home/user1/VirtualHome/src/code_guile/python-on-guile-test/btest.scm:
>> 18:11  4 (mybmethodscm _)
>> In btest.py:
>> 10:584  3 (_ "dfasdf" . _)
>> In oop/pf-objects.scm:
>> 584:15  2 (create-object _ _)
>> 567:11  1 (the-create-object _ _)
>> In language/python/bytes.scm:
>> 99:6  0 Exception thrown while printing backtrace:
>> Unbound slot in object Error while printing exception.
>> 
>> language/python/bytes.scm:99:6: Wrong number of arguments to
>> #<procedure
>> 7f2bab5d4560 at language/python/bytes.scm:92:0 (self) | (self s)>
>> 
>> -------------------
>> 
>> For a moment though, I could run:
>> 
>> guile -e mybmethodscm btest.scm dfasdf | rev | base64 -d | rev
>> # gives: dfasdf
>> 
>> which was also strange.
>> 
>>>> 
>>>> modules are a bit difficult as I use the guile module system and
>> the
>>>> python modules are different.
>>>> So nested modules needs some work. The best is to test and see.
>> 
>> Ok, got it!
>> 
>>>> 
>>>> I will look into the sys thingies
>>>> 
>>>> Regards
>>>> Stefan
>>>> 
>>>> On Sun, Feb 9, 2020 at 8:40 PM david larsson
>>>> <david.larsson@selfhosted.xyz> wrote:
>>>> Thanks for your explanations, but unfortunately I still can't
>> figure
>>>> out
>>>> how to use this except in the simplest of cases.
>>>> 
>>>> I am using the guix package python-on-guile 0.1.0-3.00a51a2 -
>> maybe
>>>> thats outdated?
>>>> 
>>>> The simple things I have managed to do, are like:
>>>> 
>>>> (add-to-load-path (dirname (current-filename)))
>>>> (load-compiled python-test.go)
>>>> 
>>>> where python-test.go is compiled with:
>>>> 
>>>> guild compile python-test.py --output=python-test.go
>>>> --from=python
>>>> 
>>>> and contains simple things, like:
>>>> 
>>>> f(s):
>>>> a = s + 1
>>>> return a
>>>> 
>>>> but if I add statements to python-test.py like:
>>>> 
>>>> import netaddr
>>>> def myfun(a)
>>>> <something using netaddr>
>>>> 
>>>> (netaddr is a module installed via: pip3 install --user netaddr)
>>>> 
>>>> I receive an error about not finding the module.
>>>> 
>>>> I am able to add only the modules which exist in the
>> python-on-guile
>>>> 
>>>> repo, like:
>>>> 
>>>> import sys
>>>> import base64
>>>> 
>>>> but Im getting errors, for example Im not able to use things from
>>>> sys,
>>>> like:
>>>> 
>>>> sys.path.append(<somepath>)
>>>> sys.path.insert(0, <somepath>)
>>>> 
>>>> I was able to use some things from base64 but I only received
>> weird
>>>> results when converting between bytevectors and strings between
>> the
>>>> .scm
>>>> file and .py file. What works fine using python3 python-test.py
>> do
>>>> not
>>>> usually work when passing either a bytevector or string to the
>> same
>>>> go-compiled file from the .scm file using the python-code. Not
>> sure
>>>> whether there's a problem using python3 vs python2 here?
>>>> 
>>>> Essentially, what Im looking for is how to proceed if I want to
>> use
>>>> modules installed via the pip package manager from guile, and
>> what
>>>> paths
>>>> and imports I need to make, and how I might need to wrap them
>>>> correctly
>>>> in the scheme and python files to invoke a pip package procedure
>>>> from
>>>> guile.
>>>> 
>>>> Best regards,
>>>> David
>>>> 
>>>> On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
>>>>> I'm the author of that lib.
>>>>> 
>>>>> 1)
>>>>> 
>>>>> The main bindings are reachable through (language python module
>>>>> python)
>>>>> 
>>>>> So you could now go ahead and do
>>>>>> (use-modules (language python module python))
>>>>>> ;L python
>>>>> 
>>>>> And you will get a python shell that works quite ok for one
>> liners
>>>>> 
>>>>> 2)
>>>>> 
>>>>> If you write a module and place it in a/b/c.py
>>>>> you can use the classes and functions theirin by
>>>>> 
>>>>> (use-modules (a b c))
>>>>> 
>>>>> 3)
>>>>> you can load a .py file as (i hope this work)
>>>>> (load "a.py")
>>>>> 
>>>>> 4)
>>>>> If you place a module in (language python module a.py) you can
>>>> import
>>>>> ir as a usual mode as
>>>>>> from a import *
>>>>> 
>>>>> The documentation is for the macro framework that enables you to
>>>> work
>>>>> with python classes and idioms like python iteration.
>>>>> 
>>>>> Hope this helps
>>>>> /Stefan
>>>>> 
>>>>> On Sun, Feb 9, 2020 at 6:31 PM david larsson
>>>>> <david.larsson@selfhosted.xyz> wrote:
>>>>> 
>>>>>> Hi everyone,
>>>>>> I am trying to wrap my head around how to use the
>> python-on-guile
>>>>>> library, but Im struggling. Does anyone have example code that
>>>> might
>>>>>> 
>>>>>> help, and which isn't too advanced?
>>>>>> 
>>>>>> All tips and suggestions appreciated!
>>>>>> 
>>>>>> Best regards,
>>>>>> David



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
  2020-02-10 12:13           ` python-on-guile david larsson
  2020-02-10 14:40             ` python-on-guile Stefan Israelsson Tampe
  2020-02-10 14:46             ` python-on-guile Stefan Israelsson Tampe
@ 2020-02-10 20:11             ` Stefan Israelsson Tampe
  2020-02-11  7:17               ` python-on-guile david larsson
  2 siblings, 1 reply; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2020-02-10 20:11 UTC (permalink / raw)
  To: david larsson; +Cc: Stefan Israelsson Tampe <stefan.itampe@gmail.com>

I have now added the bytes constructor that was not working.

To compile from source please try use the git repository at:

https://gitlab.com/python-on-guile/python-on-guile/

see readme for how to compile and what dependencies you have.

Regards
Stefan

On Mon, Feb 10, 2020 at 1:14 PM david larsson <david.larsson@selfhosted.xyz>
wrote:

> On 2020-02-09 21:36, Stefan Israelsson Tampe wrote:
> > in sys that is
> >
> > On Sun, Feb 9, 2020 at 9:36 PM Stefan Israelsson Tampe
> > <stefan.itampe@gmail.com> wrote:
> >
> >> OKey, I changed the values from immutable lists to lists.
> >>
>
> Great!
>
> >> On Sun, Feb 9, 2020 at 9:27 PM Stefan Israelsson Tampe
> >> <stefan.itampe@gmail.com> wrote:
> >>
> >> Note that a lot of things are untested because I'm alone on the
> >> development.
>
> Ok, I understand.
>
> I haven't been able to build a recent version, but if you can share some
> updated instructions, then I could perhaps help out with some occasional
> testing. I have only managed to build from the old commit fc0d7a9 by
> updating the current python-on-guile guix package locally.
>
> >>
> >> netlib is not included, you can test to add the python module file
> >> to a (language python module) directory
>
> What's been working for me so far is only (load "path/to/file.py") and
> (load-compiled "path/to/file.go").
>
> (use-modules (a b c)) did not work for me, except to load modules
> already shipped with python-on-guile repo; (language python module
> python) etc.
>
> >>
> >> I have recently added much more of the python stdlib aka 3.7 but not
> >> all.
> >>
> >> Not sure what you mean by .scm file and .py fle when it comes to
> >> base64
> >> using that module in scheme gives
> >> scheme@(guile-user)> (b64decode (b64encode "abc"))
> >> $2 = b'abc'
> >> scheme@(guile-user)> (b64decode (b64encode #(1 2 3)))
> >> $3 = b'\x01\x02\x03'
> >>
> >> Which return a bytevector if you want a string back you need to
> >> interpret the bytevector back to a string
>
> Im getting weird results when trying to output the base64 representation
> of a string, take btest.py:
>    #import sys
>    import base64
>    def mybmethod(x):
>        mybytes = bytes(x, "utf-8")
>        encodedbytes = base64.b64encode(mybytes)
>        myb64string = str(encodedbytes, "utf-8")
>        return myb64string
>        #print(myb64string)
>    #mybmethod(sys.argv[1])
>
> and assume btest.scm using it with:
>    (add-to-load-path (dirname (current-filename)))
>    (use-modules (language python module python))
>    (load "btest.py")
>    (define-public (mybmethodscm cmdline)
>      (display (mybmethod (cadr cmdline))))
>
> With this it will not work to run the scheme file with
>    guile -e mybmethodscm btest.scm dfasdf
>
> The error I got indicated that btest.py uses the bytes procedure from
> within python-on-guile instead of from the python3 base64 lib:
>
> -------------------
>
> In
> /home/user1/VirtualHome/src/code_guile/python-on-guile-test/btest.scm:
>      18:11  4 (mybmethodscm _)
> In btest.py:
>     10:584  3 (_ "dfasdf" . _)
> In oop/pf-objects.scm:
>     584:15  2 (create-object _ _)
>     567:11  1 (the-create-object _ _)
> In language/python/bytes.scm:
>       99:6  0 Exception thrown while printing backtrace:
> Unbound slot in object Error while printing exception.
>
> language/python/bytes.scm:99:6: Wrong number of arguments to #<procedure
> 7f2bab5d4560 at language/python/bytes.scm:92:0 (self) | (self s)>
>
> -------------------
>
> For a moment though, I could run:
>
>     guile -e mybmethodscm btest.scm dfasdf | rev | base64 -d | rev
>     # gives: dfasdf
>
> which was also strange.
>
> >>
> >> modules are a bit difficult as I use the guile module system and the
> >> python modules are different.
> >> So nested modules needs some work. The best is to test and see.
>
> Ok, got it!
>
> >>
> >> I will look into the sys thingies
> >>
> >> Regards
> >> Stefan
> >>
> >> On Sun, Feb 9, 2020 at 8:40 PM david larsson
> >> <david.larsson@selfhosted.xyz> wrote:
> >> Thanks for your explanations, but unfortunately I still can't figure
> >> out
> >> how to use this except in the simplest of cases.
> >>
> >> I am using the guix package python-on-guile 0.1.0-3.00a51a2 - maybe
> >> thats outdated?
> >>
> >> The simple things I have managed to do, are like:
> >>
> >> (add-to-load-path (dirname (current-filename)))
> >> (load-compiled python-test.go)
> >>
> >> where python-test.go is compiled with:
> >>
> >> guild compile python-test.py --output=python-test.go
> >> --from=python
> >>
> >> and contains simple things, like:
> >>
> >> f(s):
> >> a = s + 1
> >> return a
> >>
> >> but if I add statements to python-test.py like:
> >>
> >> import netaddr
> >> def myfun(a)
> >> <something using netaddr>
> >>
> >> (netaddr is a module installed via: pip3 install --user netaddr)
> >>
> >> I receive an error about not finding the module.
> >>
> >> I am able to add only the modules which exist in the python-on-guile
> >>
> >> repo, like:
> >>
> >> import sys
> >> import base64
> >>
> >> but Im getting errors, for example Im not able to use things from
> >> sys,
> >> like:
> >>
> >> sys.path.append(<somepath>)
> >> sys.path.insert(0, <somepath>)
> >>
> >> I was able to use some things from base64 but I only received weird
> >> results when converting between bytevectors and strings between the
> >> .scm
> >> file and .py file. What works fine using python3 python-test.py do
> >> not
> >> usually work when passing either a bytevector or string to the same
> >> go-compiled file from the .scm file using the python-code. Not sure
> >> whether there's a problem using python3 vs python2 here?
> >>
> >> Essentially, what Im looking for is how to proceed if I want to use
> >> modules installed via the pip package manager from guile, and what
> >> paths
> >> and imports I need to make, and how I might need to wrap them
> >> correctly
> >> in the scheme and python files to invoke a pip package procedure
> >> from
> >> guile.
> >>
> >> Best regards,
> >> David
> >>
> >> On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
> >>> I'm the author of that lib.
> >>>
> >>> 1)
> >>>
> >>> The main bindings are reachable through (language python module
> >>> python)
> >>>
> >>> So you could now go ahead and do
> >>>> (use-modules (language python module python))
> >>>> ;L python
> >>>
> >>> And you will get a python shell that works quite ok for one liners
> >>>
> >>> 2)
> >>>
> >>> If you write a module and place it in a/b/c.py
> >>> you can use the classes and functions theirin by
> >>>
> >>> (use-modules (a b c))
> >>>
> >>> 3)
> >>> you can load a .py file as (i hope this work)
> >>> (load "a.py")
> >>>
> >>> 4)
> >>> If you place a module in (language python module a.py) you can
> >> import
> >>> ir as a usual mode as
> >>>> from a import *
> >>>
> >>> The documentation is for the macro framework that enables you to
> >> work
> >>> with python classes and idioms like python iteration.
> >>>
> >>> Hope this helps
> >>> /Stefan
> >>>
> >>> On Sun, Feb 9, 2020 at 6:31 PM david larsson
> >>> <david.larsson@selfhosted.xyz> wrote:
> >>>
> >>>> Hi everyone,
> >>>> I am trying to wrap my head around how to use the python-on-guile
> >>>> library, but Im struggling. Does anyone have example code that
> >> might
> >>>>
> >>>> help, and which isn't too advanced?
> >>>>
> >>>> All tips and suggestions appreciated!
> >>>>
> >>>> Best regards,
> >>>> David
>
>


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
  2020-02-10 12:13           ` python-on-guile david larsson
  2020-02-10 14:40             ` python-on-guile Stefan Israelsson Tampe
@ 2020-02-10 14:46             ` Stefan Israelsson Tampe
  2020-02-10 20:11             ` python-on-guile Stefan Israelsson Tampe
  2 siblings, 0 replies; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2020-02-10 14:46 UTC (permalink / raw)
  To: david larsson; +Cc: Stefan Israelsson Tampe <stefan.itampe@gmail.com>

>Im getting weird results when trying to output the base64 representation
>>of a string, take btest.py:
 >  #import sys
>   import base64
>   def mybmethod(x):
>       mybytes = bytes(x, "utf-8")
>       encodedbytes = base64.b64encode(mybytes)
>       myb64string = str(encodedbytes, "utf-8")
>       return myb64string
>       #print(myb64string)
>   #mybmethod(sys.argv[1])


str(x,'utf-8') is supported but not bytes(x,'uft-8'). try to use
x.encode('utf-8') in stead


On Mon, Feb 10, 2020 at 1:14 PM david larsson <david.larsson@selfhosted.xyz>
wrote:

> On 2020-02-09 21:36, Stefan Israelsson Tampe wrote:
> > in sys that is
> >
> > On Sun, Feb 9, 2020 at 9:36 PM Stefan Israelsson Tampe
> > <stefan.itampe@gmail.com> wrote:
> >
> >> OKey, I changed the values from immutable lists to lists.
> >>
>
> Great!
>
> >> On Sun, Feb 9, 2020 at 9:27 PM Stefan Israelsson Tampe
> >> <stefan.itampe@gmail.com> wrote:
> >>
> >> Note that a lot of things are untested because I'm alone on the
> >> development.
>
> Ok, I understand.
>
> I haven't been able to build a recent version, but if you can share some
> updated instructions, then I could perhaps help out with some occasional
> testing. I have only managed to build from the old commit fc0d7a9 by
> updating the current python-on-guile guix package locally.
>
> >>
> >> netlib is not included, you can test to add the python module file
> >> to a (language python module) directory
>
> What's been working for me so far is only (load "path/to/file.py") and
> (load-compiled "path/to/file.go").
>
> (use-modules (a b c)) did not work for me, except to load modules
> already shipped with python-on-guile repo; (language python module
> python) etc.
>
> >>
> >> I have recently added much more of the python stdlib aka 3.7 but not
> >> all.
> >>
> >> Not sure what you mean by .scm file and .py fle when it comes to
> >> base64
> >> using that module in scheme gives
> >> scheme@(guile-user)> (b64decode (b64encode "abc"))
> >> $2 = b'abc'
> >> scheme@(guile-user)> (b64decode (b64encode #(1 2 3)))
> >> $3 = b'\x01\x02\x03'
> >>
> >> Which return a bytevector if you want a string back you need to
> >> interpret the bytevector back to a string
>
> Im getting weird results when trying to output the base64 representation
> of a string, take btest.py:
>    #import sys
>    import base64
>    def mybmethod(x):
>        mybytes = bytes(x, "utf-8")
>        encodedbytes = base64.b64encode(mybytes)
>        myb64string = str(encodedbytes, "utf-8")
>        return myb64string
>        #print(myb64string)
>    #mybmethod(sys.argv[1])
>
> and assume btest.scm using it with:
>    (add-to-load-path (dirname (current-filename)))
>    (use-modules (language python module python))
>    (load "btest.py")
>    (define-public (mybmethodscm cmdline)
>      (display (mybmethod (cadr cmdline))))
>
> With this it will not work to run the scheme file with
>    guile -e mybmethodscm btest.scm dfasdf
>
> The error I got indicated that btest.py uses the bytes procedure from
> within python-on-guile instead of from the python3 base64 lib:
>
> -------------------
>
> In
> /home/user1/VirtualHome/src/code_guile/python-on-guile-test/btest.scm:
>      18:11  4 (mybmethodscm _)
> In btest.py:
>     10:584  3 (_ "dfasdf" . _)
> In oop/pf-objects.scm:
>     584:15  2 (create-object _ _)
>     567:11  1 (the-create-object _ _)
> In language/python/bytes.scm:
>       99:6  0 Exception thrown while printing backtrace:
> Unbound slot in object Error while printing exception.
>
> language/python/bytes.scm:99:6: Wrong number of arguments to #<procedure
> 7f2bab5d4560 at language/python/bytes.scm:92:0 (self) | (self s)>
>
> -------------------
>
> For a moment though, I could run:
>
>     guile -e mybmethodscm btest.scm dfasdf | rev | base64 -d | rev
>     # gives: dfasdf
>
> which was also strange.
>
> >>
> >> modules are a bit difficult as I use the guile module system and the
> >> python modules are different.
> >> So nested modules needs some work. The best is to test and see.
>
> Ok, got it!
>
> >>
> >> I will look into the sys thingies
> >>
> >> Regards
> >> Stefan
> >>
> >> On Sun, Feb 9, 2020 at 8:40 PM david larsson
> >> <david.larsson@selfhosted.xyz> wrote:
> >> Thanks for your explanations, but unfortunately I still can't figure
> >> out
> >> how to use this except in the simplest of cases.
> >>
> >> I am using the guix package python-on-guile 0.1.0-3.00a51a2 - maybe
> >> thats outdated?
> >>
> >> The simple things I have managed to do, are like:
> >>
> >> (add-to-load-path (dirname (current-filename)))
> >> (load-compiled python-test.go)
> >>
> >> where python-test.go is compiled with:
> >>
> >> guild compile python-test.py --output=python-test.go
> >> --from=python
> >>
> >> and contains simple things, like:
> >>
> >> f(s):
> >> a = s + 1
> >> return a
> >>
> >> but if I add statements to python-test.py like:
> >>
> >> import netaddr
> >> def myfun(a)
> >> <something using netaddr>
> >>
> >> (netaddr is a module installed via: pip3 install --user netaddr)
> >>
> >> I receive an error about not finding the module.
> >>
> >> I am able to add only the modules which exist in the python-on-guile
> >>
> >> repo, like:
> >>
> >> import sys
> >> import base64
> >>
> >> but Im getting errors, for example Im not able to use things from
> >> sys,
> >> like:
> >>
> >> sys.path.append(<somepath>)
> >> sys.path.insert(0, <somepath>)
> >>
> >> I was able to use some things from base64 but I only received weird
> >> results when converting between bytevectors and strings between the
> >> .scm
> >> file and .py file. What works fine using python3 python-test.py do
> >> not
> >> usually work when passing either a bytevector or string to the same
> >> go-compiled file from the .scm file using the python-code. Not sure
> >> whether there's a problem using python3 vs python2 here?
> >>
> >> Essentially, what Im looking for is how to proceed if I want to use
> >> modules installed via the pip package manager from guile, and what
> >> paths
> >> and imports I need to make, and how I might need to wrap them
> >> correctly
> >> in the scheme and python files to invoke a pip package procedure
> >> from
> >> guile.
> >>
> >> Best regards,
> >> David
> >>
> >> On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
> >>> I'm the author of that lib.
> >>>
> >>> 1)
> >>>
> >>> The main bindings are reachable through (language python module
> >>> python)
> >>>
> >>> So you could now go ahead and do
> >>>> (use-modules (language python module python))
> >>>> ;L python
> >>>
> >>> And you will get a python shell that works quite ok for one liners
> >>>
> >>> 2)
> >>>
> >>> If you write a module and place it in a/b/c.py
> >>> you can use the classes and functions theirin by
> >>>
> >>> (use-modules (a b c))
> >>>
> >>> 3)
> >>> you can load a .py file as (i hope this work)
> >>> (load "a.py")
> >>>
> >>> 4)
> >>> If you place a module in (language python module a.py) you can
> >> import
> >>> ir as a usual mode as
> >>>> from a import *
> >>>
> >>> The documentation is for the macro framework that enables you to
> >> work
> >>> with python classes and idioms like python iteration.
> >>>
> >>> Hope this helps
> >>> /Stefan
> >>>
> >>> On Sun, Feb 9, 2020 at 6:31 PM david larsson
> >>> <david.larsson@selfhosted.xyz> wrote:
> >>>
> >>>> Hi everyone,
> >>>> I am trying to wrap my head around how to use the python-on-guile
> >>>> library, but Im struggling. Does anyone have example code that
> >> might
> >>>>
> >>>> help, and which isn't too advanced?
> >>>>
> >>>> All tips and suggestions appreciated!
> >>>>
> >>>> Best regards,
> >>>> David
>
>


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
  2020-02-10 12:13           ` python-on-guile david larsson
@ 2020-02-10 14:40             ` Stefan Israelsson Tampe
  2020-02-10 14:46             ` python-on-guile Stefan Israelsson Tampe
  2020-02-10 20:11             ` python-on-guile Stefan Israelsson Tampe
  2 siblings, 0 replies; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2020-02-10 14:40 UTC (permalink / raw)
  To: david larsson; +Cc: Stefan Israelsson Tampe <stefan.itampe@gmail.com>

> (use-modules (a b c)) did not work for me, except to load modules
> already shipped with python-on-guile repo; (language python module
> python) etc.

You need to specify a root to search for for guile modules, try using e.g.
https://www.gnu.org/software/guile/manual/html_node/Load-Paths.html

/Stefan

On Mon, Feb 10, 2020 at 1:14 PM david larsson <david.larsson@selfhosted.xyz>
wrote:

> On 2020-02-09 21:36, Stefan Israelsson Tampe wrote:
> > in sys that is
> >
> > On Sun, Feb 9, 2020 at 9:36 PM Stefan Israelsson Tampe
> > <stefan.itampe@gmail.com> wrote:
> >
> >> OKey, I changed the values from immutable lists to lists.
> >>
>
> Great!
>
> >> On Sun, Feb 9, 2020 at 9:27 PM Stefan Israelsson Tampe
> >> <stefan.itampe@gmail.com> wrote:
> >>
> >> Note that a lot of things are untested because I'm alone on the
> >> development.
>
> Ok, I understand.
>
> I haven't been able to build a recent version, but if you can share some
> updated instructions, then I could perhaps help out with some occasional
> testing. I have only managed to build from the old commit fc0d7a9 by
> updating the current python-on-guile guix package locally.
>
> >>
> >> netlib is not included, you can test to add the python module file
> >> to a (language python module) directory
>
> What's been working for me so far is only (load "path/to/file.py") and
> (load-compiled "path/to/file.go").
>
> (use-modules (a b c)) did not work for me, except to load modules
> already shipped with python-on-guile repo; (language python module
> python) etc.
>
> >>
> >> I have recently added much more of the python stdlib aka 3.7 but not
> >> all.
> >>
> >> Not sure what you mean by .scm file and .py fle when it comes to
> >> base64
> >> using that module in scheme gives
> >> scheme@(guile-user)> (b64decode (b64encode "abc"))
> >> $2 = b'abc'
> >> scheme@(guile-user)> (b64decode (b64encode #(1 2 3)))
> >> $3 = b'\x01\x02\x03'
> >>
> >> Which return a bytevector if you want a string back you need to
> >> interpret the bytevector back to a string
>
> Im getting weird results when trying to output the base64 representation
> of a string, take btest.py:
>    #import sys
>    import base64
>    def mybmethod(x):
>        mybytes = bytes(x, "utf-8")
>        encodedbytes = base64.b64encode(mybytes)
>        myb64string = str(encodedbytes, "utf-8")
>        return myb64string
>        #print(myb64string)
>    #mybmethod(sys.argv[1])
>
> and assume btest.scm using it with:
>    (add-to-load-path (dirname (current-filename)))
>    (use-modules (language python module python))
>    (load "btest.py")
>    (define-public (mybmethodscm cmdline)
>      (display (mybmethod (cadr cmdline))))
>
> With this it will not work to run the scheme file with
>    guile -e mybmethodscm btest.scm dfasdf
>
> The error I got indicated that btest.py uses the bytes procedure from
> within python-on-guile instead of from the python3 base64 lib:
>
> -------------------
>
> In
> /home/user1/VirtualHome/src/code_guile/python-on-guile-test/btest.scm:
>      18:11  4 (mybmethodscm _)
> In btest.py:
>     10:584  3 (_ "dfasdf" . _)
> In oop/pf-objects.scm:
>     584:15  2 (create-object _ _)
>     567:11  1 (the-create-object _ _)
> In language/python/bytes.scm:
>       99:6  0 Exception thrown while printing backtrace:
> Unbound slot in object Error while printing exception.
>
> language/python/bytes.scm:99:6: Wrong number of arguments to #<procedure
> 7f2bab5d4560 at language/python/bytes.scm:92:0 (self) | (self s)>
>
> -------------------
>
> For a moment though, I could run:
>
>     guile -e mybmethodscm btest.scm dfasdf | rev | base64 -d | rev
>     # gives: dfasdf
>
> which was also strange.
>
> >>
> >> modules are a bit difficult as I use the guile module system and the
> >> python modules are different.
> >> So nested modules needs some work. The best is to test and see.
>
> Ok, got it!
>
> >>
> >> I will look into the sys thingies
> >>
> >> Regards
> >> Stefan
> >>
> >> On Sun, Feb 9, 2020 at 8:40 PM david larsson
> >> <david.larsson@selfhosted.xyz> wrote:
> >> Thanks for your explanations, but unfortunately I still can't figure
> >> out
> >> how to use this except in the simplest of cases.
> >>
> >> I am using the guix package python-on-guile 0.1.0-3.00a51a2 - maybe
> >> thats outdated?
> >>
> >> The simple things I have managed to do, are like:
> >>
> >> (add-to-load-path (dirname (current-filename)))
> >> (load-compiled python-test.go)
> >>
> >> where python-test.go is compiled with:
> >>
> >> guild compile python-test.py --output=python-test.go
> >> --from=python
> >>
> >> and contains simple things, like:
> >>
> >> f(s):
> >> a = s + 1
> >> return a
> >>
> >> but if I add statements to python-test.py like:
> >>
> >> import netaddr
> >> def myfun(a)
> >> <something using netaddr>
> >>
> >> (netaddr is a module installed via: pip3 install --user netaddr)
> >>
> >> I receive an error about not finding the module.
> >>
> >> I am able to add only the modules which exist in the python-on-guile
> >>
> >> repo, like:
> >>
> >> import sys
> >> import base64
> >>
> >> but Im getting errors, for example Im not able to use things from
> >> sys,
> >> like:
> >>
> >> sys.path.append(<somepath>)
> >> sys.path.insert(0, <somepath>)
> >>
> >> I was able to use some things from base64 but I only received weird
> >> results when converting between bytevectors and strings between the
> >> .scm
> >> file and .py file. What works fine using python3 python-test.py do
> >> not
> >> usually work when passing either a bytevector or string to the same
> >> go-compiled file from the .scm file using the python-code. Not sure
> >> whether there's a problem using python3 vs python2 here?
> >>
> >> Essentially, what Im looking for is how to proceed if I want to use
> >> modules installed via the pip package manager from guile, and what
> >> paths
> >> and imports I need to make, and how I might need to wrap them
> >> correctly
> >> in the scheme and python files to invoke a pip package procedure
> >> from
> >> guile.
> >>
> >> Best regards,
> >> David
> >>
> >> On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
> >>> I'm the author of that lib.
> >>>
> >>> 1)
> >>>
> >>> The main bindings are reachable through (language python module
> >>> python)
> >>>
> >>> So you could now go ahead and do
> >>>> (use-modules (language python module python))
> >>>> ;L python
> >>>
> >>> And you will get a python shell that works quite ok for one liners
> >>>
> >>> 2)
> >>>
> >>> If you write a module and place it in a/b/c.py
> >>> you can use the classes and functions theirin by
> >>>
> >>> (use-modules (a b c))
> >>>
> >>> 3)
> >>> you can load a .py file as (i hope this work)
> >>> (load "a.py")
> >>>
> >>> 4)
> >>> If you place a module in (language python module a.py) you can
> >> import
> >>> ir as a usual mode as
> >>>> from a import *
> >>>
> >>> The documentation is for the macro framework that enables you to
> >> work
> >>> with python classes and idioms like python iteration.
> >>>
> >>> Hope this helps
> >>> /Stefan
> >>>
> >>> On Sun, Feb 9, 2020 at 6:31 PM david larsson
> >>> <david.larsson@selfhosted.xyz> wrote:
> >>>
> >>>> Hi everyone,
> >>>> I am trying to wrap my head around how to use the python-on-guile
> >>>> library, but Im struggling. Does anyone have example code that
> >> might
> >>>>
> >>>> help, and which isn't too advanced?
> >>>>
> >>>> All tips and suggestions appreciated!
> >>>>
> >>>> Best regards,
> >>>> David
>
>


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
       [not found]         ` <CAGua6m3vTY=hk8QaEoKUvFwPsm7N-uatMV1KyvgdAyKS4Gjh9g@mail.gmail.com>
@ 2020-02-10 12:13           ` david larsson
  2020-02-10 14:40             ` python-on-guile Stefan Israelsson Tampe
                               ` (2 more replies)
  0 siblings, 3 replies; 38+ messages in thread
From: david larsson @ 2020-02-10 12:13 UTC (permalink / raw)
  To: Stefan Israelsson Tampe <stefan.itampe@gmail.com>

On 2020-02-09 21:36, Stefan Israelsson Tampe wrote:
> in sys that is
> 
> On Sun, Feb 9, 2020 at 9:36 PM Stefan Israelsson Tampe
> <stefan.itampe@gmail.com> wrote:
> 
>> OKey, I changed the values from immutable lists to lists.
>> 

Great!

>> On Sun, Feb 9, 2020 at 9:27 PM Stefan Israelsson Tampe
>> <stefan.itampe@gmail.com> wrote:
>> 
>> Note that a lot of things are untested because I'm alone on the
>> development.

Ok, I understand.

I haven't been able to build a recent version, but if you can share some 
updated instructions, then I could perhaps help out with some occasional 
testing. I have only managed to build from the old commit fc0d7a9 by 
updating the current python-on-guile guix package locally.

>> 
>> netlib is not included, you can test to add the python module file
>> to a (language python module) directory

What's been working for me so far is only (load "path/to/file.py") and 
(load-compiled "path/to/file.go").

(use-modules (a b c)) did not work for me, except to load modules 
already shipped with python-on-guile repo; (language python module 
python) etc.

>> 
>> I have recently added much more of the python stdlib aka 3.7 but not
>> all.
>> 
>> Not sure what you mean by .scm file and .py fle when it comes to
>> base64
>> using that module in scheme gives
>> scheme@(guile-user)> (b64decode (b64encode "abc"))
>> $2 = b'abc'
>> scheme@(guile-user)> (b64decode (b64encode #(1 2 3)))
>> $3 = b'\x01\x02\x03'
>> 
>> Which return a bytevector if you want a string back you need to
>> interpret the bytevector back to a string

Im getting weird results when trying to output the base64 representation 
of a string, take btest.py:
   #import sys
   import base64
   def mybmethod(x):
       mybytes = bytes(x, "utf-8")
       encodedbytes = base64.b64encode(mybytes)
       myb64string = str(encodedbytes, "utf-8")
       return myb64string
       #print(myb64string)
   #mybmethod(sys.argv[1])

and assume btest.scm using it with:
   (add-to-load-path (dirname (current-filename)))
   (use-modules (language python module python))
   (load "btest.py")
   (define-public (mybmethodscm cmdline)
     (display (mybmethod (cadr cmdline))))

With this it will not work to run the scheme file with
   guile -e mybmethodscm btest.scm dfasdf

The error I got indicated that btest.py uses the bytes procedure from 
within python-on-guile instead of from the python3 base64 lib:

-------------------

In 
/home/user1/VirtualHome/src/code_guile/python-on-guile-test/btest.scm:
     18:11  4 (mybmethodscm _)
In btest.py:
    10:584  3 (_ "dfasdf" . _)
In oop/pf-objects.scm:
    584:15  2 (create-object _ _)
    567:11  1 (the-create-object _ _)
In language/python/bytes.scm:
      99:6  0 Exception thrown while printing backtrace:
Unbound slot in object Error while printing exception.

language/python/bytes.scm:99:6: Wrong number of arguments to #<procedure 
7f2bab5d4560 at language/python/bytes.scm:92:0 (self) | (self s)>

-------------------

For a moment though, I could run:

    guile -e mybmethodscm btest.scm dfasdf | rev | base64 -d | rev
    # gives: dfasdf

which was also strange.

>> 
>> modules are a bit difficult as I use the guile module system and the
>> python modules are different.
>> So nested modules needs some work. The best is to test and see.

Ok, got it!

>> 
>> I will look into the sys thingies
>> 
>> Regards
>> Stefan
>> 
>> On Sun, Feb 9, 2020 at 8:40 PM david larsson
>> <david.larsson@selfhosted.xyz> wrote:
>> Thanks for your explanations, but unfortunately I still can't figure
>> out
>> how to use this except in the simplest of cases.
>> 
>> I am using the guix package python-on-guile 0.1.0-3.00a51a2 - maybe
>> thats outdated?
>> 
>> The simple things I have managed to do, are like:
>> 
>> (add-to-load-path (dirname (current-filename)))
>> (load-compiled python-test.go)
>> 
>> where python-test.go is compiled with:
>> 
>> guild compile python-test.py --output=python-test.go
>> --from=python
>> 
>> and contains simple things, like:
>> 
>> f(s):
>> a = s + 1
>> return a
>> 
>> but if I add statements to python-test.py like:
>> 
>> import netaddr
>> def myfun(a)
>> <something using netaddr>
>> 
>> (netaddr is a module installed via: pip3 install --user netaddr)
>> 
>> I receive an error about not finding the module.
>> 
>> I am able to add only the modules which exist in the python-on-guile
>> 
>> repo, like:
>> 
>> import sys
>> import base64
>> 
>> but Im getting errors, for example Im not able to use things from
>> sys,
>> like:
>> 
>> sys.path.append(<somepath>)
>> sys.path.insert(0, <somepath>)
>> 
>> I was able to use some things from base64 but I only received weird
>> results when converting between bytevectors and strings between the
>> .scm
>> file and .py file. What works fine using python3 python-test.py do
>> not
>> usually work when passing either a bytevector or string to the same
>> go-compiled file from the .scm file using the python-code. Not sure
>> whether there's a problem using python3 vs python2 here?
>> 
>> Essentially, what Im looking for is how to proceed if I want to use
>> modules installed via the pip package manager from guile, and what
>> paths
>> and imports I need to make, and how I might need to wrap them
>> correctly
>> in the scheme and python files to invoke a pip package procedure
>> from
>> guile.
>> 
>> Best regards,
>> David
>> 
>> On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
>>> I'm the author of that lib.
>>> 
>>> 1)
>>> 
>>> The main bindings are reachable through (language python module
>>> python)
>>> 
>>> So you could now go ahead and do
>>>> (use-modules (language python module python))
>>>> ;L python
>>> 
>>> And you will get a python shell that works quite ok for one liners
>>> 
>>> 2)
>>> 
>>> If you write a module and place it in a/b/c.py
>>> you can use the classes and functions theirin by
>>> 
>>> (use-modules (a b c))
>>> 
>>> 3)
>>> you can load a .py file as (i hope this work)
>>> (load "a.py")
>>> 
>>> 4)
>>> If you place a module in (language python module a.py) you can
>> import
>>> ir as a usual mode as
>>>> from a import *
>>> 
>>> The documentation is for the macro framework that enables you to
>> work
>>> with python classes and idioms like python iteration.
>>> 
>>> Hope this helps
>>> /Stefan
>>> 
>>> On Sun, Feb 9, 2020 at 6:31 PM david larsson
>>> <david.larsson@selfhosted.xyz> wrote:
>>> 
>>>> Hi everyone,
>>>> I am trying to wrap my head around how to use the python-on-guile
>>>> library, but Im struggling. Does anyone have example code that
>> might
>>>> 
>>>> help, and which isn't too advanced?
>>>> 
>>>> All tips and suggestions appreciated!
>>>> 
>>>> Best regards,
>>>> David



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
  2020-02-09 17:59 ` python-on-guile Stefan Israelsson Tampe
@ 2020-02-09 19:39   ` david larsson
       [not found]     ` <CAGua6m1aQuwGu4ZRRk9r1Ytao_QjftzCQK5+tb_B4axh-Y3aWg@mail.gmail.com>
  0 siblings, 1 reply; 38+ messages in thread
From: david larsson @ 2020-02-09 19:39 UTC (permalink / raw)
  To: Stefan Israelsson Tampe; +Cc: Guile User

Thanks for your explanations, but unfortunately I still can't figure out 
how to use this except in the simplest of cases.

I am using the guix package python-on-guile 0.1.0-3.00a51a2 - maybe 
thats outdated?


The simple things I have managed to do, are like:

   (add-to-load-path (dirname (current-filename)))
   (load-compiled python-test.go)

where python-test.go is compiled with:

   guild compile python-test.py --output=python-test.go --from=python

and contains simple things, like:

   f(s):
     a = s + 1
     return a

but if I add statements to python-test.py like:

   import netaddr
   def myfun(a)
     <something using netaddr>

(netaddr is a module installed via: pip3 install --user netaddr)

I receive an error about not finding the module.

I am able to add only the modules which exist in the python-on-guile 
repo, like:

   import sys
   import base64

but Im getting errors, for example Im not able to use things from sys, 
like:

   sys.path.append(<somepath>)
   sys.path.insert(0, <somepath>)

I was able to use some things from base64 but I only received weird 
results when converting between bytevectors and strings between the .scm 
file and .py file. What works fine using python3 python-test.py do not 
usually work when passing either a bytevector or string to the same 
go-compiled file from the .scm file using the python-code. Not sure 
whether there's a problem using python3 vs python2 here?

Essentially, what Im looking for is how to proceed if I want to use 
modules installed via the pip package manager from guile, and what paths 
and imports I need to make, and how I might need to wrap them correctly 
in the scheme and python files to invoke a pip package procedure from 
guile.


Best regards,
David

On 2020-02-09 18:59, Stefan Israelsson Tampe wrote:
> I'm the author of that lib.
> 
> 1)
> 
> The main bindings are reachable through (language python module
> python)
> 
> So you could now go ahead and do
>> (use-modules (language python module python))
>> ;L python
> 
> And you will get a python shell that works quite ok for one liners
> 
> 2)
> 
> If you write a module and place it in a/b/c.py
> you can use the classes and functions theirin by
> 
> (use-modules (a b c))
> 
> 3)
> you can load a .py file as (i hope this work)
>   (load "a.py")
> 
> 4)
> If you place a module in (language python module a.py) you can import
> ir as a usual mode as
>> from a import *
> 
> The documentation is for the macro framework that enables you to work
> with python classes and idioms like python iteration.
> 
> Hope this helps
> /Stefan
> 
> On Sun, Feb 9, 2020 at 6:31 PM david larsson
> <david.larsson@selfhosted.xyz> wrote:
> 
>> Hi everyone,
>> I am trying to wrap my head around how to use the python-on-guile
>> library, but Im struggling. Does anyone have example code that might
>> 
>> help, and which isn't too advanced?
>> 
>> All tips and suggestions appreciated!
>> 
>> Best regards,
>> David



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
  2020-02-09 17:30 python-on-guile david larsson
@ 2020-02-09 17:59 ` Stefan Israelsson Tampe
  2020-02-09 19:39   ` python-on-guile david larsson
  0 siblings, 1 reply; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2020-02-09 17:59 UTC (permalink / raw)
  To: david larsson; +Cc: Guile User

I'm the author of that lib.

1)
The main bindings are reachable through (language python module python)

So you could now go ahead and do
> (use-modules (language python module python))
> ;L python

And you will get a python shell that works quite ok for one liners

2)
If you write a module and place it in a/b/c.py
you can use the classes and functions theirin by

(use-modules (a b c))

3)
you can load a .py file as (i hope this work)
  (load "a.py")

4)
If you place a module in (language python module a.py) you can import ir as
a usual mode as
> from a import *

The documentation is for the macro framework that enables you to work with
python classes and idioms like python iteration.

Hope this helps
/Stefan



On Sun, Feb 9, 2020 at 6:31 PM david larsson <david.larsson@selfhosted.xyz>
wrote:

> Hi everyone,
> I am trying to wrap my head around how to use the python-on-guile
> library, but Im struggling. Does anyone have example code that might
> help, and which isn't too advanced?
>
> All tips and suggestions appreciated!
>
> Best regards,
> David
>
>


^ permalink raw reply	[flat|nested] 38+ messages in thread

* python-on-guile
@ 2020-02-09 17:30 david larsson
  2020-02-09 17:59 ` python-on-guile Stefan Israelsson Tampe
  0 siblings, 1 reply; 38+ messages in thread
From: david larsson @ 2020-02-09 17:30 UTC (permalink / raw)
  To: guile-user

Hi everyone,
I am trying to wrap my head around how to use the python-on-guile 
library, but Im struggling. Does anyone have example code that might 
help, and which isn't too advanced?

All tips and suggestions appreciated!

Best regards,
David



^ permalink raw reply	[flat|nested] 38+ messages in thread

* python-on-guile
@ 2019-07-09 17:15 Stefan Israelsson Tampe
  0 siblings, 0 replies; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2019-07-09 17:15 UTC (permalink / raw)
  To: Guile User

Latest developments on python on guile is to make python's generator deep
copyable. This means copying delimited continuations and I'm happy to
acknowledge to a certain degree this works. Both pcomming 3.0 works as well
as current stable 2.4. There is a problem and that is it assumes no data is
put on the stack in raw format. Python's implementation is to set variables
with set! so I expect it to work for python programs. However scheme code
can store stack elements in raw data and hence that optimizartion needs to
be turmed off to be sure. Also if one want to serialize continuations
currently this does not work with the jit function and more work must be
done to assure that it works together with the jit engine.

Note: deep copying of generators is not suported by cpython

see http://c-lambda.se/deep-copy.html for an example

Happy hacking


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
  2019-06-14 18:06 python-on-guile Stefan Israelsson Tampe
  2019-06-22 21:07 ` python-on-guile Arne Babenhauserheide
@ 2019-06-26 18:45 ` Nala Ginrut
  1 sibling, 0 replies; 38+ messages in thread
From: Nala Ginrut @ 2019-06-26 18:45 UTC (permalink / raw)
  To: Stefan Israelsson Tampe; +Cc: Guile User, guile-devel

Thanks for the work! I appreciate it!

On Sat, Jun 15, 2019 at 3:05 AM Stefan Israelsson Tampe
<stefan.itampe@gmail.com> wrote:
>
> python on guile has reached quite far and now compiles a lot of the standard python code base. The speed has not been of importance. Rather to get good coopertion between guile scheme and python programs.
>
> But it also define a scheme interface to the python functionalites and i'm now trying to compile some documentation of this inteface. You can find docs at http://www.c-lambda.se/python-on-guile.
>
> source code is at,
> https://gitlab.com/python-on-guile/python-on-guile/
>
> This is a work in progress.
>
> Happy hacking!!



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: python-on-guile
  2019-06-14 18:06 python-on-guile Stefan Israelsson Tampe
@ 2019-06-22 21:07 ` Arne Babenhauserheide
  2019-06-26 18:45 ` python-on-guile Nala Ginrut
  1 sibling, 0 replies; 38+ messages in thread
From: Arne Babenhauserheide @ 2019-06-22 21:07 UTC (permalink / raw)
  To: guile-devel; +Cc: Guile User

[-- Attachment #1: Type: text/plain, Size: 489 bytes --]


Stefan Israelsson Tampe <stefan.itampe@gmail.com> writes:

> python on guile has reached quite far and now compiles a lot of the
> standard python code base. The speed has not been of importance. Rather to
> get good coopertion between guile scheme and python programs.

That sounds awesome! Thank you for sharing!

> https://gitlab.com/python-on-guile/python-on-guile/
> Happy hacking!!

Happy Hacking!
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1076 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread

* python-on-guile
@ 2019-06-14 18:06 Stefan Israelsson Tampe
  2019-06-22 21:07 ` python-on-guile Arne Babenhauserheide
  2019-06-26 18:45 ` python-on-guile Nala Ginrut
  0 siblings, 2 replies; 38+ messages in thread
From: Stefan Israelsson Tampe @ 2019-06-14 18:06 UTC (permalink / raw)
  To: guile-devel, Guile User

[-- Attachment #1: Type: text/plain, Size: 519 bytes --]

python on guile has reached quite far and now compiles a lot of the
standard python code base. The speed has not been of importance. Rather to
get good coopertion between guile scheme and python programs.

But it also define a scheme interface to the python functionalites and i'm
now trying to compile some documentation of this inteface. You can find
docs at http://www.c-lambda.se/python-on-guile.

source code is at,
https://gitlab.com/python-on-guile/python-on-guile/

This is a work in progress.

Happy hacking!!

[-- Attachment #2: Type: text/html, Size: 775 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2021-04-27 12:29 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23 15:00 Python-on-guile Mikael Djurfeldt
2021-04-23 20:35 ` Python-on-guile Zelphir Kaltstahl
2021-04-23 20:41 ` Python-on-guile Linus Björnstam
2021-04-23 21:04 ` Python-on-guile Matt Wette
2021-04-24  9:43   ` Python-on-guile Mikael Djurfeldt
2021-04-24 10:04 ` Python-on-guile Mikael Djurfeldt
2021-04-24 11:26   ` Python-on-guile Stefan Israelsson Tampe
2021-04-24 12:59     ` Python-on-guile Stefan Israelsson Tampe
2021-04-24 14:41       ` Python-on-guile Stefan Israelsson Tampe
2021-04-24 15:19         ` Python-on-guile Stefan Israelsson Tampe
2021-04-25  8:20           ` Python-on-guile Mikael Djurfeldt
2021-04-25 10:21             ` Python-on-guile Stefan Israelsson Tampe
2021-04-25  8:46           ` Python-on-guile Stefan Israelsson Tampe
2021-04-25 10:54       ` Python-on-guile Dr. Arne Babenhauserheide
2021-04-25 11:54         ` Python-on-guile Vivien Kraus via General Guile related discussions
2021-04-25 10:18 ` Python-on-guile Stefan Israelsson Tampe
2021-04-27 12:29 ` Python-on-guile Nala Ginrut
  -- strict thread matches above, loose matches on Subject: below --
2020-02-09 17:30 python-on-guile david larsson
2020-02-09 17:59 ` python-on-guile Stefan Israelsson Tampe
2020-02-09 19:39   ` python-on-guile david larsson
     [not found]     ` <CAGua6m1aQuwGu4ZRRk9r1Ytao_QjftzCQK5+tb_B4axh-Y3aWg@mail.gmail.com>
     [not found]       ` <CAGua6m1VFHsaid+CGUN==3AvXqZTZUO8xbOSh3r4xNVTAik79g@mail.gmail.com>
     [not found]         ` <CAGua6m3vTY=hk8QaEoKUvFwPsm7N-uatMV1KyvgdAyKS4Gjh9g@mail.gmail.com>
2020-02-10 12:13           ` python-on-guile david larsson
2020-02-10 14:40             ` python-on-guile Stefan Israelsson Tampe
2020-02-10 14:46             ` python-on-guile Stefan Israelsson Tampe
2020-02-10 20:11             ` python-on-guile Stefan Israelsson Tampe
2020-02-11  7:17               ` python-on-guile david larsson
2020-02-11 10:44                 ` python-on-guile Stefan Israelsson Tampe
2020-02-11 20:57                 ` python-on-guile Stefan Israelsson Tampe
2020-02-12  9:18                   ` python-on-guile david larsson
2020-02-12  9:59                     ` python-on-guile Stefan Israelsson Tampe
2020-02-12 15:26                       ` python-on-guile david larsson
     [not found]                         ` <CAGua6m2SP2RZ1Ok5bG2xmoHGanmRUrfaG34yY7P8=AWs0fXw2g@mail.gmail.com>
2020-02-12 19:47                           ` python-on-guile david larsson
     [not found]                             ` <CAGua6m1rcNZT_15LN=dWRb66E93UyLDFfdkaJjmyWYerWE9Jpg@mail.gmail.com>
     [not found]                               ` <46dbd813788cc3d1dc0b994106c8a528@selfhosted.xyz>
     [not found]                                 ` <CAGua6m12ytkdDcHj+PEx615qCzaXPB4P+u-DCqWQexuRo28BWA@mail.gmail.com>
2020-02-13  7:30                                   ` python-on-guile david larsson
     [not found]                                     ` <CAGua6m2+hEpGf8Z+CfyO+-mKH4sQF-mVb7YS1=+88hF2bRkjPw@mail.gmail.com>
2020-02-18 10:45                                       ` python-on-guile david larsson
     [not found]                                         ` <CAGua6m0d=L9b9MEMYekX0tL0PO3k+ZR+LP=7YYQojzr0VYdkmw@mail.gmail.com>
2020-02-19  7:30                                           ` python-on-guile david larsson
2019-07-09 17:15 python-on-guile Stefan Israelsson Tampe
2019-06-14 18:06 python-on-guile Stefan Israelsson Tampe
2019-06-22 21:07 ` python-on-guile Arne Babenhauserheide
2019-06-26 18:45 ` python-on-guile Nala Ginrut

unofficial mirror of guile-user@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-user/0 guile-user/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-user guile-user/ https://yhetil.org/guile-user \
		guile-user@gnu.org
	public-inbox-index guile-user

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.user
	nntp://news.gmane.io/gmane.lisp.guile.user


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git