go-python / gopy

gopy generates a CPython extension module from a go package.
BSD 3-Clause "New" or "Revised" License
2.03k stars 112 forks source link

"go": cannot run executable found relative to current directory #327

Closed JanEricNitschke closed 1 year ago

JanEricNitschke commented 1 year ago

I am trying to run the hi example from the readme. However i keep getting this error:

$ gopy build -output=out -vm=/d/CSGO/ML/testing/.venv/Scripts/python github.com/go-python/gopy/_examples/hi
go build -v github.com/go-python/gopy/_examples/hi

--- Processing package: github.com/go-python/gopy/_examples/hi ---

--- building package ---
gopy.exe build -output=out -vm=D:/CSGO/ML/testing/.venv/Scripts/python github.com/go-python/gopy/_examples/hi
goimports -w hi.go
cmd had error: exit status 2  output:
oerr: exec: "go": cannot run executable found relative to current directory: stderr:

2023/04/30 18:40:18 error dispatching command: exit status 2

I am running with python 3.11.2 and go version go1.20.3 windows/amd64 on windows. However the same happens for go1.19 and 1.18.

JanEricNitschke commented 1 year ago

And if i try to execute the following command manually go build -mod=mod -buildmode=c-shared -o hi_go.pyd hi.go

then it get an error that it can not find Python.h even if i try to set GOPY_INCLUDE etc.

JanEricNitschke commented 1 year ago

Setting export NoDefaultCurrentDirectoryInExePath=1 solved the first issue.

JanEricNitschke commented 1 year ago

And that also fixes the second issue because running the command standalone means a bunch of other things arent set correctly for compilation.