Code: Select all
from FreeCAD.Fem.PyGui import FemCommands
Code: Select all
from Fem.PyGui import FemCommands
Code: Select all
from FreeCAD.Fem.PyGui import FemCommands
Code: Select all
from Fem.PyGui import FemCommands
Code: Select all
>>> from FreeCAD import FemTools
>>>
Code: Select all
from PartDesign.WizardShaft import ShaftFeature as sf
This allows us to writeregarding this line https://github.com/FreeCAD/FreeCAD/blob ... nit.py#L91 it should already be possible.
Code: Select all
from FreeCAD import Fem
Code: Select all
from FreeCAD import PartDesign
Code: Select all
from FreeCAD import _PartDesign
You are right, PartDesign is a good example. There we have already a __init__.py.wmayer wrote: but trying tofails.Code: Select all
from FreeCAD import PartDesign
However,works.Code: Select all
from FreeCAD import _PartDesign
Code: Select all
from FreeCAD import PartDesign
Code: Select all
from FreeCAD import WizardShaft
No this isn't possible for me. only the files inside the Fem-dir can be imported eg.:wmayer wrote:This allows us to write
Code: Select all
from FreeCAD import Fem
Code: Select all
from FreeCAD import FemTools
Code: Select all
from FreeCAD import module
Code: Select all
FreeCAD.__path__=[FreeCAD.getHomePath()+'Mod']
from FreeCAD.PartDesign.WizardShaft import ShaftFeature as sf # works
+1. Seems much more pythonic.wmayer wrote:So, as the first step we can change this line https://github.com/FreeCAD/FreeCAD/blob ... nit.py#L91 to only list the Mod directory. In the second step we do as looo suggested and add the "_" prefix to all Python extension modules and add the __init__.py files.
This way the current behaviour still works but all packages can be moved to the new style. Once this is finished we can change the code to not add all paths to sys.path.
[And after the change every piece of code out there using "the old way of importing modules" stops to work?
So, this means we can raise a warning if someone doesLike I have said we can choose in which way a modul is loaded by checking for the __init__.py. We can also print a warning that old style will be removed in the future...
Code: Select all
import Fem
Code: Select all
from FreeCAD import Fem