From 7ca1a4a66369fefa9c676301dfdd7467b20a394a Mon Sep 17 00:00:00 2001 From: Asparuh Krastev Date: Fri, 9 Dec 2022 14:37:51 +0200 Subject: [PATCH] Fixes a leftover bug to properly handle multiple go packages when generating python relative imports. Refs go-python/gopy #245 --- bind/gen.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bind/gen.go b/bind/gen.go index c36dc9b..8f829ab 100644 --- a/bind/gen.go +++ b/bind/gen.go @@ -552,7 +552,11 @@ func (g *pyGen) genPkgWrapOut() { impstr := "" for _, im := range g.pkg.pyimports { if g.mode == ModeGen || g.mode == ModeBuild { - impstr += fmt.Sprintf("import %s\n", im) + if g.cfg.PkgPrefix != "" { + impstr += fmt.Sprintf("from %s import %s\n", g.cfg.PkgPrefix, im) + } else { + impstr += fmt.Sprintf("import %s\n", im) + } } else { impstr += fmt.Sprintf("from %s import %s\n", g.cfg.Name, im) }