Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CONDA: Various fixes to allow packaging of python bindings. #691

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
list(APPEND 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
19 changes: 13 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,21 @@ 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)
add_dependencies(complex_test TestOne)
endif()

if(COMPLEX_PLUGIN_ENABLE_TestTwo)
add_dependencies(complex_test TestTwo)
endif()

set_target_properties(complex_test
PROPERTIES
Expand Down
19 changes: 19 additions & 0 deletions test/PluginTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ TEST_CASE("Test Loading Plugins")
const auto& filterHandles = filterList->getFilterHandles();
auto plugins = filterList->getLoadedPlugins();

if(plugins.size() != COMPLEX_PLUGIN_COUNT)
{
std::cout << "Incorrect number of plugins were loaded.\n"
<< "Expected: " << COMPLEX_PLUGIN_COUNT << "\nLoaded: " << plugins.size() << "\nLoaded Plugins are:\n";
for(auto const& plugin : plugins)
{
std::cout << plugin->getName() << std::endl;
}
}

REQUIRE(plugins.size() == COMPLEX_PLUGIN_COUNT);
REQUIRE(filterHandles.size() >= 2);

Expand Down Expand Up @@ -62,6 +72,15 @@ TEST_CASE("Test Singleton")
auto plugins = filterList->getLoadedPlugins();

// Check plugins were loaded
if(plugins.size() != COMPLEX_PLUGIN_COUNT)
{
std::cout << "Incorrect number of plugins were loaded.\n"
<< "Expected: " << COMPLEX_PLUGIN_COUNT << "\nLoaded: " << plugins.size() << "\nLoaded Plugins are:\n";
for(auto const& plugin : plugins)
{
std::cout << plugin->getName() << std::endl;
}
}
REQUIRE(plugins.size() == COMPLEX_PLUGIN_COUNT);

// Check filters loaded
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
15 changes: 10 additions & 5 deletions wrapping/python/docs/generate_sphinx_docs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ void GenerateRstFilterDocs()
IFilter::UniquePointer filter = filterListPtr->createFilter(filterHandle);
// auto plugin = filterListPtr->getPlugin(filterHandle);

rstStream << filterClassName << "\n";
rstStream << GenerateUnderline(filterClassName.size(), '-') << "\n\n";

rstStream << ".. _" << filterClassName << ":\n";
rstStream << ".. py:class:: " << filterClassName << "\n\n";

Expand Down Expand Up @@ -399,18 +402,16 @@ void GenerateRstFilterDocs()
}
rstStream << '\n';

rstStream << " .. py:method:: Execute(";
rstStream << " .. py:method:: Execute(data_structure";

std::stringstream memberStream;
memberStream << " :param complex.DataStructure data_structure: The DataStructure object that holds the data to be processed.\n";

size_t index = 0;
for(const auto& parameterPair : parameters)
{
auto const& anyParameter = parameterPair.second;
if(index != 0)
{
rstStream << ", ";
}
rstStream << ", ";

rstStream << parameterPair.first;
memberStream << " :param " << s_ParameterMap[anyParameter->uuid()] << " " << anyParameter->name() << ": " << anyParameter->helpText() << "\n";
Expand Down Expand Up @@ -466,6 +467,10 @@ void GenerateIndexRstFile()
for(const auto& plugin : pluginListPtr)
{
std::string plugName = plugin->getName();
if(plugName == "TestOne" || plugName == "TestTwo")
{
continue;
}
const std::string pluginRootDir = fmt::format("{}", s_PluginDirMap[plugName]);

if(plugName == "ComplexCore")
Expand Down
2 changes: 1 addition & 1 deletion wrapping/python/examples/angle_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
data_structure = cx.DataStructure()
# Create a DataArray to copy the Euler Angles into
array_path = cx.DataPath(['Euler Angles'])
result = cx.CreateDataArray.execute(data_structure,
result = cx.CreateDataArray.execute(data_structure=data_structure,
numeric_type=cx.NumericType.float32,
component_count=3,
tuple_dimensions=[[99]],
Expand Down