Skip to content

Commit

Permalink
CONDA: Various fixes to allow packaging of python bindings.
Browse files Browse the repository at this point in the history
* TestOne and TestTwo can now be disabled if testing is disabled.
* .pyi files are correctly generated on Windows when generating anaconda packages
* Summary.cmake reformatted a bit to better group the cmake variables being printed.
  • Loading branch information
imikejackson committed Sep 13, 2023
1 parent 7916a56 commit 78942f3
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 42 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -786,13 +786,18 @@ endif()
if(COMPLEX_ENABLE_OrientationAnalysis)
set(COMPLEX_PLUGIN_LIST ${COMPLEX_PLUGIN_LIST} OrientationAnalysis)
endif()

if(COMPLEX_BUILD_TESTS)
set(COMPLEX_PLUGIN_LIST ${COMPLEX_PLUGIN_LIST} TestOne TestTwo)
endif()

# Add any plugins to the list
set(COMPLEX_PLUGIN_LIST ${COMPLEX_PLUGIN_LIST} ${COMPLEX_EXTRA_PLUGINS})


foreach(plugin ${COMPLEX_PLUGIN_LIST})
if(NOT DEFINED COMPLEX_ENABLE_${plugin})
set(COMPLEX_ENABLE_${plugin} ON)
if(NOT DEFINED COMPLEX_PLUGIN_ENABLE_${plugin})
set(COMPLEX_PLUGIN_ENABLE_${plugin} ON)
endif()
complex_add_plugin(PLUGIN_NAME ${plugin})
endforeach()
Expand Down
34 changes: 17 additions & 17 deletions cmake/Summary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ endfunction()
#------------------------------------------------------------------------------------
# Print out a Summary Section:
message(STATUS "* ============= COMPLEX Configuration Summary ===============")
set(ALL_PROJECTS complex)
foreach(proj ${ALL_PROJECTS})
# cmpGitRevisionString(PROJECT_NAME ${proj})
get_property(githash GLOBAL PROPERTY ${proj}_GIT_HASH)
message(STATUS "* ${proj}: ${${proj}_SOURCE_DIR} Git Hash: ${githash}")
endforeach()
message(STATUS "* BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "* COMPLEX: ${complex_VERSION}")
OSInformation()
Expand All @@ -55,36 +61,29 @@ message(STATUS "* nod (${nod_VERSION}) ${nod_DIR}")
message(STATUS "* reproc++ (${reproc_VERSION}) ${reproc++_DIR}")

message(STATUS "* -------------- Complex Configuration Options -------------------------------------")
message(STATUS "* COMPLEX_BUILD_PYTHON: ${COMPLEX_BUILD_PYTHON}")
message(STATUS "* Python3_EXECUTABLE: ${Python3_EXECUTABLE}")
message(STATUS "* MKDOCS_EXECUTABLE: ${MKDOCS_EXECUTABLE}")

message(STATUS "* COMPLEX_EMBED_PYTHON: ${COMPLEX_EMBED_PYTHON}")
message(STATUS "* COMPLEX_BUILD_TESTS: ${COMPLEX_BUILD_TESTS}")
message(STATUS "* COMPLEX_ENABLE_MULTICORE: ${COMPLEX_ENABLE_MULTICORE}")
message(STATUS "* COMPLEX_ENABLE_COMPRESSORS: ${COMPLEX_ENABLE_COMPRESSORS}")
message(STATUS "* COMPLEX_DOWNLOAD_TEST_FILES: ${COMPLEX_DOWNLOAD_TEST_FILES}")
message(STATUS "* COMPLEX_WRITE_TEST_OUTPUT: ${COMPLEX_WRITE_TEST_OUTPUT}")

get_property(ComplexPluginTargets GLOBAL PROPERTY ComplexPluginTargets)
foreach(d3dPlugin ${ComplexPluginTargets})
message(STATUS "* COMPLEX_ENABLE_${d3dPlugin}: ${COMPLEX_ENABLE_${d3dPlugin}}")
endforeach()

message(STATUS "* COMPLEX_ENABLE_LINK_FILESYSTEM: ${COMPLEX_ENABLE_LINK_FILESYSTEM}")
message(STATUS "* COMPLEX_ENABLE_INSTALL: ${COMPLEX_ENABLE_INSTALL}")
message(STATUS "* COMPLEX_ENABLE_PACKAGING: ${COMPLEX_ENABLE_PACKAGING}")
message(STATUS "* COMPLEX_BUILD_DOCS: ${COMPLEX_BUILD_DOCS}")
message(STATUS "* DREAM3D_DATA_DIR: ${DREAM3D_DATA_DIR}")

set(ALL_PROJECTS complex)
foreach(proj ${ALL_PROJECTS})
# cmpGitRevisionString(PROJECT_NAME ${proj})
get_property(githash GLOBAL PROPERTY ${proj}_GIT_HASH)
message(STATUS "* ${proj}: ${${proj}_SOURCE_DIR} Git Hash: ${githash}")
message(STATUS "* -------------- Complex Python Configuration Options -------------------------------------")
message(STATUS "* COMPLEX_BUILD_PYTHON: ${COMPLEX_BUILD_PYTHON}")
message(STATUS "* COMPLEX_EMBED_PYTHON: ${COMPLEX_EMBED_PYTHON}")
message(STATUS "* Python3_EXECUTABLE: ${Python3_EXECUTABLE}")
message(STATUS "* MKDOCS_EXECUTABLE: ${MKDOCS_EXECUTABLE}")

message(STATUS "* -------------- Known Plugins ------------------------------------------------------")
foreach(plugin ${COMPLEX_PLUGIN_LIST})
message(STATUS "* COMPLEX_PLUGIN_ENABLE_${plugin}: ${COMPLEX_PLUGIN_ENABLE_${plugin}}")
endforeach()
message(STATUS "* -------------- Plugins ------------------------------------------------------")

message(STATUS "* -------------- Active Plugins ------------------------------------------------------")
get_property(ComplexPluginTargets GLOBAL PROPERTY ComplexPluginTargets)
foreach(d3dPlugin ${ComplexPluginTargets})
get_property(PluginNumFilters GLOBAL PROPERTY ${d3dPlugin}_filter_count)
Expand All @@ -93,4 +92,5 @@ foreach(d3dPlugin ${ComplexPluginTargets})
get_property(PluginDocsEnabled GLOBAL PROPERTY ${d3dPlugin}_docs_enabled)
message(STATUS "* ${d3dPlugin}: [${COMPLEX_PLUGIN_ENABLE_${d3dPlugin}}] ${PluginNumFilters} Filters Docs:[${PluginDocsEnabled}]")
endforeach()

message(STATUS "* ======================================================================")
52 changes: 38 additions & 14 deletions conda/bld.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
:: ****************************************************************************
:: This script file builds the necessary dependencies that are not found as
:: part of a python environment but are needed to ultimately build the
:: complex python bindings.
:: ****************************************************************************

mkdir sdk

rem "H5Support"
:: ****************************************************************************
:: Build the H5Support library
:: ****************************************************************************

mkdir h5support_build
cd h5support_build
Expand Down Expand Up @@ -30,7 +38,9 @@ if errorlevel 1 exit 1

cd ..

rem "EbsdLib"
:: ****************************************************************************
:: Build the EbsdLib library
:: ****************************************************************************

mkdir ebsdlib_build
cd ebsdlib_build
Expand Down Expand Up @@ -59,7 +69,9 @@ if errorlevel 1 exit 1

cd ..

rem "expected-lite"
:: ****************************************************************************
:: Build the expected-light library
:: ****************************************************************************

mkdir expected-lite_build
cd expected-lite_build
Expand All @@ -80,7 +92,9 @@ if errorlevel 1 exit 1

cd ..

rem "span-lite"
:: ****************************************************************************
:: Build the span-light library
:: ****************************************************************************

mkdir span-lite_build
cd span-lite_build
Expand All @@ -101,7 +115,9 @@ if errorlevel 1 exit 1

cd ..

rem "nod"
:: ****************************************************************************
:: Build the nod library
:: ****************************************************************************

mkdir nod_build
cd nod_build
Expand All @@ -118,9 +134,25 @@ if errorlevel 1 exit 1
cmake --build . --target install
if errorlevel 1 exit 1


:: ****************************************************************************
:: Install the EbsdLibrary into the python build environment so that stubgen
:: has access to it.
:: ****************************************************************************
cd ..
cd ebsdlib_build

cmake -D CMAKE_INSTALL_PREFIX:PATH="%LIBRARY_PREFIX%" .
if errorlevel 1 exit 1

rem "complex"
cmake --build . --target install
if errorlevel 1 exit 1

cd ..

:: ****************************************************************************
:: Build the complex library
:: ****************************************************************************

mkdir build
cd build
Expand All @@ -134,11 +166,3 @@ if errorlevel 1 exit 1
cmake --build . --target install
if errorlevel 1 exit 1

cd ..
cd ebsdlib_build

cmake -D CMAKE_INSTALL_PREFIX:PATH="%LIBRARY_PREFIX%" .
if errorlevel 1 exit 1

cmake --build . --target install
if errorlevel 1 exit 1
2 changes: 1 addition & 1 deletion conda/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ requirements:
- ninja
- git
host:
- "python {{ python }}"
- python
- mypy
- numpy >=1.16
- boost_mp11
Expand Down
4 changes: 3 additions & 1 deletion src/Plugins/TestOne/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
include("${complex_SOURCE_DIR}/cmake/Plugin.cmake")

set(PLUGIN_NAME "TestOne")
set(${PLUGIN_NAME}_SOURCE_DIR ${complex_SOURCE_DIR}/src/Plugins/${PLUGIN_NAME})

#------------------------------------------------------------------------------
# These are all the filters in the plugin. All filters should be kept in the
# PLUGIN_NAME/src/PLUGIN_NAME/Filters/ directory.
Expand All @@ -15,7 +17,7 @@ set(FilterList

create_complex_plugin(NAME ${PLUGIN_NAME}
FILTER_LIST ${FilterList}
DESCRIPTION "Plugin for Comp${PLUGIN_NAME}lexCore"
DESCRIPTION "Test Plugin for ${PLUGIN_NAME}"
VERSION "0.1.0"
)

Expand Down
4 changes: 3 additions & 1 deletion src/Plugins/TestTwo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
include("${complex_SOURCE_DIR}/cmake/Plugin.cmake")

set(PLUGIN_NAME "TestTwo")
set(${PLUGIN_NAME}_SOURCE_DIR ${complex_SOURCE_DIR}/src/Plugins/${PLUGIN_NAME})

#------------------------------------------------------------------------------
# These are all the filters in the plugin. All filters should be kept in the
# PLUGIN_NAME/src/PLUGIN_NAME/Filters/ directory.
Expand All @@ -10,7 +12,7 @@ set(FilterList

create_complex_plugin(NAME ${PLUGIN_NAME}
FILTER_LIST ${FilterList}
DESCRIPTION "Plugin for Comp${PLUGIN_NAME}lexCore"
DESCRIPTION "Test Plugin for ${PLUGIN_NAME}"
VERSION "0.1.0"
)

Expand Down
21 changes: 15 additions & 6 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ find_package(Catch2 CONFIG REQUIRED)

include(Catch)

get_property(COMPLEX_PLUGIN_COUNT GLOBAL PROPERTY COMPLEX_PLUGIN_COUNT)
add_subdirectory(${complex_SOURCE_DIR}/src/Plugins/TestOne ${complex_BINARY_DIR}/Plugins/TestOne)
add_subdirectory(${complex_SOURCE_DIR}/src/Plugins/TestTwo ${complex_BINARY_DIR}/Plugins/TestTwo)
MATH(EXPR COMPLEX_PLUGIN_COUNT "${COMPLEX_PLUGIN_COUNT}+2")

add_subdirectory(UnitTestCommon)

add_executable(complex_test
Expand Down Expand Up @@ -51,9 +46,23 @@ target_link_libraries(complex_test
complex::UnitTestCommon
)

#------------------------------------------------------------------------------
# Require that the test plugins are built before tests because some tests
# require loading from those plugins but don't want to link to them.
add_dependencies(complex_test TestOne TestTwo)
get_property(COMPLEX_PLUGIN_COUNT GLOBAL PROPERTY COMPLEX_PLUGIN_COUNT)

#------------------------------------------------------------------------------
# Create dependencies with complex_test on each of the test plugins
#------------------------------------------------------------------------------
if(COMPLEX_PLUGIN_ENABLE_TestOne)
MATH(EXPR COMPLEX_PLUGIN_COUNT "${COMPLEX_PLUGIN_COUNT}+1")
add_dependencies(complex_test TestOne)
endif()

if(COMPLEX_PLUGIN_ENABLE_TestTwo)
MATH(EXPR COMPLEX_PLUGIN_COUNT "${COMPLEX_PLUGIN_COUNT}+1")
add_dependencies(complex_test TestTwo)
endif()

set_target_properties(complex_test
PROPERTIES
Expand Down
7 changes: 7 additions & 0 deletions wrapping/python/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ Create the package from the `complex` sources
[user@host] $ cd complex/conda
[user@host] $ conda build .

For faster environment solves mamba can also be used.

```
conda install boa
conda mambabuild --python 3.8|3.9|3.10 .
```

### Uploading to Anaconda.org

[user@host] $ conda login
Expand Down

0 comments on commit 78942f3

Please sign in to comment.