Skip to content

Commit d05187e

Browse files
authored
Get rid of _io cpp target (#322)
1 parent c26c9fe commit d05187e

File tree

6 files changed

+16
-22
lines changed

6 files changed

+16
-22
lines changed

python/ikarus/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ set_property(
1515
PROPERTY LINK_LIBRARIES dunecommon ikarus
1616
APPEND
1717
)
18-
add_dependencies(_ikarus _io)
1918

2019
if(SKBUILD)
2120
install(TARGETS _ikarus LIBRARY DESTINATION python/ikarus)

python/ikarus/_ikarus.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <config.h>
55

6+
#include "io/io.hh"
67
#include "pythonhelpers.hh"
78

89
#include <dune/common/float_cmp.hh>
@@ -108,4 +109,6 @@ PYBIND11_MODULE(_ikarus, m) {
108109

109110
pybind11::class_<NeoHooke> nh(materials, "NeoHooke");
110111
Ikarus::Python::registerNeoHooke(materials, nh);
112+
113+
addBindingsToIO();
111114
}

python/ikarus/io/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,3 @@
22
# SPDX-License-Identifier: LGPL-3.0-or-later
33

44
add_python_targets(io __init__)
5-
6-
dune_add_pybind11_module(NAME _io SOURCES _io.cc)
7-
8-
set_property(
9-
TARGET _io
10-
PROPERTY LINK_LIBRARIES dunecommon ikarus
11-
APPEND
12-
)
13-
14-
if(SKBUILD)
15-
install(TARGETS _io LIBRARY DESTINATION python/ikarus/io)
16-
endif()

python/ikarus/io/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import types
1111
from enum import Enum
1212

13-
from ._io import DataTag
14-
1513
# The list of supported dataCollectors
1614
DataCollector = Enum("DataCollector", ["default", "lagrange", "discontinuous", "iga"])
1715

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
// SPDX-FileCopyrightText: 2021-2024 The Ikarus Developers [email protected]
22
// SPDX-License-Identifier: LGPL-3.0-or-later
33

4-
#include <config.h>
5-
4+
/**
5+
* \file io.hh
6+
* \brief Additional python bindings for submodule io
7+
*/
68
#include "../pythonhelpers.hh"
79

8-
#include <dune/python/common/typeregistry.hh>
910
#include <dune/python/pybind11/eigen.h>
1011
#include <dune/python/pybind11/operators.h>
1112
#include <dune/python/pybind11/pybind11.h>
1213

1314
#include <ikarus/io/vtkdatatag.hh>
1415

15-
PYBIND11_MODULE(_io, m) {
16+
void addBindingsToIO() {
1617
namespace py = pybind11;
1718
using namespace pybind11::literals;
19+
using namespace Ikarus;
20+
21+
auto io = pybind11::module::import("ikarus.io");
1822

1923
using namespace Ikarus::Vtk;
2024
using namespace Ikarus;
21-
ENUM_BINDINGS(DataTag);
25+
ENUM_BINDINGS_WITH_MODULE(DataTag, io);
2226
}

python/ikarus/pythonhelpers.hh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
#pragma once
55

6-
#define ENUM_BINDINGS(Type) \
7-
py::enum_<Type> Type##Enum(m, #Type); \
6+
#define ENUM_BINDINGS_WITH_MODULE(Type, module) \
7+
py::enum_<Type> Type##Enum(module, #Type); \
88
Type Type##EnumV = Type::BEGIN; \
99
Ikarus::increment(Type##EnumV); \
1010
for (; Type##EnumV != Type::END; Ikarus::increment(Type##EnumV)) \
1111
Type##Enum.value(toString(Type##EnumV).c_str(), Type##EnumV);
12+
13+
#define ENUM_BINDINGS(Type) ENUM_BINDINGS_WITH_MODULE(Type, m)

0 commit comments

Comments
 (0)