new-style-modules: adding the possebility to import from "freecad"

(this mostly aims at new modules and extension modules which want to use pip)
- any module having problems with nameclashes can use this syntax (from freecad import module)
- current imports still work (backward cobatibility)
- python extension moduels can be installed (pip) to python std path (eg.: site-packages)

- adding app, gui to the new freecad package:
```
from freecad import app
from freecad import gui
```

- syntax for importing c++ extension will not change
```
import FreeCAD as App
import FreeCADGui as Gui
```
This commit is contained in:
looooo
2017-08-31 23:27:53 +02:00
committed by wmayer
parent ddfa62282a
commit c7a4541722
6 changed files with 74 additions and 1 deletions

6
src/Ext/CMakeLists.txt Normal file
View File

@@ -0,0 +1,6 @@
# this directory is the entry point for extension modules. Any package
# installed to a directory "freecad" which is in sys.path can be imported
# with "from freecad import package" and is checked for a init_gui.py
# module, which is import at startup. (FreeCADGuiInit.py)
add_subdirectory(freecad)

View File

@@ -0,0 +1,20 @@
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c
"from distutils.sysconfig import get_python_lib; print(get_python_lib())"
OUTPUT_VARIABLE python_libs OUTPUT_STRIP_TRAILING_WHITESPACE )
SET(PYTHON_MAIN_DIR ${python_libs})
SET(EXT_SRCS
__init__.py
)
ADD_CUSTOM_TARGET(freecad_COPY_SOURCE ALL
SOURCES ${EXT_SRCS})
fc_copy_sources(freecad_COPY_SOURCE "${CMAKE_BINARY_DIR}/Ext/freecad" ${EXT_SRCS})
INSTALL(
FILES
__init__.py
DESTINATION
Ext/freecad
)

View File

@@ -0,0 +1,4 @@
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
import FreeCAD as app