diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt
index 7c36570..f1a47a8 100644
--- a/pcbnew/CMakeLists.txt
+++ b/pcbnew/CMakeLists.txt
@@ -1,3 +1,13 @@
+
+if( UNIX AND NOT APPLE )
+    # Setting this ON slows down linking and is a advanced (=hidden) developer option for
+    # linux, not a user option.
+    option( PCBNEW_LINK_MAPS
+        "Developer: create linker map files for pcbnew binaries, not typical for Debug builds"
+        )
+    mark_as_advanced( PCBNEW_LINK_MAPS )
+endif()
+
 add_definitions( -DPCBNEW )
 
 add_subdirectory(router)
@@ -18,8 +28,9 @@ endif()
 
 if( BUILD_GITHUB_PLUGIN )
     set( GITHUB_3DLIBRARIES_WIZARD
-            dialogs/wizard_3DShape_Libs_downloader_base.cpp
-            dialogs/wizard_3DShape_Libs_downloader.cpp )
+        dialogs/wizard_3DShape_Libs_downloader_base.cpp
+        dialogs/wizard_3DShape_Libs_downloader.cpp
+    )
 endif()
 
 include_directories( BEFORE ${INC_BEFORE} )
@@ -36,7 +47,7 @@ include_directories(
     ../utils/idftools
     ${GLM_INCLUDE_DIR}
     ${INC_AFTER}
-    )
+)
 
 set( PCBNEW_DIALOGS
     dialogs/dialog_block_options_base.cpp
@@ -149,13 +160,13 @@ set( PCBNEW_DIALOGS
     dialogs/wizard_add_fplib_base.cpp
     dialogs/wizard_add_fplib.cpp
     ${GITHUB_3DLIBRARIES_WIZARD}
-    )
+)
 
 set( PCBNEW_IMPORT_DXF
     import_dxf/dialog_dxf_import_base.cpp
     import_dxf/dialog_dxf_import.cpp
     import_dxf/dxf2brd_items.cpp
-    )
+)
 
 set( PCBNEW_EXPORTERS
     exporters/export_d356.cpp
@@ -165,7 +176,7 @@ set( PCBNEW_EXPORTERS
     exporters/gen_drill_report_files.cpp
     exporters/gen_modules_placefile.cpp
     exporters/gendrill_Excellon_writer.cpp
-    )
+)
 
 set( PCBNEW_AUTOROUTER_SRCS
     autorouter/rect_placement/rect_placement.cpp
@@ -179,7 +190,7 @@ set( PCBNEW_AUTOROUTER_SRCS
     autorouter/solve.cpp
     autorouter/graphpcb.cpp
     autorouter/work.cpp
-    )
+)
 
 set( PCBNEW_CLASS_SRCS
     board_commit.cpp
@@ -303,7 +314,7 @@ set( PCBNEW_CLASS_SRCS
     tools/grid_menu.cpp
     tools/zoom_menu.cpp
     tools/size_menu.cpp
-    )
+)
 
 set( PCBNEW_SRCS ${PCBNEW_AUTOROUTER_SRCS} ${PCBNEW_CLASS_SRCS} ${PCBNEW_DIALOGS} )
 
@@ -312,12 +323,12 @@ set( PCBNEW_SRCS ${PCBNEW_AUTOROUTER_SRCS} ${PCBNEW_CLASS_SRCS} ${PCBNEW_DIALOGS
 set( PCBNEW_COMMON_SRCS
     ../common/dialogs/dialog_page_settings.cpp
     ../common/base_units.cpp
-    )
+)
 
 set( PCBNEW_SCRIPTING_DIALOGS
     dialogs/dialog_scripting_base.cpp
     dialogs/dialog_scripting.cpp
-    )
+)
 
 set( PCBNEW_SCRIPTING_PYTHON_HELPERS
     ../common/swig/wx_python_helpers.cpp
@@ -325,22 +336,22 @@ set( PCBNEW_SCRIPTING_PYTHON_HELPERS
     swig/pcbnew_scripting_helpers.cpp
     swig/pcbnew_footprint_wizards.cpp
     swig/pcbnew_action_plugins.cpp
-    )
+)
 
 if( KICAD_SCRIPTING )
     set( PCBNEW_SCRIPTING_SRCS
         ${PCBNEW_SCRIPTING_DIALOGS}
         pcbnew_wrap.cxx
         ${PCBNEW_SCRIPTING_PYTHON_HELPERS}
-        )
+    )
 
 
     # Swig generated files do not use the override specifier, therefore
     # disable suggest-override warnings
-    if (COMPILER_SUPPORTS_WSUGGEST_OVERRIDE)
+    if( COMPILER_SUPPORTS_WSUGGEST_OVERRIDE )
         set_source_files_properties( pcbnew_wrap.cxx pcbnewPYTHON_wrap.cxx
             PROPERTIES COMPILE_FLAGS -Wno-suggest-override
-        )
+    )
     endif()
 
 endif()
@@ -354,7 +365,7 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
         -I${CMAKE_CURRENT_SOURCE_DIR}/../scripting
         -I${CMAKE_CURRENT_SOURCE_DIR}/../common/swig
         -I${WXPYTHON_SWIG_DIR}
-        )
+    )
 
     if( DEBUG )
         set( SWIG_FLAGS ${SWIG_FLAGS} -DDEBUG )
@@ -369,7 +380,10 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
 endif()
 
 
-if( KICAD_SCRIPTING )
+if( KICAD_SCRIPTING )   # Generate pcbnew.py and pcbnew_wrap.cxx using swig
+
+    # We deliberately do not use the CMake support for swig here,
+    # i.e. swig_add_module()) because we want full control.
 
     set( SWIG_OPTS -python -c++ -outdir ${CMAKE_CURRENT_BINARY_DIR} ${SWIG_FLAGS} )
 
@@ -386,6 +400,8 @@ if( KICAD_SCRIPTING )
         DEPENDS exporters/gendrill_Excellon_writer.h
         DEPENDS swig/pcbnew.i
         DEPENDS swig/board.i
+        DEPENDS swig/board_connected_item.i
+        DEPENDS swig/board_design_settings.i
         DEPENDS swig/board_item.i
         DEPENDS swig/board_item_container.i
         DEPENDS swig/dimension.i
@@ -403,6 +419,7 @@ if( KICAD_SCRIPTING )
         DEPENDS swig/track.i
         DEPENDS swig/units.i
         DEPENDS swig/zone.i
+        DEPENDS swig/zone_settings.i
 
         DEPENDS ../common/swig/dlist.i
         DEPENDS ../common/swig/kicad.i
@@ -411,13 +428,19 @@ if( KICAD_SCRIPTING )
         DEPENDS ../scripting/kicadplugins.i
 
         COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/docstrings
-        COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/docstrings/docstrings.i # this makes docstrings.i available if it doesn't exist
 
-        COMMAND ${SWIG_EXECUTABLE} ${SWIG_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx  swig/pcbnew.i
-        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripting/build_tools/fix_swig_imports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-        )
+        # Make docstrings.i available if it doesn't exist
+        COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/docstrings/docstrings.i
+
+        COMMAND ${SWIG_EXECUTABLE}
+            ${SWIG_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx swig/pcbnew.i
 
+        COMMAND ${PYTHON_EXECUTABLE}
+            ${CMAKE_SOURCE_DIR}/scripting/build_tools/fix_swig_imports.py
+            ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
+
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+    )
 endif()
 
 
@@ -430,126 +453,6 @@ if( UNIX AND NOT APPLE )
 endif()
 
 
-if( KICAD_SCRIPTING_MODULES )
-
-    #message( "building pcbnew scripting" )
-
-    set( CMAKE_SWIG_FLAGS ${SWIG_FLAGS} )
-    set_source_files_properties( swig/pcbnew.i PROPERTIES CPLUSPLUS ON )
-
-    # https://cmake.org/cmake/help/v3.2/module/UseSWIG.html
-    # Set this ..EXTRA_DEPS variable before invoking swig_add_module() macro
-    set( SWIG_MODULE_pcbnew_EXTRA_DEPS
-        swig/board.i
-        swig/board_item.i
-        swig/board_item_container.i
-        swig/dimension.i
-        swig/drawsegment.i
-        swig/edge_mod.i
-        swig/marker_pcb.i
-        swig/mire.i
-        swig/module.i
-        swig/netclass.i
-        swig/netinfo.i
-        swig/pad.i
-        swig/pcb_text.i
-        swig/plugins.i
-        swig/text_mod.i
-        swig/track.i
-        swig/units.i
-        swig/zone.i
-
-        ../common/swig/dlist.i
-        ../common/swig/kicad.i
-        ../common/swig/wx.i
-        ../common/swig/ki_exception.i
-        ../scripting/kicadplugins.i
-        )
-
-    swig_add_module( pcbnew
-        python
-        swig/pcbnew.i
-        ${PCBNEW_SCRIPTING_PYTHON_HELPERS}
-        pcbnew.cpp
-        ${PCBNEW_SRCS}
-        ${PCBNEW_COMMON_SRCS}
-        )
-
-    swig_link_libraries( pcbnew
-        3d-viewer
-        pcbcommon
-        pnsrouter
-        pcad2kicadpcb
-        common
-        lib_dxf
-        idf3
-        polygon
-        bitmaps
-        gal
-        ${wxWidgets_LIBRARIES}
-        ${GITHUB_PLUGIN_LIBRARIES}
-        ${GDI_PLUS_LIBRARIES}
-        ${PYTHON_LIBRARIES}
-        ${PCBNEW_EXTRA_LIBS}
-        ${Boost_LIBRARIES}      # must follow GITHUB
-        )
-
-    if( MAKE_LINK_MAPS )
-        set_target_properties( _pcbnew PROPERTIES
-            LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=pcbnew.so.map"
-            )
-    endif()
-
-    if( ${OPENMP_FOUND} )
-        set_property( TARGET _pcbnew APPEND_STRING
-            PROPERTY LINK_FLAGS " ${OpenMP_CXX_FLAGS}"
-        )
-    endif()
-endif()
-
-
-###
-# Doxygen python documentation
-###
-
-if( DOXYGEN_FOUND )
-    if( KICAD_SCRIPTING )
-
-        # create XML files from doxygen parsing
-        add_custom_target( doxygen-python-xml
-            ${CMAKE_COMMAND} -E remove_directory doxygen-python-xml
-            COMMAND SOURCES_DIR=${CMAKE_SOURCE_DIR} ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile_xml
-            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-            DEPENDS Doxyfile_xml
-            COMMENT "building doxygen docs into directory doxygen-python/html"
-            )
-
-        # create .i files from XML doxygen parsing, docstrings.i will include all of them
-        add_custom_target( xml-to-docstrings
-            COMMAND ${CMAKE_COMMAND} -E remove_directory docstrings
-            COMMAND ${CMAKE_COMMAND} -E make_directory docstrings
-            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripting/build_tools/extract_docstrings.py pcbnew.py doxygen-xml/xml docstrings
-            COMMAND ${CMAKE_COMMAND} -E remove pcbnew.py # force removal so it will be recreated later with the new docstrings
-            COMMENT "building docstring files"
-            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-            DEPENDS pcbnew.py
-            DEPENDS doxygen-python-xml
-            )
-
-        # create doxygen-python html
-        add_custom_target( doxygen-python
-            ${CMAKE_COMMAND} -E remove_directory doxygen-python
-            COMMAND PYTHON_SOURCES_TO_DOC=${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile_python
-            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-            DEPENDS Doxyfile_python
-            DEPENDS xml-to-docstrings
-            DEPENDS pcbnew.py
-            COMMENT "building doxygen docs into directory doxygen-python/html"
-            )
-    endif()
-endif()
-
-
 if( MINGW )
     # PCBNEW_RESOURCES variable is set by the macro.
     mingw_resource_compiler( pcbnew )
@@ -563,10 +466,10 @@ if( APPLE )
     set( PCBNEW_RESOURCES pcbnew.icns pcbnew_doc.icns )
     set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pcbnew.icns" PROPERTIES
         MACOSX_PACKAGE_LOCATION Resources
-        )
+    )
     set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/pcbnew_doc.icns" PROPERTIES
         MACOSX_PACKAGE_LOCATION Resources
-        )
+    )
     set( MACOSX_BUNDLE_ICON_FILE pcbnew.icns )
     set( MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-pcb.kicad )
     set( MACOSX_BUNDLE_NAME pcbnew )
@@ -583,11 +486,11 @@ add_custom_command(
     DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help.html
     COMMENT "creating ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help_html.h
        from ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help.html"
-    )
+)
 
 set_source_files_properties( dialogs/dialog_freeroute_exchange.cpp PROPERTIES
     OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help_html.h
-    )
+)
 
 add_subdirectory( pcad2kicadpcb_plugin )
 
@@ -603,21 +506,22 @@ endif()
 add_executable( pcbnew WIN32 MACOSX_BUNDLE
     ../common/single_top.cpp
     ${PCBNEW_RESOURCES}
-    )
+)
 set_source_files_properties( ../common/single_top.cpp pcbnew.cpp PROPERTIES
     COMPILE_DEFINITIONS "TOP_FRAME=FRAME_PCB;PGM_DATA_FILE_EXT=\"kicad_pcb\";BUILD_KIWAY_DLL"
-    )
+)
 target_link_libraries( pcbnew
     #singletop  # replaces common, giving us restrictive control and link warnings.
     # There's way too much crap coming in from common yet.
     common
     bitmaps
     ${wxWidgets_LIBRARIES}
-    )
+)
 
-if( MAKE_LINK_MAPS )
+if( PCBNEW_LINK_MAPS )
     set_target_properties( pcbnew PROPERTIES
-        LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=pcbnew.map" )
+        LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=pcbnew.map" 
+    )
 endif()
 
 # the main pcbnew program, in DSO form.
@@ -626,19 +530,19 @@ add_library( pcbnew_kiface MODULE
     ${PCBNEW_SRCS}
     ${PCBNEW_COMMON_SRCS}
     ${PCBNEW_SCRIPTING_SRCS}
-    )
+)
 set_target_properties( pcbnew_kiface PROPERTIES
     # Decorate OUTPUT_NAME with PREFIX and SUFFIX, creating something like
     # _pcbnew.so, _pcbnew.dll, or _pcbnew.kiface
     OUTPUT_NAME     pcbnew
     PREFIX          ${KIFACE_PREFIX}
     SUFFIX          ${KIFACE_SUFFIX}
-    )
+)
 
 if( ${OPENMP_FOUND} )
     set_target_properties( pcbnew_kiface PROPERTIES
         COMPILE_FLAGS   ${OpenMP_CXX_FLAGS}
-        )
+    )
 endif()
 
 target_link_libraries( pcbnew_kiface
@@ -659,19 +563,19 @@ target_link_libraries( pcbnew_kiface
     ${Boost_LIBRARIES}      # must follow GITHUB
     ${PCBNEW_EXTRA_LIBS}    # -lrt must follow Boost
     ${OPENMP_LIBRARIES}
-    )
+)
 set_source_files_properties( pcbnew.cpp PROPERTIES
     # The KIFACE is in pcbnew.cpp, export it:
     COMPILE_DEFINITIONS     "BUILD_KIWAY_DLL;COMPILING_DLL"
-    )
+)
 
-if( MAKE_LINK_MAPS )
+if( PCBNEW_LINK_MAPS )
     set_target_properties( pcbnew_kiface PROPERTIES
         LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=_pcbnew.kiface.map"
-        )
+    )
     set_target_properties( pcbnew PROPERTIES
         LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=pcbnew.map"
-        )
+    )
 endif()
 
 # if building pcbnew, then also build pcbnew_kiface if out of date.
@@ -681,18 +585,18 @@ add_dependencies( pcbnew pcbnew_kiface )
 if( APPLE )
     set_target_properties( pcbnew PROPERTIES
         MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
-        )
+    )
 
     # puts binaries into the *.app bundle while linking
     set_target_properties( pcbnew_kiface PROPERTIES
         LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR}
-        )
+    )
     # put individual bundle outside of main bundle as a first step
     # will be pulled into the main bundle when creating main bundle
     install( TARGETS pcbnew
         DESTINATION ${KICAD_BIN}
         COMPONENT binary
-        )
+    )
     install( CODE "
         # override default embedded path settings
         ${OSX_BUNDLE_OVERRIDE_PATHS}
@@ -704,32 +608,76 @@ if( APPLE )
             \"\"
             )
         " COMPONENT Runtime
-        )
+    )
 else()
     install( TARGETS pcbnew
         DESTINATION ${KICAD_BIN}
         COMPONENT binary
-        )
+    )
     install( TARGETS pcbnew_kiface
         DESTINATION ${KICAD_BIN}
         COMPONENT binary
-        )
+    )
 endif()
 
 add_dependencies( pcbnew lib-dependencies )
 
 
+###
+# Doxygen python documentation
+###
+
+if( DOXYGEN_FOUND )
+    if( KICAD_SCRIPTING )
+
+        # create XML files from doxygen parsing
+        add_custom_target( doxygen-python-xml
+            ${CMAKE_COMMAND} -E remove_directory doxygen-python-xml
+            COMMAND SOURCES_DIR=${CMAKE_SOURCE_DIR} ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile_xml
+            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+            DEPENDS Doxyfile_xml
+            COMMENT "building doxygen docs into directory doxygen-python/html"
+        )
+
+        # create .i files from XML doxygen parsing, docstrings.i will include all of them
+        add_custom_target( xml-to-docstrings
+            COMMAND ${CMAKE_COMMAND} -E remove_directory docstrings
+            COMMAND ${CMAKE_COMMAND} -E make_directory docstrings
+            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripting/build_tools/extract_docstrings.py pcbnew.py doxygen-xml/xml docstrings
+            COMMAND ${CMAKE_COMMAND} -E remove pcbnew.py # force removal so it will be recreated later with the new docstrings
+            COMMENT "building docstring files"
+            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+            DEPENDS pcbnew.py
+            DEPENDS doxygen-python-xml
+        )
+
+        # create doxygen-python html
+        add_custom_target( doxygen-python
+            ${CMAKE_COMMAND} -E remove_directory doxygen-python
+            COMMAND PYTHON_SOURCES_TO_DOC=${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile_python
+            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+            DEPENDS Doxyfile_python
+            DEPENDS xml-to-docstrings
+            DEPENDS pcbnew.py
+            COMMENT "building doxygen docs into directory doxygen-python/html"
+        )
+    endif()
+endif()
+
+###
+# Python Scripting Install Rules
+###
 if( KICAD_SCRIPTING )
     if( NOT APPLE )
         install( FILES ${CMAKE_BINARY_DIR}/pcbnew/pcbnew.py DESTINATION ${PYTHON_DEST} )
     else()
         # put into bundle at build time, it is relocated at install
+        file( MAKE_DIRECTORY ${PYTHON_DEST} )
         add_custom_target( ScriptingPcbnewPyCopy ALL
             COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/pcbnew/pcbnew.py" "${PYTHON_DEST}/"
             DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
             COMMENT "Copying pcbnew.py into ${PYTHON_DEST}"
-            )
-        add_dependencies( ScriptingPcbnewPyCopy ScriptingWxpythonCopy )
+        )
     endif()
 
     # python plugins
@@ -745,40 +693,64 @@ if( KICAD_SCRIPTING )
     )
 endif()
 
+
 if( KICAD_SCRIPTING_MODULES )
-    add_custom_target( FixSwigImportsModuleScripting ALL
-        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripting/build_tools/fix_swig_imports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
-        DEPENDS _pcbnew
-        COMMENT "Fixing swig_import_helper in Kicad scripting modules"
-        )
+
+    # 1) KICAD_SCRIPTING enables python inside _pcbnew.kiface.
+    # 2) KICAD_SCRIPTING_MODULES enables python from the OS command line for pcbnew.
+    # When python is running within _pcbnew.kiface (case 1 above) it uses said
+    # kiface for the native part of the pcbnew python module.  This is a kind of
+    # circular dependency that works well.  When running python from
+    # the command line (case 2 above) then python needs a native portion of the pcbnew
+    # python module also, and this is _pcbnew.{so,pyd}.  It turns out that the
+    # kiface file is built adequately to serve the needs of 2) for now if it is
+    # merely renamed. This is phase 1 of a 2 step plan.
+    # In phase 2 we will use the _pcbnew.kiface file without renaming, by doctoring
+    # what the python portion of the pcbnew python module wants to load when run
+    # from the command line, case 2 above.
+
+    # Here is built the _pcbnew.{so,pyd} which is the native part of the pcbnew Python library
+    # when Python is used from the command line.
 
     if( MINGW )
         install( FILES ${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.pyd DESTINATION ${PYTHON_DEST} )
+        set( PYMOD_EXT "pyd" )
     elseif( APPLE )
          # put everything into bundle at build time, it is relocated at install
         add_custom_target( ScriptingModulesPcbnewSoCopy ALL
             COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.so" "${PYTHON_DEST}/"
-            DEPENDS _pcbnew
+            DEPENDS _pcbnew.so
             COMMENT "Copying _pcbnew.so into ${PYTHON_DEST}"
             )
-        add_dependencies( ScriptingModulesPcbnewSoCopy ScriptingWxpythonCopy )
-    else()
+        set( PYMOD_EXT "so" )
+
+    else()  # only linux remains among supported platforms
         install( FILES ${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.so DESTINATION ${PYTHON_DEST} )
+        set( PYMOD_EXT "so" )
     endif()
+
+    # For phase 1, copy _pcbnew.kiface to the python module.
+    add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT}
+        DEPENDS pcbnew_kiface
+        COMMAND ${CMAKE_COMMAND} -E copy _pcbnew.kiface _pcbnew.${PYMOD_EXT}
+        COMMENT "Creating python's pcbnew native module _pcbnew.${PYMOD_EXT} for command line use."
+    )
+    add_custom_target(
+        pcbnew_python_module ALL
+        DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT}
+    )
+
 endif()
 
-if( APPLE )
-    if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
+
+if( KICAD_SCRIPTING_WXPYTHON )
+    if( APPLE )
         # find wx-X.Y-osx_cocoa path below PYTHON_SITE_PACKAGE_PATH
         file( GLOB WXPYTHON_DIR RELATIVE ${PYTHON_SITE_PACKAGE_PATH} ${PYTHON_SITE_PACKAGE_PATH}/wx-?.?-osx_cocoa )
         if( NOT WXPYTHON_DIR )
             message( FATAL_ERROR "Could not find 'wx-?.?-osx_cocoa' in '${PYTHON_SITE_PACKAGE_PATH}'" )
         endif()
-        # copy contents
-        add_custom_target( ScriptingWxpythonCopy ALL
-            COMMAND ${CMAKE_COMMAND} -E copy_directory "${PYTHON_SITE_PACKAGE_PATH}/${WXPYTHON_DIR}" "${PYTHON_DEST}/${WXPYTHON_DIR}"
-            COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_SITE_PACKAGE_PATH}/wxversion.py" "${PYTHON_DEST}"
-            COMMENT "Copying wxPython into ${PYTHON_DEST}"
-            )
+        install( DIRECTORY ${PYTHON_SITE_PACKAGE_PATH}/${WXPYTHON_DIR} DESTINATION ${PYTHON_DEST} )
+        install( FILES ${PYTHON_SITE_PACKAGE_PATH}/wxversion.py DESTINATION ${PYTHON_DEST} )
     endif()
 endif()
