From a29564bd9c9020376e40ff2af6ca7ad5d8b93011 Mon Sep 17 00:00:00 2001 From: Alex Lin Date: Thu, 2 May 2019 08:20:06 -0500 Subject: [PATCH] Python init code does not work when using SWIG 4.0 #760 Looks like the way modules are loaded changed a little with SWIG 4.0. So I changed the order we include everything in __init__.py. We include all of the c++ python modules first now instead of having them read in from the python code itself. Basically we include the files like this in this order import _m from m import * --- libexec/trick/make_makefile_swig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libexec/trick/make_makefile_swig b/libexec/trick/make_makefile_swig index a11b13b0..b2c13415 100755 --- a/libexec/trick/make_makefile_swig +++ b/libexec/trick/make_makefile_swig @@ -383,11 +383,16 @@ LINK_LISTS += \$(LD_FILELIST)build/py_link_list foreach $f ( @files_to_process, @ext_lib_files ) { print INITFILE "# $f\n" ; - print INITFILE "from m$md5s{$f} import *\n" ; + print INITFILE "import _m$md5s{$f}\n" ; print INITFILE "combine_cvars(all_cvars, cvar)\n" ; print INITFILE "cvar = None\n\n" ; } + foreach $f ( @files_to_process, @ext_lib_files ) { + print INITFILE "# $f\n" ; + print INITFILE "from m$md5s{$f} import *\n" ; + } + foreach my $mod ( keys %python_modules ) { print INITFILE "import trick.$mod\n" ; }