From 1e59046cb15fe7f7f79122fe8d48905f8315bdc4 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 20 Jul 2018 09:51:37 -0400 Subject: [PATCH 1/8] Rearranging project layout --- swmm-toolkit/setup.py => setup.py | 32 ++++--- swmm-toolkit/src/swmm_toolkit.i | 145 ------------------------------ toolkit/toolkit.i | 145 ++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+), 159 deletions(-) rename swmm-toolkit/setup.py => setup.py (58%) delete mode 100644 swmm-toolkit/src/swmm_toolkit.i create mode 100644 toolkit/toolkit.i diff --git a/swmm-toolkit/setup.py b/setup.py similarity index 58% rename from swmm-toolkit/setup.py rename to setup.py index 759ff316..d04c935f 100644 --- a/swmm-toolkit/setup.py +++ b/setup.py @@ -18,22 +18,26 @@ from distutils.core import setup, Extension from distutils.command.build_ext import build_ext -setup( - name = "swmm-toolkit", - version = "0.0.1", - ext_modules = [ - Extension("_swmm_toolkit", - include_dirs = ['include/'], +toolkit_ext = Extension("_toolkit", + include_dirs = ['toolkit/include/'], libraries = ['swmm5'], - library_dirs = ['lib/'], - sources = ['src/swmm_toolkit.i'], - swig_opts=['-py3'], + library_dirs = ['toolkit/lib/'], + sources = ['toolkit/toolkit.i'], + swig_opts = ['-py3'], language = 'C' - ) - ], - package_dir = {'':'src'}, - py_modules = ['swmm_toolkit'], - + ) + +setup( + name = "swmm-python", + version = "0.0.1", + ext_modules = [toolkit_ext], + + py_modules = ['toolkit'], + package_dir = {'':'toolkit'}, + + include_package_data = True, + zip_safe = False, + install_requires = [ 'enum34' ] diff --git a/swmm-toolkit/src/swmm_toolkit.i b/swmm-toolkit/src/swmm_toolkit.i deleted file mode 100644 index 7e0d5d88..00000000 --- a/swmm-toolkit/src/swmm_toolkit.i +++ /dev/null @@ -1,145 +0,0 @@ -/* - * swmm_toolkit.i - SWIG interface description file for SWMM toolkit - * - * Created: 7/2/2018 - * Author: Michael E. Tryby - * US EPA - ORD/NRMRL - * - * Build command: - * $ python setup.py build - * -*/ - -%module swmm_toolkit -%{ -#include "swmm5.h" -#include "toolkitAPI.h" - -#define SWIG_FILE_WITH_INIT -%} - -%include "typemaps.i" - -/* DEFINE AND TYPEDEF MUST BE INCLUDED */ -typedef void* SWMM_ProjectHandle; - - -#ifdef WINDOWS - #ifdef __cplusplus - #define DLLEXPORT __declspec(dllexport) __cdecl - #else - #define DLLEXPORT __declspec(dllexport) __stdcall - #endif -#else - #define DLLEXPORT -#endif - - -/* TYPEMAPS FOR OPAQUE POINTER */ -/* Used for functions that output a new opaque pointer */ -%typemap(in, numinputs=0) SWMM_ProjectHandle* ph_out (SWMM_ProjectHandle retval) -{ - /* OUTPUT in */ - retval = NULL; - $1 = &retval; -} -/* used for functions that take in an opaque pointer (or NULL) -and return a (possibly) different pointer */ -%typemap(argout) SWMM_ProjectHandle* ph_out, SWMM_ProjectHandle* ph_inout -{ - /* OUTPUT argout */ - %append_output(SWIG_NewPointerObj(SWIG_as_voidptr(retval$argnum), $1_descriptor, 0)); -} -%typemap(in) SWMM_ProjectHandle* ph_inout (SWMM_ProjectHandle retval) -{ - /* INOUT in */ - SWIG_ConvertPtr(obj0,SWIG_as_voidptrptr(&retval), 0, 0); - $1 = &retval; -} -/* No need for special IN typemap for opaque pointers, it works anyway */ - -/* TYPEMAP FOR IGNORING INT ERROR CODE RETURN VALUE */ -%typemap(out) int { - $result = Py_None; - Py_INCREF($result); -} - - -/* INSERTS CUSTOM EXCEPTION HANDLING IN WRAPPER */ -%exception -{ - char* err_msg; - swmm_clearError_project(arg1); - $function - if (swmm_checkError_project(arg1, &err_msg)) - { - PyErr_SetString(PyExc_Exception, err_msg); - free(err_msg); - SWIG_fail; - } -} - -// CANONICAL API -int DLLEXPORT swmm_run_project(SWMM_ProjectHandle ph, const char* f1, const char* f2, const char* f3); -int DLLEXPORT swmm_open_project(SWMM_ProjectHandle ph, const char* f1, const char* f2, const char* f3); -int DLLEXPORT swmm_start_project(SWMM_ProjectHandle ph, int saveFlag); -int DLLEXPORT swmm_step_project(SWMM_ProjectHandle ph, double* elapsedTime); -int DLLEXPORT swmm_end_project(SWMM_ProjectHandle ph); -int DLLEXPORT swmm_report_project(SWMM_ProjectHandle ph); -int DLLEXPORT swmm_getMassBalErr_project(SWMM_ProjectHandle ph, float* runoffErr, float* flowErr, float* qualErr); -int DLLEXPORT swmm_close_project(SWMM_ProjectHandle ph); -int DLLEXPORT swmm_getError_project(SWMM_ProjectHandle ph, char* errMsg, int msgLen); -int DLLEXPORT swmm_getWarnings_project(SWMM_ProjectHandle ph); - -// NEW TOOLKIT API -int DLLEXPORT swmm_getSimulationUnit_project(SWMM_ProjectHandle ph, int type, int *value); -int DLLEXPORT swmm_getSimulationAnalysisSetting_project(SWMM_ProjectHandle ph, int type, int *value); -int DLLEXPORT swmm_getSimulationParam_project(SWMM_ProjectHandle ph, int type, double *value); -int DLLEXPORT swmm_countObjects_project(SWMM_ProjectHandle ph, int type, int *count); -int DLLEXPORT swmm_getObjectId_project(SWMM_ProjectHandle ph, int type, int index, char *id); -int DLLEXPORT swmm_getNodeType_project(SWMM_ProjectHandle ph, int index, int *Ntype); -int DLLEXPORT swmm_getLinkType_project(SWMM_ProjectHandle ph, int index, int *Ltype); -int DLLEXPORT swmm_getLinkConnections_project(SWMM_ProjectHandle ph, int index, int *Node1, int *Node2); -int DLLEXPORT swmm_getLinkDirection_project(SWMM_ProjectHandle ph, int index, signed char *value); -int DLLEXPORT swmm_getSubcatchOutConnection_project(SWMM_ProjectHandle ph, int index, int *type, int *ObjIndex ); -int DLLEXPORT swmm_getNodeParam_project(SWMM_ProjectHandle ph, int index, int Param, double *value); -int DLLEXPORT swmm_setNodeParam_project(SWMM_ProjectHandle ph, int index, int Param, double value); -int DLLEXPORT swmm_getLinkParam_project(SWMM_ProjectHandle ph, int index, int Param, double *value); -int DLLEXPORT swmm_setLinkParam_project(SWMM_ProjectHandle ph, int index, int Param, double value); -int DLLEXPORT swmm_getSubcatchParam_project(SWMM_ProjectHandle ph, int index, int Param, double *value); -int DLLEXPORT swmm_setSubcatchParam_project(SWMM_ProjectHandle ph, int index, int Param, double value); -int DLLEXPORT swmm_getSimulationDateTime_project(SWMM_ProjectHandle ph, int timetype, int *year, int *month, int *day, int *hours, int *minutes, int *seconds); -int DLLEXPORT swmm_setSimulationDateTime_project(SWMM_ProjectHandle ph, int timetype, char *dtimestr); - -// Active Simulation Results API -int DLLEXPORT swmm_getCurrentDateTimeStr_project(SWMM_ProjectHandle ph, char *dtimestr); -int DLLEXPORT swmm_getNodeResult_project(SWMM_ProjectHandle ph, int index, int type, double *result); -int DLLEXPORT swmm_getLinkResult_project(SWMM_ProjectHandle ph, int index, int type, double *result); -int DLLEXPORT swmm_getSubcatchResult_project(SWMM_ProjectHandle ph, int index, int type, double *result); -int DLLEXPORT swmm_getNodeStats_project(SWMM_ProjectHandle ph, int index, SM_NodeStats *nodeStats); -int DLLEXPORT swmm_getNodeTotalInflow_project(SWMM_ProjectHandle ph, int index, double *value); -int DLLEXPORT swmm_getStorageStats_project(SWMM_ProjectHandle ph, int index, SM_StorageStats *storageStats);\ -int DLLEXPORT swmm_getOutfallStats_project(SWMM_ProjectHandle ph, int index, SM_OutfallStats *outfallStats); -//void DLLEXPORT swmm_freeOutfallStats(SM_OutfallStats *outfallStats); -int DLLEXPORT swmm_getLinkStats_project(SWMM_ProjectHandle ph, int index, SM_LinkStats *linkStats); -int DLLEXPORT swmm_getPumpStats_project(SWMM_ProjectHandle ph, int index, SM_PumpStats *pumpStats); -int DLLEXPORT swmm_getGagePrecip_project(SWMM_ProjectHandle ph, int index, double *rainfall, double *snowfall, double *total); -int DLLEXPORT swmm_getSubcatchStats_project(SWMM_ProjectHandle ph, int index, SM_SubcatchStats *subcatchStats); -//void DLLEXPORT swmm_freeSubcatchStats(SM_SubcatchStats *subcatchStats); -int DLLEXPORT swmm_getSystemRoutingStats_project(SWMM_ProjectHandle ph, SM_RoutingTotals *routingTot); -int DLLEXPORT swmm_getSystemRunoffStats_project(SWMM_ProjectHandle ph, SM_RunoffTotals *runoffTot); - -// Setters API -int DLLEXPORT swmm_setLinkSetting_project(SWMM_ProjectHandle ph, int index, double setting); -int DLLEXPORT swmm_setNodeInflow_project(SWMM_ProjectHandle ph, int index, double flowrate); -int DLLEXPORT swmm_setOutfallStage_project(SWMM_ProjectHandle ph, int index, double stage); -int DLLEXPORT swmm_setGagePrecip_project(SWMM_ProjectHandle ph, int index, double value); - -%exception; - -/* NO EXCEPTION HANDLING FOR THESE FUNCTIONS */ -int DLLEXPORT swmm_alloc_project(SWMM_ProjectHandle *ph_out); -int DLLEXPORT swmm_free_project(SWMM_ProjectHandle *ph_out); - -void DLLEXPORT swmm_clearError_project(SWMM_ProjectHandle ph); -int DLLEXPORT swmm_checkError_project(SWMM_ProjectHandle ph, char** msg_buffer); diff --git a/toolkit/toolkit.i b/toolkit/toolkit.i new file mode 100644 index 00000000..68b97836 --- /dev/null +++ b/toolkit/toolkit.i @@ -0,0 +1,145 @@ +/* + * swmm_toolkit.i - SWIG interface description file for SWMM toolkit + * + * Created: 7/2/2018 + * Author: Michael E. Tryby + * US EPA - ORD/NRMRL + * + * Build command: + * $ python setup.py build + * +*/ + +%module swmm_toolkit +%{ +#include "swmm5.h" +#include "toolkitAPI.h" + +#define SWIG_FILE_WITH_INIT +%} + +%include "typemaps.i" + +/* DEFINE AND TYPEDEF MUST BE INCLUDED */ +typedef void* SWMM_ProjectHandle; + + +#ifdef WINDOWS + #ifdef __cplusplus + #define DLLEXPORT __declspec(dllexport) __cdecl + #else + #define DLLEXPORT __declspec(dllexport) __stdcall + #endif +#else + #define DLLEXPORT +#endif + + +/* TYPEMAPS FOR OPAQUE POINTER */ +/* Used for functions that output a new opaque pointer */ +%typemap(in, numinputs=0) SWMM_ProjectHandle* ph_out (SWMM_ProjectHandle retval) +{ + /* OUTPUT in */ + retval = NULL; + $1 = &retval; +} +/* used for functions that take in an opaque pointer (or NULL) +and return a (possibly) different pointer */ +%typemap(argout) SWMM_ProjectHandle* ph_out, SWMM_ProjectHandle* ph_inout +{ + /* OUTPUT argout */ + %append_output(SWIG_NewPointerObj(SWIG_as_voidptr(retval$argnum), $1_descriptor, 0)); +} +%typemap(in) SWMM_ProjectHandle* ph_inout (SWMM_ProjectHandle retval) +{ + /* INOUT in */ + SWIG_ConvertPtr(obj0,SWIG_as_voidptrptr(&retval), 0, 0); + $1 = &retval; +} +/* No need for special IN typemap for opaque pointers, it works anyway */ + +/* TYPEMAP FOR IGNORING INT ERROR CODE RETURN VALUE */ +%typemap(out) int { + $result = Py_None; + Py_INCREF($result); +} + + +/* INSERTS CUSTOM EXCEPTION HANDLING IN WRAPPER */ +%exception +{ + char* err_msg; + swmm_clearError_project(arg1); + $function + if (swmm_checkError_project(arg1, &err_msg)) + { + PyErr_SetString(PyExc_Exception, err_msg); + free(err_msg); + SWIG_fail; + } +} + +// CANONICAL API +int DLLEXPORT swmm_run_project(SWMM_ProjectHandle ph, const char* f1, const char* f2, const char* f3); +int DLLEXPORT swmm_open_project(SWMM_ProjectHandle ph, const char* f1, const char* f2, const char* f3); +int DLLEXPORT swmm_start_project(SWMM_ProjectHandle ph, int saveFlag); +int DLLEXPORT swmm_step_project(SWMM_ProjectHandle ph, double* elapsedTime); +int DLLEXPORT swmm_end_project(SWMM_ProjectHandle ph); +int DLLEXPORT swmm_report_project(SWMM_ProjectHandle ph); +int DLLEXPORT swmm_getMassBalErr_project(SWMM_ProjectHandle ph, float* runoffErr, float* flowErr, float* qualErr); +int DLLEXPORT swmm_close_project(SWMM_ProjectHandle ph); +int DLLEXPORT swmm_getError_project(SWMM_ProjectHandle ph, char* errMsg, int msgLen); +int DLLEXPORT swmm_getWarnings_project(SWMM_ProjectHandle ph); + +// NEW TOOLKIT API +//int DLLEXPORT swmm_getSimulationUnit_project(SWMM_ProjectHandle ph, int type, int *value); +//int DLLEXPORT swmm_getSimulationAnalysisSetting_project(SWMM_ProjectHandle ph, int type, int *value); +//int DLLEXPORT swmm_getSimulationParam_project(SWMM_ProjectHandle ph, int type, double *value); +//int DLLEXPORT swmm_countObjects_project(SWMM_ProjectHandle ph, int type, int *count); +//int DLLEXPORT swmm_getObjectId_project(SWMM_ProjectHandle ph, int type, int index, char *id); +//int DLLEXPORT swmm_getNodeType_project(SWMM_ProjectHandle ph, int index, int *Ntype); +//int DLLEXPORT swmm_getLinkType_project(SWMM_ProjectHandle ph, int index, int *Ltype); +//int DLLEXPORT swmm_getLinkConnections_project(SWMM_ProjectHandle ph, int index, int *Node1, int *Node2); +//int DLLEXPORT swmm_getLinkDirection_project(SWMM_ProjectHandle ph, int index, signed char *value); +//int DLLEXPORT swmm_getSubcatchOutConnection_project(SWMM_ProjectHandle ph, int index, int *type, int *ObjIndex ); +//int DLLEXPORT swmm_getNodeParam_project(SWMM_ProjectHandle ph, int index, int Param, double *value); +//int DLLEXPORT swmm_setNodeParam_project(SWMM_ProjectHandle ph, int index, int Param, double value); +//int DLLEXPORT swmm_getLinkParam_project(SWMM_ProjectHandle ph, int index, int Param, double *value); +//int DLLEXPORT swmm_setLinkParam_project(SWMM_ProjectHandle ph, int index, int Param, double value); +//int DLLEXPORT swmm_getSubcatchParam_project(SWMM_ProjectHandle ph, int index, int Param, double *value); +//int DLLEXPORT swmm_setSubcatchParam_project(SWMM_ProjectHandle ph, int index, int Param, double value); +//int DLLEXPORT swmm_getSimulationDateTime_project(SWMM_ProjectHandle ph, int timetype, int *year, int *month, //int *day, int *hours, int *minutes, int *seconds); +//int DLLEXPORT swmm_setSimulationDateTime_project(SWMM_ProjectHandle ph, int timetype, char *dtimestr); + +// Active Simulation Results API +//int DLLEXPORT swmm_getCurrentDateTimeStr_project(SWMM_ProjectHandle ph, char *dtimestr); +//int DLLEXPORT swmm_getNodeResult_project(SWMM_ProjectHandle ph, int index, int type, double *result); +//int DLLEXPORT swmm_getLinkResult_project(SWMM_ProjectHandle ph, int index, int type, double *result); +//int DLLEXPORT swmm_getSubcatchResult_project(SWMM_ProjectHandle ph, int index, int type, double *result); +//int DLLEXPORT swmm_getNodeStats_project(SWMM_ProjectHandle ph, int index, SM_NodeStats *nodeStats); +//int DLLEXPORT swmm_getNodeTotalInflow_project(SWMM_ProjectHandle ph, int index, double *value); +//int DLLEXPORT swmm_getStorageStats_project(SWMM_ProjectHandle ph, int index, SM_StorageStats *storageStats);\ +//int DLLEXPORT swmm_getOutfallStats_project(SWMM_ProjectHandle ph, int index, SM_OutfallStats *outfallStats); +////void DLLEXPORT swmm_freeOutfallStats(SM_OutfallStats *outfallStats); +//int DLLEXPORT swmm_getLinkStats_project(SWMM_ProjectHandle ph, int index, SM_LinkStats *linkStats); +//int DLLEXPORT swmm_getPumpStats_project(SWMM_ProjectHandle ph, int index, SM_PumpStats *pumpStats); +//int DLLEXPORT swmm_getGagePrecip_project(SWMM_ProjectHandle ph, int index, double *rainfall, double *snowfall, double *total); +//int DLLEXPORT swmm_getSubcatchStats_project(SWMM_ProjectHandle ph, int index, SM_SubcatchStats *subcatchStats); +////void DLLEXPORT swmm_freeSubcatchStats(SM_SubcatchStats *subcatchStats); +//int DLLEXPORT swmm_getSystemRoutingStats_project(SWMM_ProjectHandle ph, SM_RoutingTotals *routingTot); +//int DLLEXPORT swmm_getSystemRunoffStats_project(SWMM_ProjectHandle ph, SM_RunoffTotals *runoffTot); + +// Setters API +//int DLLEXPORT swmm_setLinkSetting_project(SWMM_ProjectHandle ph, int index, double setting); +//int DLLEXPORT swmm_setNodeInflow_project(SWMM_ProjectHandle ph, int index, double flowrate); +//int DLLEXPORT swmm_setOutfallStage_project(SWMM_ProjectHandle ph, int index, double stage); +//int DLLEXPORT swmm_setGagePrecip_project(SWMM_ProjectHandle ph, int index, double value); + +%exception; + +/* NO EXCEPTION HANDLING FOR THESE FUNCTIONS */ +int DLLEXPORT swmm_alloc_project(SWMM_ProjectHandle *ph_out); +int DLLEXPORT swmm_free_project(SWMM_ProjectHandle *ph_out); + +void DLLEXPORT swmm_clearError_project(SWMM_ProjectHandle ph); +int DLLEXPORT swmm_checkError_project(SWMM_ProjectHandle ph, char** msg_buffer); From 31fe337996d868cdbcfb2efc3826004f658fd36f Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 20 Jul 2018 09:58:46 -0400 Subject: [PATCH 2/8] Renaming module --- toolkit/toolkit.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/toolkit.i b/toolkit/toolkit.i index 68b97836..977e8103 100644 --- a/toolkit/toolkit.i +++ b/toolkit/toolkit.i @@ -10,7 +10,7 @@ * */ -%module swmm_toolkit +%module toolkit %{ #include "swmm5.h" #include "toolkitAPI.h" From eb7b27cbdefdfdb0f0216a34ff77782515039921 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 20 Jul 2018 12:55:14 -0400 Subject: [PATCH 3/8] Package is building --- setup.py | 16 ++++++++-------- toolkit/__init__.py | 0 2 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 toolkit/__init__.py diff --git a/setup.py b/setup.py index d04c935f..7b0372e4 100644 --- a/setup.py +++ b/setup.py @@ -12,13 +12,13 @@ # try: - from setuptools import setup, Extension + from setuptools import setup, Extension, find_packages from setuptools.command.build_ext import build_ext except ImportError: from distutils.core import setup, Extension from distutils.command.build_ext import build_ext -toolkit_ext = Extension("_toolkit", +toolkit_ext = Extension("toolkit.lib._toolkit", include_dirs = ['toolkit/include/'], libraries = ['swmm5'], library_dirs = ['toolkit/lib/'], @@ -32,14 +32,14 @@ version = "0.0.1", ext_modules = [toolkit_ext], - py_modules = ['toolkit'], - package_dir = {'':'toolkit'}, + packages = ['toolkit'], + # package_dir = {'toolkit':'toolkit'}, +# py_modules = ['toolkit.toolkit'], + package_data = {'toolkit':['lib/swmm5.dll']}, + exclude_package_data = {'toolkit':['toolkit.i']}, include_package_data = True, zip_safe = False, - install_requires = [ - 'enum34' - ] - + install_requires = ['enum34'] ) diff --git a/toolkit/__init__.py b/toolkit/__init__.py new file mode 100644 index 00000000..e69de29b From ef9ba7f79bea37e1bcc4e3819d42ac154a31650f Mon Sep 17 00:00:00 2001 From: michaeltryby Date: Sun, 29 Jul 2018 11:36:28 -0400 Subject: [PATCH 4/8] Rearranging packages into implicit namespace configuration --- output/setup.py | 41 +++ output/swmm/output/__init__.py | 2 + output/swmm/output/output.i | 342 ++++++++++++++++++ {swmm-toolkit => toolkit}/setup.py | 24 +- toolkit/swmm/toolkit/__init__.py | 2 + .../swmm/toolkit/toolkit.i | 4 +- 6 files changed, 403 insertions(+), 12 deletions(-) create mode 100644 output/setup.py create mode 100644 output/swmm/output/__init__.py create mode 100644 output/swmm/output/output.i rename {swmm-toolkit => toolkit}/setup.py (58%) create mode 100644 toolkit/swmm/toolkit/__init__.py rename swmm-toolkit/src/swmm_toolkit.i => toolkit/swmm/toolkit/toolkit.i (98%) diff --git a/output/setup.py b/output/setup.py new file mode 100644 index 00000000..a0b5157b --- /dev/null +++ b/output/setup.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +# +# setup.py +# +# Author: Michael E. Tryby +# US EPA - ORD/NRMRL +# +# + +'''Setup up script for SWMM Output API python extension''' + +try: + from setuptools import setup, Extension + from setuptools.command.build_ext import build_ext +except ImportError: + from distutils.core import setup, Extension + from distutils.command.build_ext import build_ext + + +setup( + name = "swmm-output", + version = "0.1.0-alpha", + ext_modules = [ + Extension("swmm/output/_output", + include_dirs = ['swmm/output/'], + libraries = ['swmm-output'], + library_dirs = ['swmm/output/'] + sources = ['swmm/output/output.i'], + swig_opts=['-py3'], + language='C' + ) + ], + packages = ['swmm.output'], + py_modules = ['output'], + package_data = {'swmm.output':['libswmm-output.so']}, + + install_requires = [ + 'enum34' + ] +) diff --git a/output/swmm/output/__init__.py b/output/swmm/output/__init__.py new file mode 100644 index 00000000..5d6711a8 --- /dev/null +++ b/output/swmm/output/__init__.py @@ -0,0 +1,2 @@ + +from swmm.output import output \ No newline at end of file diff --git a/output/swmm/output/output.i b/output/swmm/output/output.i new file mode 100644 index 00000000..0b3bf125 --- /dev/null +++ b/output/swmm/output/output.i @@ -0,0 +1,342 @@ +/* + * swmm_output.i - SWIG interface description file for SWMM Output API + * + * Created: 11/3/2017 + * Author: Michael E. Tryby + * US EPA - ORD/NRMRL + * +*/ + +%module(package="swmm") output +%{ +#include "errormanager.h" +#include "messages.h" +#include "swmm_output.h" + +#define SWIG_FILE_WITH_INIT +%} + +%include "typemaps.i" + +/* DEFINE AND TYPEDEF MUST BE INCLUDED */ +typedef void* SMO_Handle; + +typedef enum { + SMO_flow_rate, + SMO_concentration +} SMO_unit; + +typedef enum { + SMO_subcatch, + SMO_node, + SMO_link, + SMO_sys +} SMO_elementType; + +typedef enum { + SMO_reportStep, + SMO_numPeriods +} SMO_time; + +typedef enum { + SMO_rainfall_subcatch, // (in/hr or mm/hr), + SMO_snow_depth_subcatch, // (in or mm), + SMO_evap_loss, // (in/hr or mm/hr), + SMO_infil_loss, // (in/hr or mm/hr), + SMO_runoff_rate, // (flow units), + SMO_gwoutflow_rate, // (flow units), + SMO_gwtable_elev, // (ft or m), + SMO_soil_moisture, // unsaturated zone moisture content (-), + SMO_pollutant_conc_subcatch // first pollutant +} SMO_subcatchAttribute; + +typedef enum { + SMO_invert_depth, // (ft or m), + SMO_hydraulic_head, // (ft or m), + SMO_stored_ponded_volume, // (ft3 or m3), + SMO_lateral_inflow, // (flow units), + SMO_total_inflow, // lateral + upstream (flow units), + SMO_flooding_losses, // (flow units), + SMO_pollutant_conc_node // first pollutant, +} SMO_nodeAttribute; + +typedef enum { + SMO_flow_rate_link, // (flow units), + SMO_flow_depth, // (ft or m), + SMO_flow_velocity, // (ft/s or m/s), + SMO_flow_volume, // (ft3 or m3), + SMO_capacity, // (fraction of conduit filled), + SMO_pollutant_conc_link // first pollutant, +} SMO_linkAttribute; + +typedef enum { + SMO_air_temp, // (deg. F or deg. C), + SMO_rainfall_system, // (in/hr or mm/hr), + SMO_snow_depth_system, // (in or mm), + SMO_evap_infil_loss, // (in/hr or mm/hr), + SMO_runoff_flow, // (flow units), + SMO_dry_weather_inflow, // (flow units), + SMO_groundwater_inflow, // (flow units), + SMO_RDII_inflow, // (flow units), + SMO_direct_inflow, // user defined (flow units), + SMO_total_lateral_inflow, // (sum of variables 4 to 8) //(flow units), + SMO_flood_losses, // (flow units), + SMO_outfall_flows, // (flow units), + SMO_volume_stored, // (ft3 or m3), + SMO_evap_rate // (in/day or mm/day), + //p_evap_rate // (in/day or mm/day) +} SMO_systemAttribute; + + +#ifdef WINDOWS + #ifdef __cplusplus + #define DLLEXPORT __declspec(dllexport) __cdecl + #else + #define DLLEXPORT __declspec(dllexport) __stdcall + #endif +#else + #define DLLEXPORT +#endif + + +/* TYPEMAPS FOR VOID POINTER */ +/* Used for functions that output a new opaque pointer */ +%typemap(in, numinputs=0) SMO_Handle* p_handle_out (void* retval) +{ + /* OUTPUT in */ + retval = NULL; + $1 = &retval; +} +/* used for functions that take in an opaque pointer (or NULL) +and return a (possibly) different pointer */ +%typemap(argout) SMO_Handle* p_handle_out +{ + /* OUTPUT argout */ + %append_output(SWIG_NewPointerObj(SWIG_as_voidptr(retval$argnum), $1_descriptor, 0)); +} +/* No need for special IN typemap for opaque pointers, it works anyway */ + + +/* TYPEMAP FOR IGNORING INT ERROR CODE RETURN VALUE */ +%typemap(out) int { + $result = Py_None; + Py_INCREF($result); +} + + +/* TYPEMAPS FOR DOUBLE ARGUMENT AS RETURN VALUE */ +%typemap(in, numinputs=0) double* double_out (double temp) { + $1 = &temp; +} +%typemap(argout) double* double_out { + %append_output(PyFloat_FromDouble(*$1)); +} + + +/* TYPEMAPS FOR INT ARGUMENT AS RETURN VALUE */ +%typemap(in, numinputs=0) int* int_out (int temp) { + $1 = &temp; +} +%typemap(argout) int* int_out { + %append_output(PyInt_FromLong(*$1)); +} + + +/* TYPEMAP FOR MEMORY MANAGEMENT AND ENCODING OF STRINGS */ +%typemap(in, numinputs=0)char** string_out (char* temp), int* slen (int temp){ + $1 = &temp; +} +%typemap(argout)(char** string_out, int* slen) { + if (*$1) { + PyObject* o; + o = PyUnicode_FromStringAndSize(*$1, *$2); + + $result = SWIG_Python_AppendOutput($result, o); + free(*$1); + } +} + +/* TYPEMAPS FOR MEMORY MANAGEMNET OF FLOAT ARRAYS */ +%typemap(in, numinputs=0)float** float_out (float* temp), int* int_dim (int temp){ + $1 = &temp; +} +%typemap(argout) (float** float_out, int* int_dim) { + if (*$1) { + PyObject *o = PyList_New(*$2); + int i; + float* temp = *$1; + for(i=0; i<*$2; i++) { + PyList_SetItem(o, i, PyFloat_FromDouble((double)temp[i])); + } + $result = SWIG_Python_AppendOutput($result, o); + free(*$1); + } +} + + +/* TYPEMAPS FOR MEMORY MANAGEMNET OF INT ARRAYS */ +%typemap(in, numinputs=0)int** int_out (long* temp), int* int_dim (int temp){ + $1 = &temp; +} +%typemap(argout) (int** int_out, int* int_dim) { + if (*$1) { + PyObject *o = PyList_New(*$2); + int i; + long* temp = (long*)*$1; + for(i=0; i<*$2; i++) { + PyList_SetItem(o, i, PyInt_FromLong(temp[i])); + } + $result = SWIG_Python_AppendOutput($result, o); + free(*$1); + } +} + + +/* TYPEMAP FOR ENUMERATED TYPES */ +%typemap(in) EnumeratedType (int val, int ecode = 0) { + if (PyObject_HasAttrString($input,"value")) { + PyObject* o; + o = PyObject_GetAttrString($input, "value"); + ecode = SWIG_AsVal_int(o, &val); + } + else { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "$symname" "', argument " "$argnum"" of type '" "$ltype""'"); + } + + $1 = ($1_type)(val); +} +%apply EnumeratedType {SMO_unit, SMO_elementType, SMO_time, SMO_subcatchAttribute, +SMO_nodeAttribute, SMO_linkAttribute, SMO_systemAttribute}; + + +/* RENAME FUNCTIONS PYTHON STYLE */ +%rename("%(undercase)s") ""; + + +/* INSERTS CUSTOM EXCEPTION HANDLING IN WRAPPER */ +%exception +{ + char* err_msg; + SMO_clearError(arg1); + $function + if (SMO_checkError(arg1, &err_msg)) + { + PyErr_SetString(PyExc_Exception, err_msg); + SWIG_fail; + } +} + +/* INSERT EXCEPTION HANDLING FOR THESE FUNCTIONS */ + +int DLLEXPORT SMO_open(SMO_Handle p_handle, const char* path); + +int DLLEXPORT SMO_getVersion(SMO_Handle p_handle, int* int_out); +int DLLEXPORT SMO_getProjectSize(SMO_Handle p_handle, int** int_out, int* int_dim); +int DLLEXPORT SMO_getFlowUnits(SMO_Handle p_handle, int* int_out); +int DLLEXPORT SMO_getPollutantUnits(SMO_Handle p_handle, int** int_out, int* int_dim); +int DLLEXPORT SMO_getStartDate(SMO_Handle p_handle, double* double_out); +int DLLEXPORT SMO_getTimes(SMO_Handle p_handle, SMO_time code, int* int_out); +int DLLEXPORT SMO_getElementName(SMO_Handle p_handle, SMO_elementType type, + int elementIndex, char** string_out, int* slen); + +int DLLEXPORT SMO_getSubcatchSeries(SMO_Handle p_handle, int subcatchIndex, + SMO_subcatchAttribute attr, int startPeriod, int endPeriod, float** float_out, int* int_dim); +int DLLEXPORT SMO_getNodeSeries(SMO_Handle p_handle, int nodeIndex, SMO_nodeAttribute attr, + int startPeriod, int endPeriod, float** float_out, int* int_dim); +int DLLEXPORT SMO_getLinkSeries(SMO_Handle p_handle, int linkIndex, SMO_linkAttribute attr, + int startPeriod, int endPeriod, float** float_out, int* int_dim); +int DLLEXPORT SMO_getSystemSeries(SMO_Handle p_handle, SMO_systemAttribute attr, + int startPeriod, int endPeriod, float** float_out, int* int_dim); + +int DLLEXPORT SMO_getSubcatchAttribute(SMO_Handle p_handle, int timeIndex, + SMO_subcatchAttribute attr, float** float_out, int* int_dim); +int DLLEXPORT SMO_getNodeAttribute(SMO_Handle p_handle, int timeIndex, + SMO_nodeAttribute attr, float** float_out, int* int_dim); +int DLLEXPORT SMO_getLinkAttribute(SMO_Handle p_handle, int timeIndex, + SMO_linkAttribute attr, float** float_out, int* int_dim); +int DLLEXPORT SMO_getSystemAttribute(SMO_Handle p_handle, int timeIndex, + SMO_systemAttribute attr, float** float_out, int* int_dim); + +int DLLEXPORT SMO_getSubcatchResult(SMO_Handle p_handle, int timeIndex, + int subcatchIndex, float** float_out, int* int_dim); +int DLLEXPORT SMO_getNodeResult(SMO_Handle p_handle, int timeIndex, + int nodeIndex, float** float_out, int* int_dim); +int DLLEXPORT SMO_getLinkResult(SMO_Handle p_handle, int timeIndex, + int linkIndex, float** float_out, int* int_dim); +int DLLEXPORT SMO_getSystemResult(SMO_Handle p_handle, int timeIndex, + int dummyIndex, float** float_out, int* int_dim); + +%exception; + +/* NO EXCEPTION HANDLING FOR THESE FUNCTIONS */ +int DLLEXPORT SMO_init(SMO_Handle* p_handle_out); +int DLLEXPORT SMO_close(SMO_Handle* p_handle_out); +void DLLEXPORT SMO_free(void** array); + +void DLLEXPORT SMO_clearError(SMO_Handle p_handle); +int DLLEXPORT SMO_checkError(SMO_Handle p_handle, char** msg_buffer); + + +/* CODE ADDED DIRECTLY TO SWIGGED INTERFACE MODULE */ +%pythoncode%{ +import enum + +class Unit(enum.Enum): + FLOW_UNIT = SMO_flow_rate + CONC_UNIT = SMO_concentration + +class ElementType(enum.Enum): + SUBCATCH = SMO_subcatch + NODE = SMO_node + LINK = SMO_link + SYSTEM = SMO_sys + +class Time(enum.Enum): + REPORT_STEP = SMO_reportStep + NUM_PERIODS = SMO_numPeriods + +class SubcatchAttribute(enum.Enum): + RAINFALL = SMO_rainfall_subcatch + SNOW_DEPTH = SMO_snow_depth_subcatch + EVAP_LOSS = SMO_evap_loss + INFIL_LOSS = SMO_infil_loss + RUNOFF_RATE = SMO_runoff_rate + GWOUTFLOW_RATE = SMO_gwoutflow_rate + GETABLE_ELEV = SMO_gwtable_elev + SOIL_MOISTURE = SMO_soil_moisture + POLLUT_CONC = SMO_pollutant_conc_subcatch + +class NodeAttribute(enum.Enum): + INVERT_DEPTH = SMO_invert_depth + HYDRAULIC_HEAD = SMO_hydraulic_head + PONDED_VOLUME = SMO_stored_ponded_volume + LATERAL_INFLOW = SMO_lateral_inflow + TOTAL_INFLOW = SMO_total_inflow + FLOODING_LOSSES = SMO_flooding_losses + POLLUT_CONC = SMO_pollutant_conc_node + +class LinkAttribute(enum.Enum): + FLOW_RATE = SMO_flow_rate_link + FLOW_DEPTH = SMO_flow_depth + FLOW_VELOCITY = SMO_flow_velocity + FLOW_VOLUME = SMO_flow_volume + CAPACITY = SMO_capacity + POLLUT_CONC = SMO_pollutant_conc_link + +class SystemAttribute(enum.Enum): + AIR_TEMP = SMO_air_temp + RAINFALL = SMO_rainfall_system + SNOW_DEPTH = SMO_snow_depth_system + EVAP_INFIL_LOSS = SMO_evap_infil_loss + RUNOFF_FLOW = SMO_runoff_flow + DRY_WEATHER_INFLOW = SMO_dry_weather_inflow + GW_INFLOW = SMO_groundwater_inflow + RDII_INFLOW = SMO_RDII_inflow + DIRECT_INFLOW = SMO_direct_inflow + TOTAL_LATERAL_INFLOW = SMO_total_lateral_inflow + FLOOD_LOSSES = SMO_flood_losses + OUTFALL_FLOWS = SMO_outfall_flows + VOLUME_STORED = SMO_volume_stored + EVAP_RATE = SMO_evap_rate + +%} diff --git a/swmm-toolkit/setup.py b/toolkit/setup.py similarity index 58% rename from swmm-toolkit/setup.py rename to toolkit/setup.py index 759ff316..664d29a2 100644 --- a/swmm-toolkit/setup.py +++ b/toolkit/setup.py @@ -18,24 +18,28 @@ from distutils.core import setup, Extension from distutils.command.build_ext import build_ext + setup( - name = "swmm-toolkit", - version = "0.0.1", + name = 'swmm_toolkit', + version = '0.0.1', + ext_modules = [ - Extension("_swmm_toolkit", - include_dirs = ['include/'], + Extension('swmm/toolkit/_toolkit', + include_dirs = ['swmm/toolkit/'], libraries = ['swmm5'], - library_dirs = ['lib/'], - sources = ['src/swmm_toolkit.i'], + library_dirs = ['swmm/toolkit/'], + sources = ['swmm/toolkit/toolkit.i'], swig_opts=['-py3'], language = 'C' ) ], - package_dir = {'':'src'}, - py_modules = ['swmm_toolkit'], - + packages=['swmm.toolkit'], +# package_dir = {'':'swmm'}, + py_modules = ['toolkit'], + package_data = {'swmm.toolkit':['libswmm5.so']}, +# exclude_package_data = {'swmm':['toolkit.i']}, + install_requires = [ 'enum34' ] - ) diff --git a/toolkit/swmm/toolkit/__init__.py b/toolkit/swmm/toolkit/__init__.py new file mode 100644 index 00000000..d96cfbd5 --- /dev/null +++ b/toolkit/swmm/toolkit/__init__.py @@ -0,0 +1,2 @@ + +from swmm.toolkit import toolkit \ No newline at end of file diff --git a/swmm-toolkit/src/swmm_toolkit.i b/toolkit/swmm/toolkit/toolkit.i similarity index 98% rename from swmm-toolkit/src/swmm_toolkit.i rename to toolkit/swmm/toolkit/toolkit.i index 7e0d5d88..1d218a52 100644 --- a/swmm-toolkit/src/swmm_toolkit.i +++ b/toolkit/swmm/toolkit/toolkit.i @@ -1,5 +1,5 @@ /* - * swmm_toolkit.i - SWIG interface description file for SWMM toolkit + * toolkit.i - SWIG interface description file for SWMM toolkit * * Created: 7/2/2018 * Author: Michael E. Tryby @@ -10,7 +10,7 @@ * */ -%module swmm_toolkit +%module(package="swmm") toolkit %{ #include "swmm5.h" #include "toolkitAPI.h" From 4d4eda90d28757a37f8677e921be3091cc7496a9 Mon Sep 17 00:00:00 2001 From: michaeltryby Date: Sun, 29 Jul 2018 12:50:03 -0400 Subject: [PATCH 5/8] Updating package_data --- output/setup.py | 2 +- toolkit/setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/output/setup.py b/output/setup.py index fb00edce..6635cc95 100644 --- a/output/setup.py +++ b/output/setup.py @@ -34,7 +34,7 @@ ], packages = ['swmm.output'], py_modules = ['output'], - package_data = {'swmm.output':['libswmm-output.so']}, + package_data = {'swmm.output':['*swmm-output.dll', '*swmm-output.so']}, install_requires = [ 'enum34' diff --git a/toolkit/setup.py b/toolkit/setup.py index 336e5b52..2225c9b8 100644 --- a/toolkit/setup.py +++ b/toolkit/setup.py @@ -35,7 +35,7 @@ ], packages=['swmm.toolkit'], py_modules = ['toolkit'], - package_data = {'swmm.toolkit':['libswmm5.so']}, + package_data = {'swmm.toolkit':['*swmm5.dll', '*swmm5.so']}, install_requires = [ 'enum34' From 44c466cae20c8a74da661a63e9009793454adaa6 Mon Sep 17 00:00:00 2001 From: michaeltryby Date: Mon, 30 Jul 2018 15:09:29 -0400 Subject: [PATCH 6/8] Renaming functions and adding documentation --- output/swmm/output/output.i | 3 +++ toolkit/swmm/toolkit/toolkit.i | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/output/swmm/output/output.i b/output/swmm/output/output.i index 0b3bf125..4f2d4fac 100644 --- a/output/swmm/output/output.i +++ b/output/swmm/output/output.i @@ -212,6 +212,9 @@ SMO_nodeAttribute, SMO_linkAttribute, SMO_systemAttribute}; /* RENAME FUNCTIONS PYTHON STYLE */ %rename("%(undercase)s") ""; +/* GENERATES DOCUMENTATION */ +%feature("autodoc", "2"); + /* INSERTS CUSTOM EXCEPTION HANDLING IN WRAPPER */ %exception diff --git a/toolkit/swmm/toolkit/toolkit.i b/toolkit/swmm/toolkit/toolkit.i index 1d218a52..2323f4da 100644 --- a/toolkit/swmm/toolkit/toolkit.i +++ b/toolkit/swmm/toolkit/toolkit.i @@ -64,6 +64,12 @@ and return a (possibly) different pointer */ Py_INCREF($result); } +/* RENAME FUNCTIONS PYTHON STYLE */ +%rename("%(undercase)s") ""; + +/* GENERATES DOCUMENTATION */ +%feature("autodoc", "2"); + /* INSERTS CUSTOM EXCEPTION HANDLING IN WRAPPER */ %exception From b20530cf62c813324590b10d37bb8e0c5f7f6a82 Mon Sep 17 00:00:00 2001 From: michaeltryby Date: Fri, 3 Aug 2018 06:02:09 -0400 Subject: [PATCH 7/8] Adding metadata --- output/swmm/output/__init__.py | 87 +++++++++++++++++++++++++++++++++- output/swmm/output/output.i | 4 +- 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/output/swmm/output/__init__.py b/output/swmm/output/__init__.py index 5d6711a8..75801509 100644 --- a/output/swmm/output/__init__.py +++ b/output/swmm/output/__init__.py @@ -1,2 +1,87 @@ -from swmm.output import output \ No newline at end of file +from swmm.output import output + + +# Units of Measurement +# +# Parameter Long Name US Customary SI Metric +# AREA_SUBCATCH Subcatchment Area acres ac hectares ha +# AREA_STOR Storage Unit Area square feet sq ft square meters sq m +# AREA_POND Ponding Area square feet sq ft square meters sq m +# CAP_SUC Capillary Suction inches in millimeters mm +# CONC Concentration milligrams/liter mg/L milligrams/liter mg/L +# micrograms/liter ug/L micrograms/liter ug/L +# counts/liter Count/L counts/liter Count/L +# INFIL_DECAY Infiltration Decay Constant 1/hours 1/hrs 1/hours 1/hrs +# POLLUT_DECAY Pollutant Decay Constant 1/days 1/days 1/days 1/days +# DEPRES_STOR Depression Storage inches in millimeters mm +# DEPTH Depth feet ft meters m +# DIAM Diameter feet ft meters m +# DISC_COEFF_ORIF Orifice Discharge Coefficient dimensionless dimless dimensionless dimless +# DISC_COEFF_WEIR Weir Discharge Coefficient CFS/foot^n CFS/ft^n CMS/meter^n CMS/m^n +# ELEV Elevation feet ft meters m +# EVAP_RATE Evaporation inches/day in/day millimeters/day mm/day +# FLOW_RATE Flow cubic feet/sec CFS cubic meter/sec CMS +# gallons/minute GPM liter/sec LPS +# million gallons/day MGD million liter/day MLD +# HEAD Head feet ft meters m +# HYD_CONDUCT Hydraulic Conductivity inches/hour in/hr millimeters/hour mm/hr +# INFIL_RATE Infiltration Rate inches/hour in/hr millimeters/hour mm/hr +# LEN Length feet ft meters m +# MANN_N Manning's n seconds/meter^1/3 sec/m^1/3 seconds/meter^1/3 sec/m^1/3 +# POLLUT_BUILDUP Pollutant Buildup mass/length mass/len mass/length mass/len +# mass/acre mass/ac mass/hectare mass/ha +# RAIN_INTENSITY Rainfall Intensity inches/hour in/hr millimeters/hour mm/hr +# RAIN_VOLUME Rainfall Volume inches in millimeters mm +# SLOPE_SUBCATCH Subcatchment Slope percent percent percent percent +# SLOPE_XSEC Cross Section Slope rise/run rise/run rise/run rise/run +# STREET_CLEAN_INT Street Cleaning Interval days days days days +# VOLUME Volume cubic feet cu ft cubic meters cu m +# WIDTH Width feet ft meters m + + +# Output Metadata +# +# Subcatch Attributes Long Name Parameter Name +# RAINFALL Rainfall RAIN_INTENSITY +# SNOW_DEPTH Snow Depth DEPTH +# EVAP_LOSS Evaporation Loss LOSS_RATE +# INFIL_LOSS Infiltration Loss LOSS_RATE +# RUNOFF_RATE Runoff Rate FLOW_RATE +# GW_OUTFLOW_RATE Groundwater Flow Rate FLOW_RATE +# GW_TABLE_ELEV Groundwater Elevation ELEV +# SOIL_MOISTURE Soil Moisture PERCENT +# POLLUT_CONC Pollutant Concentration CONC + +# Node Attributes +# INVERT_DEPTH Invert Depth DEPTH +# HYDRAULIC_HEAD Hydraulic Head HEAD +# PONDED_VOLUME Ponded Volume VOLUME +# LATERAL_INFLOW Lateral Inflow FLOW_RATE +# TOTAL_INFLOW Total Inflow FLOW_RATE +# FLOODING_LOSSES Flooding Loss FLOW_RATE +# POLLUT_CONC Pollutant Concentration CONC + +# Link Attributes +# FLOW_RATE Flow Rate FLOW_RATE +# FLOW_DEPTH Flow Depth DEPTH +# FLOW_VELOCITY Flow Velocity VELOCITY +# FLOW_VOLUME Flow Volume VOLUME +# CAPACITY Capacity PERCENT +# POLLUT_CONC Pollutant Concentration CONC + +# System Attributes +# AIR_TEMP Temperature TEMP +# RAINFALL Rainfall RAIN_INTENSITY +# SNOW_DEPTH Snow Depth DEPTH +# EVAP_INFIL_LOSS Evap and Infil Losses LOSS_RATE +# RUNOFF_FLOW Runoff Flow Rate FLOW_RATE +# DRY_WEATHER_INFLOW Dry Weather Inflow FLOW_RATE +# GW_INFLOW Groundwater Inflow FLOW_RATE +# RDII_INFLOW RDII Inflow FLOW_RATE +# DIRECT_INFLOW Direct Inflow FLOW_RATE +# TOTAL_LATERAL_INFLOW Total Lateral Inflow FLOW_RATE +# FLOOD_LOSSES Flood Losses FLOW_RATE +# OUTFALL_FLOWS Outfall Flow FLOW_RATE +# VOLUME_STORED Volume Stored VOLUME +# EVAP_RATE Evaporation Rate LOSS_RATE diff --git a/output/swmm/output/output.i b/output/swmm/output/output.i index 4f2d4fac..07c8b89b 100644 --- a/output/swmm/output/output.i +++ b/output/swmm/output/output.i @@ -304,8 +304,8 @@ class SubcatchAttribute(enum.Enum): EVAP_LOSS = SMO_evap_loss INFIL_LOSS = SMO_infil_loss RUNOFF_RATE = SMO_runoff_rate - GWOUTFLOW_RATE = SMO_gwoutflow_rate - GETABLE_ELEV = SMO_gwtable_elev + GW_OUTFLOW_RATE = SMO_gwoutflow_rate + GW_TABLE_ELEV = SMO_gwtable_elev SOIL_MOISTURE = SMO_soil_moisture POLLUT_CONC = SMO_pollutant_conc_subcatch From 035d83f47e7761e3367b80bd0df86c63ffd01868 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Mon, 6 Aug 2018 13:05:21 -0400 Subject: [PATCH 8/8] Fixing link error. Packages are now building --- output/setup.py | 4 ++-- output/swmm/output/output.i | 2 -- toolkit/setup.py | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/output/setup.py b/output/setup.py index 6635cc95..526d9f59 100644 --- a/output/setup.py +++ b/output/setup.py @@ -23,10 +23,10 @@ version = "0.1.0-alpha", ext_modules = [ - Extension("swmm/output/_output", + Extension("swmm.output._output", include_dirs = ['swmm/output/'], libraries = ['swmm-output'], - library_dirs = ['swmm/output/'] + library_dirs = ['swmm/output/'], sources = ['swmm/output/output.i'], swig_opts=['-py3'], language='C' diff --git a/output/swmm/output/output.i b/output/swmm/output/output.i index 07c8b89b..99b11ce7 100644 --- a/output/swmm/output/output.i +++ b/output/swmm/output/output.i @@ -9,8 +9,6 @@ %module(package="swmm") output %{ -#include "errormanager.h" -#include "messages.h" #include "swmm_output.h" #define SWIG_FILE_WITH_INIT diff --git a/toolkit/setup.py b/toolkit/setup.py index 2225c9b8..d8b29c13 100644 --- a/toolkit/setup.py +++ b/toolkit/setup.py @@ -24,7 +24,7 @@ version = '0.0.1', ext_modules = [ - Extension('swmm/toolkit/_toolkit', + Extension('swmm.toolkit._toolkit', include_dirs = ['swmm/toolkit/'], libraries = ['swmm5'], library_dirs = ['swmm/toolkit/'], @@ -33,6 +33,7 @@ language = 'C' ) ], + packages=['swmm.toolkit'], py_modules = ['toolkit'], package_data = {'swmm.toolkit':['*swmm5.dll', '*swmm5.so']},