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.lars...@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