diff --git a/src/App/FreeCADInit.py b/src/App/FreeCADInit.py index 41281f01d0..4510e13c26 100644 --- a/src/App/FreeCADInit.py +++ b/src/App/FreeCADInit.py @@ -86,9 +86,24 @@ def InitApplications(): # add also this path so that all modules search for libraries # they depend on first here PathExtension = BinDir + os.pathsep + # prepend all module paths to Python search path Log('Init: Searching for modules...\n') - FreeCAD.__path__ = list(ModDict.values()) + + + # to have all the module-paths available in FreeCADGuiInit.py: + FreeCAD.__ModDirs__ = list(ModDict.values()) + + # this allows importing with: + # from FreeCAD.Module import package + FreeCAD.__path__ = [ModDir, Lib64Dir, LibDir] + + # also add these directories to the sys.path to + # not change the old behaviour. once we have moved to + # proper python modules this can eventuelly be removed. + for path in FreeCAD.__path__[::-1]: + sys.path.insert(0, path) + for Dir in ModDict.values(): if ((Dir != '') & (Dir != 'CVS') & (Dir != '__init__.py')): sys.path.insert(0,Dir) @@ -105,13 +120,12 @@ def InitApplications(): Log(traceback.format_exc()) Log('-'*100+'\n') Err('During initialization the error ' + str(inst) + ' occurred in ' + InstallFile + '\n') + Err('Please look into the log file for further information') else: Log('Init: Initializing ' + Dir + '... done\n') else: Log('Init: Initializing ' + Dir + '(Init.py not found)... ignore\n') - sys.path.insert(0,LibDir) - sys.path.insert(0,Lib64Dir) - sys.path.insert(0,ModDir) + Log("Using "+ModDir+" as module path!\n") # new paths must be prepended to avoid to load a wrong version of a library try: diff --git a/src/Gui/FreeCADGuiInit.py b/src/Gui/FreeCADGuiInit.py index 81bac85d31..b5e9409618 100644 --- a/src/Gui/FreeCADGuiInit.py +++ b/src/Gui/FreeCADGuiInit.py @@ -101,7 +101,7 @@ def InitApplications(): import sys,os,traceback # Searching modules dirs +++++++++++++++++++++++++++++++++++++++++++++++++++ # (additional module paths are already cached) - ModDirs = FreeCAD.__path__ + ModDirs = FreeCAD.__ModDirs__ #print ModDirs Log('Init: Searching modules...\n') for Dir in ModDirs: @@ -116,9 +116,9 @@ def InitApplications(): Log('Init: Initializing ' + Dir + '... failed\n') Log('-'*100+'\n') Log(traceback.format_exc()) - Log(output.getvalue()) Log('-'*100+'\n') Err('During initialization the error ' + str(inst) + ' occurred in ' + InstallFile + '\n') + Err('Please look into the log file for further information') else: Log('Init: Initializing ' + Dir + '... done\n') else: