Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    pvance
    @phillvancejr
    Also as for wasm, Grumpy doesn't allow for using syscall/js and the wasm copiler flags on a Grumpy transpiled go file?
    pvance
    @phillvancejr
    Or rather importing syscall/js into your python file then transpiling that with grumpc and compiling that using the go wasm flags
    pvance
    @phillvancejr
    I was able to run my grumpc transpiled code by making changes to the file generated by grumpc. I had to change the package name to main and add a main function that used πg.RunMain(Code). Maybe I'm missing some option or flag to make this the default behavior? I also updated my issue with the changes
    Alan Justino da Silva
    @alanjds

    Also as for wasm, Grumpy doesn't allow for using syscall/js and the wasm copiler flags on a Grumpy transpiled go file?

    Grumpy used something not available to be compiled on wasm, IIRC. So, this is for the future I guess

    I was able to run my grumpc transpiled code by making changes to the file generated by grumpc. I had to change the package name to main and add a main function that used πg.RunMain(Code). Maybe I'm missing some option or flag to make this the default behavior? I also updated my issue with the changes

    For simple one-file module it can work. For complex ones, you can run 1st time via grumpy -v debug run --keep-main myfile.py and the last logs do show the produced main and the GOPATH you need to use

    Hope this helps you.
    pvance
    @phillvancejr
    Ah I see now. Is there currently a built in way to bring this main.go file with all its dependencies into the current folder instead of the temp one and set the gopath appropriately?
    thank you for your help by the way!
    pvance
    @phillvancejr

    Got it! Looks like I just need to use

    grumpy run --go-action build hello.py

    The --go-action build was the key!

    Maybe grumpy build -o hello hello.py will be possible in the future
    Thanks a lot for your help Alan!
    Alan Justino da Silva
    @alanjds
    You are welcome

    Ah I see now. Is there currently a built in way to bring this main.go file with all its dependencies into the current folder instead of the temp one and set the gopath appropriately?

    This would break the __pycache__ magic a lot, leading to lengthy re-transpilations. But is possible

    Maybe grumpy build -o hello hello.py will be possible in the future

    Hehe. PRs are welcome ;)

    pvance
    @phillvancejr
    I will try implementing it in a pull :). Can we still import go packages into the python file using go ? I tried from go.net.http import ListenAndServe, RedirectHandler but I get the error: No moduled named go
    Alan Justino da Silva
    @alanjds
    Yes. You can see usage on grumpy-runtime-src/lib/math.py for example
    See also time.py: from '__go__/time' import Local, Now
    This is not standard Python, so I suggest you to create a _mymodule.py and import it from mymodule.py. Then on the _ one only you use the non-standard stuff.
    pvance
    @phillvancejr
    thanks!
    Miguel Filipe
    @msf
    hi! anyone used grumpy to "just" translate python to Go code ?
    Alan Justino da Silva
    @alanjds
    That is the whole plan @msf. But the result is "Bad Go" code.
    Alan Justino da Silva
    @alanjds

    Python is a language that
    1) Is way higher level than Go;
    2) Have exceptions.

    Grumpy translates a 4-line simple Python program into a 25+ lines program in Go with the same behaviors. You can get down to 4 Go lines, losing some behaviors. Grumpy do not does that.

    Miguel Filipe
    @msf
    @alanjds I thought it was mostly a "runtime" in Go that would compile and then run that Go code.. not really focussed on being a "translator" per se
    and yes, I understand I would get bad Go.
    Alan Justino da Silva
    @alanjds
    So you understood right :)
    There is a "stdlib" wrote mostly in Go that your Py code uses when translated to Go
    Pure-python libs like StringIO are just translated to Go. C-based ones are rewrote in Go or Python. "Primitives" like int, str, unicode are directly wrote in Go, and this is the Grumpy Runtime
    there is also the Grumpy Transpiler, that combines your Py->Go code with the Runtime, and calls Go to compile+run this thing
    On PyPI you can find grumpy-runtime and grumpy-tools. The transpiler lives in grumpy-tools.
    Miguel Filipe
    @msf
    ahh, so if I wanted to try and transpile some py modules with some of my code, I should look into grumpy-tools ?
    Alan Justino da Silva
    @alanjds
    Yes and no. You need to install only grumpy-tools and this can translate Py code. But such code relies on grumpy-runtime libs.
    So I advise to install grumpy-runtime as it already installs grumpy-tools
    You can gumpy transpile script.py and grumpy run script.py this way
    randiaz95
    @randiaz95
    Hi
    randiaz95
    @randiaz95
    Seems like py to go compilers are in python2 not 3 yet :D
    Alan Justino da Silva
    @alanjds
    Yes. And the resulting code is not faster for now, for single-threaded applications
    Kyle
    @zsmatrix62
    does anyone know that how to use grpc in angularDart?
    we use dart in flutter but seems that cannot be compiled in AngularDart ... thakns.
    kannanjmc
    @kannanjmc
    HI
    how to install grumpy
    in mac
    Alan Justino da Silva
    @alanjds
    Hi, @kannanjmc. The easiest way is to pip install grumpy-runtime
    You will need Golang already installed for this to work
    kannanjmc
    @kannanjmc
    great
    thanks
    Alan Justino da Silva
    @alanjds
    also, I strongly suggest you to use a virtualenv
    kannanjmc
    @kannanjmc
    could you please explain why so ?
    Alan Justino da Silva
    @alanjds
    Because without that nobody can 1) know what you already have installed 2) be sure that it will not mess with your working system
    kannanjmc
    @kannanjmc
    thanks Alan
    Alan Justino da Silva
    @alanjds
    3) be sure that the versions your are using are the same that I am using, to reproduce errors/bugs