grumpyhome / grumpy

Grumpy is a Python to Go source code transcompiler and runtime.
Apache License 2.0
420 stars 18 forks source link

Not able to make executables #52

Open alanjds opened 6 years ago

alanjds commented 6 years ago

google/grumpy#366 opened by @gregoff82 on Jul 19, 2017

Hi all,

I'm trying to create an executeable by following the steps here: https://github.com/google/grumpy#method-2-grumpc

The issue is when I try to build the go file. It creates a file roughly 21kB which seems too small nor is it executeable. Also, even after making a chmod +x on the file it cannot be run. The error that occurs is:

dev@mymachine:~/grumpy$ ./hello
./hello: line 1: syntax error near unexpected token `newline'
./hello: line 1: `!<arch>'

the go file produced from the command 'build/bin/grumpc hello.py > hello.go' is:

package __main__
import (
        πg "grumpy"
)
func initModule(πF *πg.Frame, _ []*πg.Object) (*πg.Object, *πg.BaseException) {
        var πTemp001 []*πg.Object
        _ = πTemp001
        var πE *πg.BaseException; _ = πE
        for ; πF.State() >= 0; πF.PopCheckpoint() {
                switch πF.State() {
                case 0:
                default: panic("unexpected function state")
                }
                // line 1: print "hello, world"
                πF.SetLineno(1)
                πTemp001 = make([]*πg.Object, 1)
                πTemp001[0] = πg.NewStr("hello, world").ToObject()
                if πE = πg.Print(πF, πTemp001, true); πE != nil {
                        continue
                }
                return nil, nil
        }
        return nil, πE
}
var Code *πg.Code
func init() {
        Code = πg.NewCode("<module>", "hello.py", nil, 0, initModule)
        πg.RegisterModule("__main__", Code)
}

if trying to build a simple go file with the code below, it works just fine (creates an executeable which i can run directly) so I don't think it's my Go installation that's been causing the issue.

package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")
}

I'm using go version go1.8.3 linux/amd64

alanjds commented 6 years ago

Comment by trotterdylan Thursday Jul 20, 2017 at 16:41 GMT


Thanks for reporting this. There was a similar issue reported on the mailing list: https://groups.google.com/forum/#!forum/grumpy-users

Basically, I've been messing around with the toolchain and those instructions no longer work. I've since updated that section of the README.

I want to make it easier to build one-off binaries like in the old instructions, so I'm going to leave this issue open to track progress on that work.

alanjds commented 6 years ago

Comment by gregoff82 Thursday Jul 20, 2017 at 17:33 GMT


Hi,

Thanks for input! Now I know that that part is still a work in progress. Looking forward to the future instructions to build one-off binaries.

Thanks again!

alanjds commented 6 years ago

Comment by jwalters-gpsw Thursday Jan 04, 2018 at 22:46 GMT


Need any help with this?

alanjds commented 6 years ago

Comment by ymy0 Friday May 25, 2018 at 03:00 GMT


I need help please,I have the same problem!!! So if it can't work ,how should I deal with? Can I continue to use the GRUMPY? Please

alanjds commented 6 years ago

I was able to produce a binary changing the go run... line on https://github.com/grumpyhome/grumpy/blob/0ee582920937774e5123deb10e1a6b23ca9d2aba/grumpy-tools-src/grumpy_tools/grumprun.py#L126 to go build..., but had not committed this on any branch. Needs proper polishing.

The plan is to create a grumpy build myscript.py command that outputs a binary instead of compiling and running the code.

This should be an easy 1st PR for someone willing to help.