Thanks. I agree that running arbitrary code in #cgo directives is a bad idea :) I'll probably document asking to export CGO_CFLAGS="-I $(python -c 'import numpy; print(numpy.get_include())')" before running "go get"
On Monday, August 10, 2020 at 4:06:54 AM UTC+3, Ian Lance Taylor wrote: > > On Sun, Aug 9, 2020 at 9:57 AM Miki Tebeka <[email protected] > <javascript:>> wrote: > > > > Is there a way to pass include path dynamically to cgo? > > > > I'm working with numpy and the way to find the include directory is to > call (in Python) > > numpy.get_include() > > > > In a Makefile I can run go build with > > CGO_CFLAGS=-I $(shell python -c 'import numpy; > print(numpy.get_include())') go build > > > > but I don't know how to do it as a > > #cgo CFLAGS: > > directive and I'd like to have the module go gettable > > The usual approach is to use "#cgo pkg-config:". But that assumes > that numpy provides pkg-config definitions. There isn't any other > support for dynamic dependencies specified in the Go input file. In > particular we don't and won't permit running arbitrary programs in a > #cgo line. > > Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/faf2d4fc-06d7-401d-ae39-39505f7e235fo%40googlegroups.com.
