Skip to content

Commit 3c999c0

Browse files
author
Sam Hatchett
committed
temporarily remove output library, update for epanet 2.3.3
1 parent dae4bca commit 3c999c0

5 files changed

Lines changed: 100 additions & 7 deletions

File tree

owa-epanet/CMakeLists.txt

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.8)
22

3-
project(owa-epanet)
3+
project(owa-epanet LANGUAGES C CXX)
44
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
55

66
if(SKBUILD)
@@ -18,8 +18,8 @@ endif()
1818
find_package(SWIG REQUIRED)
1919
cmake_policy(SET CMP0078 NEW)
2020
cmake_policy(SET CMP0086 NEW)
21+
set(CMAKE_SWIG_FLAGS -c++)
2122
include(${SWIG_USE_FILE})
22-
set(CMAKE_SWIG_FLAGS -py3)
2323

2424
message("PYTHONLIBS_VERSION_STRING: ${PYTHONLIBS_VERSION_STRING}")
2525
message("CMAKE_SWIG_FLAGS: ${CMAKE_SWIG_FLAGS}")
@@ -50,7 +50,17 @@ set_property(TARGET epanet2
5050
PROPERTY
5151
USE_TARGET_INCLUDE_DIRECTORIES TRUE
5252
)
53+
#set_property(SOURCE wrapper/output.i
54+
# PROPERTY
55+
# USE_TARGET_INCLUDE_DIRECTORIES TRUE
56+
#)
57+
#set_property(TARGET epanet-output
58+
# PROPERTY
59+
# USE_TARGET_INCLUDE_DIRECTORIES TRUE
60+
#)
5361

62+
63+
set_property(SOURCE wrapper/toolkit.i PROPERTY CPLUSPLUS ON)
5464
# Create cmake target
5565
swig_add_library(toolkit
5666
TYPE
@@ -71,14 +81,37 @@ target_link_options(toolkit
7181
$<$<BOOL:${APPLE}>:-undefined dynamic_lookup>
7282
)
7383

74-
75-
7684
swig_link_libraries(toolkit
7785
PUBLIC
7886
$<$<BOOL:$<C_COMPILER_ID:MSVC>>:Python3::Module>
7987
epanet2
8088
)
8189

90+
#swig_add_library(output
91+
# TYPE
92+
# MODULE
93+
# LANGUAGE
94+
# python
95+
# SOURCES
96+
# wrapper/output.i
97+
#)
98+
99+
#target_include_directories(output
100+
# PUBLIC
101+
# ${Python3_INCLUDE_DIRS}
102+
#)
103+
104+
#target_link_options(output
105+
# PUBLIC
106+
# $<$<BOOL:${APPLE}>:-undefined dynamic_lookup>
107+
#)
108+
109+
#swig_link_libraries(output
110+
# PUBLIC
111+
# $<$<BOOL:$<C_COMPILER_ID:MSVC>>:Python3::Module>
112+
# epanet-output
113+
#)
114+
82115
set_target_properties(toolkit
83116
PROPERTIES
84117
SWIG_COMPILE_DEFINITIONS EXPORT_OUT_API
@@ -89,7 +122,20 @@ set_target_properties(toolkit
89122
INSTALL_RPATH_USE_LINK_PATH TRUE
90123
)
91124

125+
126+
#set_target_properties(output
127+
# PROPERTIES
128+
# MACOSX_RPATH TRUE
129+
# SKIP_BUILD_RPATH FALSE
130+
# BUILD_WITH_INSTALL_RPATH FALSE
131+
# INSTALL_RPATH "${PACKAGE_RPATH}"
132+
# INSTALL_RPATH_USE_LINK_PATH TRUE
133+
#
134+
135+
92136
install(TARGETS toolkit LIBRARY DESTINATION packages/epanet)
137+
#install(TARGETS output LIBRARY DESTINATION packages/epanet)
138+
93139

94140
add_custom_command(
95141
TARGET toolkit
@@ -102,3 +148,15 @@ add_custom_command(
102148
${CMAKE_SOURCE_DIR}/packages/epanet
103149
)
104150

151+
152+
#add_custom_command(
153+
# TARGET output
154+
# POST_BUILD
155+
# COMMAND ${CMAKE_COMMAND} -E copy
156+
# "${CMAKE_CURRENT_BINARY_DIR}/output.py"
157+
# $<$<BOOL:${WIN32}>:${CMAKE_CURRENT_BINARY_DIR}/_output.pyd>
158+
# $<$<BOOL:${WIN32}>:${CMAKE_CURRENT_BINARY_DIR}/bin/epanet-output.dll>
159+
# $<$<NOT:$<BOOL:${WIN32}>>:${CMAKE_CURRENT_BINARY_DIR}/lib/libepanet-output.*>
160+
# ${CMAKE_SOURCE_DIR}/packages/epanet
161+
#)
162+

owa-epanet/EPANET

Submodule EPANET updated 109 files

owa-epanet/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name = "owa-epanet",
9-
version = "2.2.4",
9+
version = "2.3.3",
1010
author = "Sam Hatchett",
1111
author_email = "samhatchett@gmail.com",
1212
description = "a thin wrapper for epanet hydraulic toolkit",

owa-epanet/wrapper/output.i

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
%include "typemaps.i"
22
%include "cstring.i"
3+
%include "carrays.i"
34

45
/* epanet simple python wrapper */
56
%module (package="epanet") output
67
%{
7-
#define SHARED_EXPORTS_BUILT_AS_STATIC
8+
#define EXPORT_OUT_API
89
#include <epanet_output.h>
910
%}
1011
%include <epanet_output_enums.h>
@@ -91,6 +92,7 @@
9192

9293
%feature("autodoc", "2");
9394
#define SHARED_EXPORTS_BUILT_AS_STATIC
95+
#define EXPORT_OUT_API
9496
%include <epanet_output.h>
9597

9698
%exception;

owa-epanet/wrapper/toolkit.i

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,39 @@
2222
%typemap(argout) EN_Project* {
2323
%append_output(SWIG_NewPointerObj(*$1, SWIGTYPE_p_Project, SWIG_POINTER_NEW));
2424
}
25+
/*
26+
This is the same logic applied in swmm toolkit to handle a breaking change
27+
introduced in the version 4.3 of SWIG. Credit: karosc
28+
29+
See https://github.com/karosc/swmm-python/commit/1ef854ac469c1e2df29f9bb1ed718361df79cc95
30+
*/
31+
%header %{
32+
SWIGINTERN PyObject*
33+
Custom_SWIG_Python_AppendOutput(PyObject* result, PyObject* obj, int is_void) {
34+
if (!result) {
35+
result = obj;
36+
} else if (result == Py_None) {
37+
SWIG_Py_DECREF(result);
38+
result = obj;
39+
} else {
40+
if (!PyList_Check(result)) {
41+
PyObject *o2 = result;
42+
result = PyList_New(1);
43+
if (result) {
44+
PyList_SET_ITEM(result, 0, o2);
45+
} else {
46+
SWIG_Py_DECREF(obj);
47+
return o2;
48+
}
49+
}
50+
PyList_Append(result,obj);
51+
SWIG_Py_DECREF(obj);
52+
}
53+
return result;
54+
}
55+
#define SWIG_Python_AppendOutput Custom_SWIG_Python_AppendOutput
56+
%}
57+
2558

2659
/* TYPEMAP FOR IGNORING INT ERROR CODE RETURN VALUE */
2760
%typemap(out) int {

0 commit comments

Comments
 (0)