@@ -38,11 +38,11 @@ var WindowsOS = false
3838
3939// for all preambles: 1 = name of package (outname), 2 = cmdstr
4040
41- // 3 = libcfg, 4 = GoHandle, 5 = CGoHandle, 6 = all imports, 7 = mainstr, 8 = exe pre C, 9 = exe pre go
41+ // 3 = libcfg, 4 = GoHandle, 5 = CGoHandle, 6 = all imports, 7 = mainstr, 8 = exe pre C, 9 = exe pre go, 10 = gopy version
4242const (
4343 goPreamble = `/*
4444cgo stubs for package %[1]s.
45- File is generated by gopy. Do not edit.
45+ File is generated by gopy version %[10]s . Do not edit.
4646%[2]s
4747*/
4848
@@ -263,8 +263,9 @@ func GoPyMainRun() {
263263
264264`
265265
266+ // 3 = gopy version
266267 PyBuildPreamble = `# python build stubs for package %[1]s
267- # File is generated by gopy. Do not edit.
268+ # File is generated by gopy version %[3]s . Do not edit.
268269# %[2]s
269270
270271from pybindgen import retval, param, Function, Module
@@ -317,11 +318,11 @@ mod.add_function('_gopy_clear_go_tls', None, [])
317318 // appended to imports in py wrap preamble as key for adding at end
318319 importHereKeyString = "%%%%%%<<<<<<ADDIMPORTSHERE>>>>>>>%%%%%%%"
319320
320- // 3 = specific package name, 4 = spec pkg path, 5 = doc, 6 = imports
321+ // 3 = specific package name, 4 = spec pkg path, 5 = doc, 6 = imports, 8 = gopy version
321322 PyWrapPreamble = `%[5]s
322323# python wrapper for package %[4]s within overall package %[1]s
323324# This is what you import to use the package.
324- # File is generated by gopy. Do not edit.
325+ # File is generated by gopy version %[8]s . Do not edit.
325326# %[2]s
326327
327328# the following is required to enable dlopen to open the _go.so file
@@ -379,11 +380,11 @@ except Exception:
379380`
380381
381382 // exe version of preamble -- doesn't need complex code to load _ module
382- // 3 = specific package name, 4 = spec pkg path, 5 = doc, 6 = imports
383+ // 3 = specific package name, 4 = spec pkg path, 5 = doc, 6 = imports, 8 = gopy version
383384 PyWrapExePreamble = `%[5]s
384385# python wrapper for package %[4]s within standalone executable package %[1]s
385386# This is what you import to use the package.
386- # File is generated by gopy. Do not edit.
387+ # File is generated by gopy version %[8]s . Do not edit.
387388# %[2]s
388389
389390import collections
@@ -431,9 +432,9 @@ def Init():
431432 `
432433
433434 // 3 = gencmd, 4 = vm, 5 = libext 6 = extraGccArgs, 7 = CFLAGS, 8 = LDLFAGS,
434- // 9 = windows special declspec hack
435+ // 9 = windows special declspec hack, 10 = gopy version
435436 MakefileTemplate = `# Makefile for python interface for package %[1]s.
436- # File is generated by gopy. Do not edit.
437+ # File is generated by gopy version %[10]s . Do not edit.
437438# %[2]s
438439
439440GOCMD=go
@@ -470,9 +471,9 @@ build:
470471
471472`
472473
473- // exe version of template: 3 = gencmd, 4 = vm, 5 = libext
474+ // exe version of template: 3 = gencmd, 4 = vm, 5 = libext, 8 = gopy version
474475 MakefileExeTemplate = `# Makefile for python interface for standalone executable package %[1]s.
475- # File is generated by gopy. Do not edit.
476+ # File is generated by gopy version %[8]s . Do not edit.
476477# %[2]s
477478
478479GOCMD=go
@@ -721,12 +722,12 @@ func (g *pyGen) genGoPreamble() {
721722 exeprego = goExePreambleGo
722723 }
723724 g .gofile .Printf (goPreamble , g .cfg .Name , g .cfg .Cmd , libcfg , GoHandle , CGoHandle ,
724- pkgimport , g .cfg .Main , exeprec , exeprego )
725+ pkgimport , g .cfg .Main , exeprec , exeprego , g . cfg . Version )
725726 g .gofile .Printf ("\n // --- generated code for package: %[1]s below: ---\n \n " , g .cfg .Name )
726727}
727728
728729func (g * pyGen ) genPyBuildPreamble () {
729- g .pybuild .Printf (PyBuildPreamble , g .cfg .Name , g .cfg .Cmd )
730+ g .pybuild .Printf (PyBuildPreamble , g .cfg .Name , g .cfg .Cmd , g . cfg . Version )
730731}
731732
732733func (g * pyGen ) genPyWrapPreamble () {
@@ -784,9 +785,9 @@ func (g *pyGen) genPyWrapPreamble() {
784785 impstr += importHereKeyString
785786
786787 if g .mode == ModeExe {
787- g .pywrap .Printf (PyWrapExePreamble , g .cfg .Name , g .cfg .Cmd , n , pkgimport , pkgDoc , impgenstr , impstr )
788+ g .pywrap .Printf (PyWrapExePreamble , g .cfg .Name , g .cfg .Cmd , n , pkgimport , pkgDoc , impgenstr , impstr , g . cfg . Version )
788789 } else {
789- g .pywrap .Printf (PyWrapPreamble , g .cfg .Name , g .cfg .Cmd , n , pkgimport , pkgDoc , impgenstr , impstr )
790+ g .pywrap .Printf (PyWrapPreamble , g .cfg .Name , g .cfg .Cmd , n , pkgimport , pkgDoc , impgenstr , impstr , g . cfg . Version )
790791 }
791792}
792793
@@ -816,14 +817,14 @@ func (g *pyGen) genMakefile() {
816817 }
817818
818819 if g .mode == ModeExe {
819- g .makefile .Printf (MakefileExeTemplate , g .cfg .Name , g .cfg .Cmd , gencmd , g .cfg .VM , g .libext , pycfg .CFlags , pycfg .LdFlags )
820+ g .makefile .Printf (MakefileExeTemplate , g .cfg .Name , g .cfg .Cmd , gencmd , g .cfg .VM , g .libext , pycfg .CFlags , pycfg .LdFlags , g . cfg . Version )
820821 } else {
821822 winhack := ""
822823 if WindowsOS {
823824 winhack = fmt .Sprintf (`# windows-only sed hack here to fix pybindgen declaration of PyInit
824825 sed -i "s/ PyInit_/ __declspec(dllexport) PyInit_/g" %s.c` , g .cfg .Name )
825826 }
826- g .makefile .Printf (MakefileTemplate , g .cfg .Name , g .cfg .Cmd , gencmd , g .cfg .VM , g .libext , g .extraGccArgs , pycfg .CFlags , pycfg .LdFlags , winhack )
827+ g .makefile .Printf (MakefileTemplate , g .cfg .Name , g .cfg .Cmd , gencmd , g .cfg .VM , g .libext , g .extraGccArgs , pycfg .CFlags , pycfg .LdFlags , winhack , g . cfg . Version )
827828 }
828829}
829830
0 commit comments