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:
6
src/Ext/CMakeLists.txt
Normal file
6
src/Ext/CMakeLists.txt
Normal 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)
|
||||
20
src/Ext/freecad/CMakeLists.txt
Normal file
20
src/Ext/freecad/CMakeLists.txt
Normal 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
|
||||
)
|
||||
4
src/Ext/freecad/__init__.py
Normal file
4
src/Ext/freecad/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
import pkgutil
|
||||
__path__ = pkgutil.extend_path(__path__, __name__)
|
||||
|
||||
import FreeCAD as app
|
||||
Reference in New Issue
Block a user