Skip to content
Open
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
1 change: 1 addition & 0 deletions cmake/Utility.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ function(AddPythonTest)
ENVIRONMENT
"PYTHON_TEST_FILE=${ARGS_FILE}"
"PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}"
"Python3_EXECUTABLE=${Python3_EXECUTABLE}"
)
else()
add_test(NAME ${ARGS_NAME}
Expand Down
43 changes: 30 additions & 13 deletions wrapping/python/CxPybind/CxPybind/CxPybind.hpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
#pragma once

#include <pybind11/pybind11.h>
#include <simplnx/Common/ScopeGuard.hpp>
#include <simplnx/Core/Application.hpp>
#include <simplnx/Filter/Arguments.hpp>
#include <simplnx/Filter/FilterTraits.hpp>
#include <simplnx/Filter/IFilter.hpp>
#include <simplnx/Filter/IParameter.hpp>
#include <simplnx/Filter/ParameterTraits.hpp>
#include <simplnx/Filter/Parameters.hpp>
#include <simplnx/Plugin/AbstractPlugin.hpp>
#include <simplnx/Plugin/PluginLoader.hpp>

#include <pybind11/functional.h>
#include <pybind11/numpy.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/stl/filesystem.h>

#if PYBIND11_HAS_NATIVE_ENUM
#include <pybind11/native_enum.h>
#endif

#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/integral.hpp>
#include <boost/mp11/list.hpp>

#include <fmt/ranges.h>

#include <simplnx/Common/ScopeGuard.hpp>
#include <simplnx/Core/Application.hpp>
#include <simplnx/Filter/Arguments.hpp>
#include <simplnx/Filter/FilterTraits.hpp>
#include <simplnx/Filter/IFilter.hpp>
#include <simplnx/Filter/IParameter.hpp>
#include <simplnx/Filter/ParameterTraits.hpp>
#include <simplnx/Filter/Parameters.hpp>
#include <simplnx/Plugin/AbstractPlugin.hpp>
#include <simplnx/Plugin/PluginLoader.hpp>

#include <any>
#include <memory>
#include <type_traits>
Expand Down Expand Up @@ -111,11 +114,25 @@ std::string GetFixedPythonTypeCasterName()
template <class T>
std::string GetFullPythonName()
{
using CasterT = py::detail::make_caster<T>;
// Use py::type::of for registered C++ types otherwise use py::detail::type_caster::name
if constexpr(std::is_base_of_v<py::detail::type_caster_generic, py::detail::make_caster<T>>)
if constexpr(std::is_base_of_v<py::detail::type_caster_generic, CasterT>)
{
return GetRegisteredPythonTypeName<T>();
}
#if PYBIND11_HAS_NATIVE_ENUM
else if constexpr(std::is_base_of_v<py::detail::type_caster_enum_type<T>, CasterT>) // Is registered enum
{
const std::type_info& typeInfo = typeid(T);
py::handle nativeEnumHandle = py::detail::global_internals_native_enum_type_map_get_item(typeInfo);
if(nativeEnumHandle)
{
return GetFullPythonNameFromType(nativeEnumHandle);
}
py::handle handle = py::detail::get_type_handle(typeInfo, true);
return GetFullPythonNameFromType(handle);
}
#endif
else
{
return GetFixedPythonTypeCasterName<T>();
Expand Down
5 changes: 3 additions & 2 deletions wrapping/python/testing/anaconda_test.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
echo "PYTHON_TEST_FILE: %PYTHON_TEST_FILE%"
echo "PYTHONPATH: %PYTHONPATH%"
echo "PYTHON_EXECUTABLE: %PYTHON_EXECUTABLE%"
echo "Python3_EXECUTABLE: %Python3_EXECUTABLE%"

:: CALL "%complex_CONDA_EXECUTABLE%" activate "%complex_CONDA_ENV%"

echo "PATH: %PATH%"
:: echo "Where is Python: "
:: where python.exe
echo "Python Version: "
%PYTHON_EXECUTABLE% --version
%Python3_EXECUTABLE% --version
if %errorlevel% neq 0 exit 1

%PYTHON_EXECUTABLE% "%PYTHON_TEST_FILE%"
%Python3_EXECUTABLE% "%PYTHON_TEST_FILE%"
3 changes: 2 additions & 1 deletion wrapping/python/testing/anaconda_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
echo "PYTHON_TEST_FILE: $PYTHON_TEST_FILE"
echo "PYTHONPATH: $PYTHONPATH"
echo "PYTHON_EXECUTABLE: $PYTHON_EXECUTABLE"
echo "Python3_EXECUTABLE: $Python3_EXECUTABLE"

# echo "Sourcing $complex_ANACONDA_DIR/etc/profile.d/conda.sh"
# source "$complex_ANACONDA_DIR"/etc/profile.d/conda.sh
Expand All @@ -19,4 +20,4 @@ echo "PATH: $PATH"
#PYTHONEXE=`which python`
#echo "Python Version: " `${PYTHONEXE} --version`

${PYTHON_EXECUTABLE} "$PYTHON_TEST_FILE"
${Python3_EXECUTABLE} "$PYTHON_TEST_FILE"
Loading