Skip to content

Commit

Permalink
upgraded to version 5.2.0 (post2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Assela Pathirana committed Apr 17, 2022
1 parent 6dcc4ff commit e4bd165
Show file tree
Hide file tree
Showing 89 changed files with 7,964 additions and 5,506 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
*.bak
.vscode/

# Packages #
############
# it's better to unpack these files and commit the raw source
Expand Down
63 changes: 21 additions & 42 deletions README.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,28 @@ https://wiki.python.org/moin/WindowsCompilers#Compilers_Installation_and_configu
(Open a visual studio command prompt and see if cl.exe command works. If so, there is no need to do anything else.
winpython knows how to find it)


1. New swmm version: replace files in swmm5\swmm5 with the new version.

THEN comment all definitions CLE, SOL and DLL (they will be defined by the compiler options depending on the OS)

*** NOTE as of 2021 sept this step was not needed. ***

/**********************************************************
// Leave only one of the following 3 lines un-commented,
// depending on the choice of compilation target
//**********************************************************
//#define CLE /* Compile as a command line executable */
//#define SOL /* Compile as a shared object library */
//#define DLL /* Compile as a Windows DLL */


2. Upload to pypi

delete directory dist if exists.

python setup.py bdist_wininst
python setup.py bdist_wheel
python setup.py sdsit

the binaries has to be done with ALL python versions supported.

install a binary and test
TESTS:

python -m doctest -v README.txt
python ./tests\test_multithreading.py


3. Then upload them with twine
*** When new files are added by swmm upstream, make sure they are updated in MANIFEST.in file!
*** if you change the swmm5.i file go to swmm5 directory and run
c:\_NO_INSTALL\swig\swigwin-4.0.2\swig.exe -python swmm5.i

Now build :
pip install build
[ hacky way I test:
pip install --force-reinstall dist\.....whl
python -m doctest README.txt -v
python tests\test_1.py
python tests\test_multithreading.py

then repeat again with
pip install --force-reinstall dist\.....tar.gz
...
...
...
]


2. Then upload them with twine
twine upload dist/*

4. Compilers for windows: Now we (again) use microsoft compilers! So, if python defaults to gcc (mingw) as in winpython 3.4

edit pydistutils.cfg file to have ONLY following content (

[config]


(During compilation (setup.py) you will be asked to download certain compilers from microsfot)

That's it.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ One should always use the new interface. The old interface (below) is left only
::

>>> st.SWMM5_Version() # Version of underlying SWMM5 engine.
'5.1.015'
'5.2.000'
>>> st.SWMM5_VERSION # same thing as an integer
51015
52000
>>> st.Flow_Units() # Flow units.
'LPS'
>>> st.SWMM_FlowUnits # returns flow units as an index. 0 = CFS, 1 = GPM, 2 = MGD, 3 = CMS, 4 = LPS, and 5 = LPD
Expand Down
2 changes: 1 addition & 1 deletion swmm/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include swmm5/swmm5/*.h swmm5/*.h swmm5/swmm5/*.c swmm5/*.c
include swmm5/swmm5/*.h swmm5/*.h swmm5/swmm5/*.c swmm5/*.c swmm5/swmm5/*.txt
include swmm5/swmm5/xsect.dat
73 changes: 57 additions & 16 deletions swmm/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Released under GNU GPL v.3

Release History:
----------------
version 5.2.000 released in 2022

version 5.1.015 released in 2021

version 1.0.0.1 first production (non-beta) release.
Expand Down Expand Up @@ -72,9 +74,9 @@ One should always use the new interface. The old interface (below) is left only
::

>>> st.SWMM5_Version() # Version of underlying SWMM5 engine.
'5.1.015'
'5.2.000'
>>> st.SWMM5_VERSION # same thing as an integer
51015
52000
>>> st.Flow_Units() # Flow units.
'LPS'
>>> st.SWMM_FlowUnits # returns flow units as an index. 0 = CFS, 1 = GPM, 2 = MGD, 3 = CMS, 4 = LPS, and 5 = LPD
Expand All @@ -101,13 +103,21 @@ One should always use the new interface. The old interface (below) is left only

>>> st.entityList()
['SUBCATCH', 'NODE', 'LINK', 'SYS']
>>> st.Subcatch()
>>> st.Subcatch() # Deprecated
['A2', 'A1', 'A3', 'A4', 'A5', 'E1']
>>> st.entityList(within='SUBCATCH') # use these new since version 5.2
['A2', 'A1', 'A3', 'A4', 'A5', 'E1']
>>> st.Node()
>>> st.Node() # Deprecated
['J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'J10', 'J11', 'J12']
>>> st.entityList(within='NODE') # use these new since version 5.2
['J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'J10', 'J11', 'J12']
>>> st.Link()
>>> st.Link() # Deprecated
['T4-1', 'T4-2', 'T4-3', 'T1-1', 'T1-2', 'T2-1', 'T2-2', 'T2-3', 'T3-1', 'T3-2', 'T5']
>>> st.Sys()
>>> st.entityList(within='LINK')
['T4-1', 'T4-2', 'T4-3', 'T1-1', 'T1-2', 'T2-1', 'T2-2', 'T2-3', 'T3-1', 'T3-2', 'T5']
>>> st.Sys() # Deprecated
['SYS']
>>> st.entityList(within='SYS') # use these new since version 5.2
['SYS']
>>> st.Pollutants() # no pollutants in this file.
[]
Expand Down Expand Up @@ -174,6 +184,7 @@ One should always use the new interface. The old interface (below) is left only
11 Flow leaving through outfalls (flow units)
12 Volume of stored water (ft3 or m3)
13 Evaporation rate (in/day or mm/day)
14 Potential evaporation rate (PET) in/day or mm/day)



Expand Down Expand Up @@ -212,7 +223,7 @@ One should always use the new interface. The old interface (below) is left only

::

>>> wq.Subcatch()
>>> wq.entityList(within='SUBCATCH')
['S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7']

>>> r=list(wq.Results('SUBCATCH','S3', 8)) # TSS out of catchment 'S3'. We convert it to a list.
Expand All @@ -231,7 +242,7 @@ One should always use the new interface. The old interface (below) is left only

::

>>> wq.Node()
>>> wq.entityList(within='NODE')
['J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'J10', 'J11', 'O1']

>>> r=list(wq.Results('NODE','J3', 6)) # TSS out of Node 'J3'. We convert it to a list.
Expand All @@ -247,26 +258,56 @@ One should always use the new interface. The old interface (below) is left only
15.14
15.64

>>> wq.Link()
>>> wq.entityList(within='LINK')
['C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10', 'C11']

>>> r=list(wq.Results('LINK','C11', 5)) # TSS out of Link 'C11'. We convert it to a list.
>>> print ("\n".join( "%5.2f"% (i) for i in r)) # Lets print the first 10 items. #doctest: +ELLIPSIS
>>> print ("\n".join( "%5.2f"% (i) for i in r)) # #doctest: +ELLIPSIS
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
5.55
9.98
12.72
0.00
6.40
12.64
16.57
19.60
22.53
25.40
...
44.95
0.00


:Example 5: Tracking output files
:Example 5: Get all results once (inefficient, but easy)

::

>>> simtemp=SWMM5Simulation("swmm5/examples/simple/swmm5Example.inp")
>>> ar=simtemp.allResults()
>>> len(ar)
4
>>> list(ar.keys())
['SUBCATCH', 'NODE', 'LINK', 'SYS']
>>> len(ar['NODE'])
12
>>> list(ar['NODE'].keys())
['J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'J10', 'J11', 'J12']
>>> list(ar['NODE']['J1'].keys())[5]
'Flow lost to flooding (flow units)'
>>> max(list(ar['NODE']['J1']['Flow lost to flooding (flow units)'])) # doctest: +ELLIPSIS
4267.9...
>>> # or we can use the index for shorthand
>>> max(list(list(ar['NODE']['J10'].values())[5])) # doctest: +ELLIPSIS
2252.7...


:Example 6: Tracking output files

::

Expand Down
59 changes: 29 additions & 30 deletions swmm/run.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
:: echo off
:: RUN this script in winpython command prompt.
:: download epa-swmm binary and install it. Open the examples *inp files using this binary and save them back. (Important to make sure the version compatibility of the library)
:: Download and extract swmm sourcecode to swmm/swmm5/swmm5 directory.
:: first step both in swmm5.c and swmm5.h #undef WINDOWS after its definition
Expand Down Expand Up @@ -32,15 +33,16 @@ if not "%1" == "" (


if not %good%=="true" (
echo "USAGE: %0% <name (case is important check on pypi!)> <arch 64bit/32bit> <python_version x.x.x.x> <version x.x.x.x[dev]>
echo "USAGE: %0% <name (case is important check on pypi!)> <arch 64/32> <python_version x.x.x.x> <version x.x.x.x[dev]>
echo "Example: %0% SWMM5 64 3980 5.2.0"
goto ERROR
)

:::::::::::::::::::::::::::::::::::::::::::::::::::::::
set swig=c:\swig\swigwin-3.0.5\swig.exe
set swig=C:\_NO_INSTALL\swig\swigwin-4.0.2\swig.exe
set loc=%~dp0
set py3=3.3.5.0
set py2=2.7.6.4
:: set py3=3.9.8.0
:: set py2=2.7.6.4


::2.7.6.4
Expand All @@ -51,7 +53,7 @@ set pyverwhl=%pyver:.=%



if %arch% == 64bit (
if %arch% == 64 (
set arch1=x64
set arch2=win-amd64
set arch3=win_amd64
Expand All @@ -77,7 +79,7 @@ pause
echo on

cd /d %loc%
call D:\WinPython-%arch%-%pyversion%\scripts\env.bat || goto ERROR
call C:\_NO_INSTALL\python\WPy%arch%-%pyversion%\scripts\env.bat || goto ERROR
pip install virtualenv
echo on
cd %loc%\%name% || goto ERROR
Expand All @@ -86,40 +88,37 @@ echo on
cd ..
rd /s /q build dist env1
pip install wheel
python setup.py bdist_wininst bdist_wheel || goto ERROR
python setup.py bdist_wheel || goto ERROR
cd /d %loc% || goto ERROR

:: test wininst
rd /s /q env1
virtualenv --no-site-packages --clear env1 || goto ERROR
echo on
call %loc%\env1\Scripts\activate.bat || goto ERROR
set OLDPATH=%PATH%
set PATH=%loc%\env1\Scripts
echo on
cd /d %loc% || goto ERROR
%loc%env1\Scripts\easy_install.exe %loc%\dist\%name%-%version%.%arch2%-py%pyver%.exe || goto ERROR
cd /d %loc% || goto ERROR
echo on
python -m doctest -f -v README.txt|| goto ERROR
python tests\test_1.py -v || goto ERROR
pip install nose
python tests\test_multithreading.py || goto ERROR
set PATH=%OLDPATH%

call env1\Scripts\deactivate.bat || goto ERROR
:: :: test wininst
::rd /s /q env1
::virtualenv --clear env1 || goto ERROR
::echo on
::call %loc%\env1\Scripts\activate.bat || goto ERROR
::set OLDPATH=%PATH%
::set PATH=%loc%\env1\Scripts
::echo on
::cd /d %loc% || goto ERROR
::%loc%env1\Scripts\easy_install.exe %loc%\dist\%name%-%version%.%arch2%-py%pyver%.exe || goto ERROR
::cd /d %loc% || goto ERROR
::echo on
::python -m doctest -f -v README.txt|| goto ERROR
::python tests\test_1.py -v || goto ERROR
::pip install nose
::python tests\test_multithreading.py || goto ERROR
::set PATH=%OLDPATH%
:: call env1\Scripts\deactivate.bat || goto ERROR
del env1 /f /q
:: test wheel


virtualenv --no-site-packages --clear env1 || goto ERROR
virtualenv --clear env1 || goto ERROR
echo on
call %loc%\env1\Scripts\activate.bat || goto ERROR
set OLDPATH=%PATH%
set PATH=%loc%\env1\Scripts
echo on
cd /d %loc% || goto ERROR
%loc%env1\Scripts\pip install %loc%\dist\%name%-%version%-cp%pyverwhl%-none-%arch3%.whl || goto ERROR
%loc%env1\Scripts\pip install %loc%dist\%name%-%version%-cp%pyverwhl%-none-%arch3%.whl || goto ERROR
cd /d %loc% || goto ERROR
echo on
python -m doctest -v README.txt|| goto ERROR
Expand Down
Loading

0 comments on commit e4bd165

Please sign in to comment.