go-embed-python icon indicating copy to clipboard operation
go-embed-python copied to clipboard

Compiling with tiny Go

Open amlwwalker opened this issue 1 year ago • 2 comments
trafficstars

Hey @codablock - i thought as we had solved the other ticket for all intent and purposes, and this isn't related, i'd ask in a new issue.... 😁

I want to compile with Tiny Go,

GOARCH=wasm tinygo build -tags wasm -x -o plugin.wasm -scheduler=none -target=wasi           

However this results in

GOARCH=wasm tinygo build -tags wasm -x -o plugin.wasm -scheduler=none -target=wasi           
package command-line-arguments
        imports github.com/user.name/python-embed/internal/python-libs/data: build constraints exclude all Go files in /Users/user.name/go/src/github.com/user.name/python-embed/internal/python-libs/data
make: *** [wasm] Error 1

I've looked through the files in the data directory and i can't see a constraint that would explicitly cause this - would you have any ideas?

If i put a file in the data folder like

package data

func HelloWorld() string {
	return "hello world"
}

and then compile I get

/usr/local/go/src/internal/cpu/cpu_wasm.go:7:7: CacheLinePadSize redeclared in this block
/usr/local/go/src/internal/cpu/cpu_arm.go:7:7:  other declaration of CacheLinePadSize
/usr/local/go/src/internal/cpu/cpu_wasm.go:9:6: doinit redeclared in this block
/usr/local/go/src/internal/cpu/cpu_arm.go:21:6:         other declaration of doinit

which seems odd as I'm on OSX but it allows a file to be compiled in the dir which exposes this issue...

amlwwalker avatar Dec 09 '23 20:12 amlwwalker

I have no experience with Tiny Go...but it looks like you're trying to compile to wasm, which is not supported at the moment. go-embed-python relies on python binaries and python code being packaged that are compatible with the target platform that your binary gets compiled for. These binaries are then executed via os/exec, which is not supported in Tiny Go. Even if it would be supported, there is currently no wasm build of Python that could be used in go-embed-python (this might change in the future, but there is a lot missing for this to be practical).

codablock avatar Dec 11 '23 09:12 codablock

gotcha. Makes sense. If you hear of any changes, please let me know! Basically I was hoping to write plugins for Go and then allow those plugins to be written (mainly) in python. I may however still be able to do it if the host application processes the python and not the plugin.

amlwwalker avatar Dec 11 '23 11:12 amlwwalker