Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Support for Python 3.12 #490

Merged
merged 7 commits into from
Nov 28, 2023
Merged
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
12 changes: 6 additions & 6 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
fail-fast: false
matrix:
os: [windows-2022, macos-12, ubuntu-latest]
py: ["3.8", "3.9", "3.10", "3.11"]
py: ["3.8", "3.9", "3.10", "3.11", "3.12"]

name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

Expand All @@ -28,7 +28,7 @@ jobs:
run: |
pip install -r requirements.txt
pip install -e .

- name: run unit tests
run: pytest

Expand All @@ -37,7 +37,7 @@ jobs:
run: |
pip install --no-index --find-links=./dist pyswmm
pytest

build_wheels:
runs-on: ubuntu-latest

Expand All @@ -48,7 +48,7 @@ jobs:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.12"

- name: Install build requirements
run: pip install -r requirements.txt
Expand All @@ -63,4 +63,4 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: ./dist/pyswmm-*.*
path: ./dist/pyswmm-*.*
35 changes: 19 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<div align="center" style="max-width:500px;margin: auto;">
<img src="https://raw.githubusercontent.com/OpenWaterAnalytics/pyswmm/master/docs/source/_static/type-logo-black.png"><br>
<img src="https://raw.githubusercontent.com/pyswmm/pyswmm/master/docs/source/_static/type-logo-black.png"><br>
</div>


# python wrappers for the Stormwater Management Model (SWMM5)

[![GitHub Actions Build Status](https://github.com/OpenWaterAnalytics/pyswmm/actions/workflows/python-package.yml/badge.svg?branch=master)](https://github.com/OpenWaterAnalytics/pyswmm/actions/workflows/python-package.yml)
[![Documentation Status](https://github.com/OpenWaterAnalytics/pyswmm/actions/workflows/documentation.yml/badge.svg?branch=master)](http:https://docs.pyswmm.org/)
[![GitHub Actions Build Status](https://github.com/pyswmm/pyswmm/actions/workflows/python-package.yml/badge.svg?branch=master)](https://github.com/pyswmm/pyswmm/actions/workflows/python-package.yml)
[![Documentation Status](https://github.com/pyswmm/pyswmm/actions/workflows/documentation.yml/badge.svg?branch=master)](http:https://docs.pyswmm.org/)
[![License](https://img.shields.io/pypi/l/pyswmm.svg)](LICENSE.txt)
[![Latest PyPI version](https://img.shields.io/pypi/v/pyswmm.svg)](https://pypi.python.org/pypi/pyswmm/)
[![PyPI Monthly Downloads](https://img.shields.io/badge/dynamic/json.svg?label=Downloads&url=https%3A%2F%2Fpypistats.org%2Fapi%2Fpackages%2Fpyswmm%2Frecent&query=%24.data.last_month&colorB=green&suffix=%20last%20month)](https://pypi.python.org/pypi/pyswmm/)
[![Cite our Paper](https://joss.theoj.org/papers/10.21105/joss.02292/status.svg)](https://doi.org/10.21105/joss.02292)

## Getting started

* Poject Website: [www.pyswmm.org](https://www.pyswmm.org)
* Project Website: [www.pyswmm.org](https://www.pyswmm.org)

* [Official PySWMM Documentation](http:https://docs.pyswmm.org)

Expand All @@ -23,10 +23,13 @@

* [PySWMM Example Bundles](https://www.pyswmm.org/examples)

Introducing the SWAG STORE! All Proceeds go toward the hosting/service fees related to maintaining the PySWMM Project!!! Get yourself a hoodie or coffee cup!


* [PySWMM SWAG Store](https://www.zazzle.com/store/pyswmm)

🆘Do you need HELP?🆘
> We provide support on [Stack
> Overflow](https://stackoverflow.com/search?q=pyswmm) or [GitHub
> Discussions](https://github.com/OpenWaterAnalytics/pyswmm/discussions)
> [GitHub Discussions](https://github.com/pyswmm/pyswmm/discussions)
> to answer support questions related to PySWMM.

Cite our Paper
Expand Down Expand Up @@ -87,18 +90,18 @@ Guide](https://www.pyswmm.org/docs)!
```
$ pip install pyswmm
```
As of version 1.3.1, pyswmm can be installed with specific versions of the SWMM engine ranging from 5.1.14 to 5.2.3 using pip extras:
As of version 1.3.1, pyswmm can be installed with specific versions of the SWMM engine ranging from 5.1.14 to 5.2.4 using pip extras:

```
$ pip install pyswmm[swmm5.2.1]
$ pip install pyswmm[swmm5.2.4]
```

### SWMM and Python Compatibility Table

| pyswmm version | swmm-toolkit compatibility<br>(SWMM engine) | python compatibility |
|----------------|--------------------------------------------------------------------------------------------------------|----------------------|
| 1.0.0 - 1.1.1 | 0.8.2 (SWMM 5.1.13) | 3.6 - 3.9 |
| 1.2.0 - 1.4.0 | 0.9.1 - 0.14.0 (SWMM 5.1.14 - 5.2.3)<br>Note: 0.11.0 (SWMM 5.2.0) only supported on windows | 3.7 - 3.11 |
| pyswmm version | swmm-toolkit compatibility<br>(SWMM engine) | python compatibility |
| -------------- | ------------------------------------------------------------ | -------------------- |
| 1.0.0 - 1.1.1 | 0.8.2 (SWMM 5.1.13) | 3.6 - 3.9 |
| 1.2.0 - 1.5.0 | 0.9.1 - 0.15.0 (SWMM 5.1.14 - 5.2.4)<br>Note: 0.11.0 (SWMM 5.2.0) only supported on windows | 3.7 - 3.12 |

# Usage

Expand Down Expand Up @@ -145,7 +148,7 @@ with Output('model.out') as out:
# Bugs

Our issue tracker is at
<https://github.com/OpenWaterAnalytics/pyswmm/issues>. Please report any
<https://github.com/pyswmm/pyswmm/issues>. Please report any
bugs that you find. Or, even better, fork the repository on GitHub and
create a pull request. All changes are welcome, big or small, and we
will help you make the pull request if you are new to git (just ask on
Expand All @@ -154,7 +157,7 @@ the issue).
# Contributing

Please check out our Wiki
<https://github.com/OpenWaterAnalytics/pyswmm/wiki> for more information
<https://github.com/pyswmm/pyswmm/wiki> for more information
on contributing, including an Author Contribution Checklist.

# License
Expand All @@ -166,4 +169,4 @@ Distributed with a BSD2 license; see LICENSE.txt:

# Acknowledgements

- Assela Pathirana
- Assela Pathirana
8 changes: 4 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@

# General information about the project.
project = u'pyswmm'
copyright = u'2016, Bryant E. McDonnell (EmNet LLC)'
author = u'Bryant E. McDonnell (EmNet LLC)'
copyright = u'2023, Bryant E. McDonnell (Hydroinformatics, LLC)'
author = u'Bryant E. McDonnell (See AUTHORS)'

version = pyswmm.__version__
# The full version, including alpha/beta/rc tags.
Expand Down Expand Up @@ -162,7 +162,7 @@
"image_light": "type-logo-black.png",
"image_dark": "type-logo-white.png",
},
"github_url": "https://github.com/OpenWaterAnalytics/pyswmm",
"github_url": "https://github.com/pyswmm/pyswmm",
"icon_links": [
{
"name": "PyPI",
Expand Down Expand Up @@ -333,7 +333,7 @@
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'pyswmm.tex', u'pyswmm Documentation',
u'Bryant E. McDonnell (EmNet LLC)', 'manual'),
u'Bryant E. McDonnell (Hydroinformatics, LLC)', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down
12 changes: 6 additions & 6 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. use raw html to hide the doc title show it is shows up in browser tab but not on page
.. use raw html to hide the doc title show it is shows up in browser tab but not on page
.. https://github.com/sphinx-doc/sphinx/issues/8356#issuecomment-1201029122
.. raw:: html

Expand Down Expand Up @@ -80,7 +80,7 @@ More information about pyswmm can be found at the `official pyswmm website`_.
Video Tutorials
^^^^^^^^^^^^^^^^

The pyswmm development team is putting together a video
The pyswmm development team is putting together a video
tutorial series the covers the various use cases of pyswmm.

+++
Expand All @@ -103,8 +103,8 @@ More information about pyswmm can be found at the `official pyswmm website`_.

.. only:: html

.. |gh actions| image:: https://github.com/OpenWaterAnalytics/pyswmm/actions/workflows/python-package.yml/badge.svg?branch=master
:target: https://github.com/OpenWaterAnalytics/pyswmm/actions/workflows/python-package.yml
.. |gh actions| image:: https://github.com/pyswmm/pyswmm/actions/workflows/python-package.yml/badge.svg?branch=master
:target: https://github.com/pyswmm/pyswmm/actions/workflows/python-package.yml
:alt: GitHub Actions Build Status
.. |downloads| image:: https://img.shields.io/badge/dynamic/json.svg?label=Downloads&url=https%3A%2F%2Fpypistats.org%2Fapi%2Fpackages%2Fpyswmm%2Frecent&query=%24.data.last_month&colorB=green&suffix=%20last%20month
:target: https://pypi.python.org/pypi/pyswmm/
Expand All @@ -115,10 +115,10 @@ More information about pyswmm can be found at the `official pyswmm website`_.
.. |pypi version| image:: https://img.shields.io/pypi/v/pyswmm.svg
:target: https://pypi.python.org/pypi/pyswmm/
:alt: Latest PyPI version
.. |docs| image:: https://github.com/OpenWaterAnalytics/pyswmm/actions/workflows/documentation.yml/badge.svg?branch=master
.. |docs| image:: https://github.com/pyswmm/pyswmm/actions/workflows/documentation.yml/badge.svg?branch=master
:target: http:https://docs.pyswmm.org/
:alt: Documentation Status
.. |cite| image:: https://joss.theoj.org/papers/10.21105/joss.02292/status.svg
:target: https://doi.org/10.21105/joss.02292
:alt: Cite our Paper
.. _official pyswmm website: https://www.pyswmm.org
.. _official pyswmm website: https://www.pyswmm.org
6 changes: 3 additions & 3 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ Try to install it with::
and an attempt will be made to find and install an appropriate version
that matches your operating system and Python version.

As of version 1.4.0, pyswmm can be installed with specific versions of the SWMM engine ranging from 5.1.14 to 5.2.3 using pip extras::
As of version 1.4.0, pyswmm can be installed with specific versions of the SWMM engine ranging from 5.1.14 to 5.2.4 using pip extras::

pip install pyswmm["swmm5.2.1"]

SWMM and Python Compatibility
++++++++++++++++++++++++++++++
pyswmm has grown with EPA SWMM, supporting new versions as they are released.
pyswmm has grown with EPA SWMM, supporting new versions as they are released.
However, there are some compatibility limitations based on the version of pyswmm installed.

+----------------+-------------------------------------------------------+----------------------+
| pyswmm version | compatible swmm-toolkit versions (SWMM engine) | python compatibility |
+================+=======================================================+======================+
| 1.0.0 - 1.1.1 | 0.8.2 (SWMM 5.1.13) | 3.6 - 3.9 |
+----------------+-------------------------------------------------------+----------------------+
| 1.2.0 - 1.4.0 | | 0.9.1 - 0.14.0 (SWMM 5.1.14 - 5.2.3) | 3.7 - 3.11 |
| 1.2.0 - 1.5.0 | | 0.9.1 - 0.15.3 (SWMM 5.1.14 - 5.2.4) | 3.7 - 3.12 |
| | | Note: 0.11.0 (SWMM 5.2.0) only supported on windows | |
+----------------+-------------------------------------------------------+----------------------+

Expand Down
6 changes: 3 additions & 3 deletions docs/source/overview.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. image:: _static/banner.jpg
:alt: pyswmm banner

Overview
========

Expand Down Expand Up @@ -41,15 +41,15 @@ PySWMM is intended to provide
- a coding interface to binary output files,

- new modeling possibilities for the SWMM5 Community.

Free software
-------------

PySWMM is free software; you can redistribute it and/or
modify it under the terms of the :doc:`BSD License </reference/legal>`.
We welcome contributions from the community. Information on
PySWMM development is found at the PySWMM Github Page
https://github.com/OpenWaterAnalytics/pyswmm
https://github.com/pyswmm/pyswmm


What Next
Expand Down
8 changes: 4 additions & 4 deletions pyswmm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright (c) 2014 Bryant E. McDonnell
# Copyright (c) 2023 Bryant E. McDonnell (See AUTHORS)
#
# Licensed under the terms of the BSD2 License
# See LICENSE.txt for details
Expand All @@ -18,11 +18,11 @@
from pyswmm.system import SystemStats
from pyswmm.raingages import RainGages, RainGage

VERSION_INFO = (1, 4, 0, "dev0")
VERSION_INFO = (1, 5, 0)

__version__ = '.'.join(map(str, VERSION_INFO))
__author__ = 'Bryant E. McDonnell (EmNet LLC) - [email protected]'
__copyright__ = 'Copyright (c) 2016 Bryant E. McDonnell (See AUTHORS)'
__author__ = 'Bryant E. McDonnell (Hydroinformatics, LLC) - [email protected]'
__copyright__ = 'Copyright (c) 2023 Bryant E. McDonnell (See AUTHORS)'
__licence__ = 'BSD2'
__all__ = [
Link, Links, LidControls, LidGroups, Node, Nodes, Subcatchment, Subcatchments, Simulation,
Expand Down
22 changes: 5 additions & 17 deletions pyswmm/simulation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright (c) 2014 Bryant E. McDonnell
# Copyright (c) 2023 Bryant E. McDonnell (See AUTHORS)
#
# Licensed under the terms of the BSD2 License
# See LICENSE.txt for details
Expand Down Expand Up @@ -31,18 +31,6 @@ class Simulation(object):

Examples:

Intialize a simulation and iterate through a simulation. This
approach requires some clean up.

>>> from pyswmm import Simulation
>>>
>>> sim = Simulation('tests/data/model_weir_setting.inp')
>>> for step in sim:
... pass
>>>
>>> sim.report()
>>> sim.close()

Intialize using with statement. This automatically cleans up
after a simulation

Expand Down Expand Up @@ -673,14 +661,14 @@ def use_hotstart(self,hotstart_file):
:param str hotstart_file: Path to hotstart file.
"""
self._model.swmm_use_hotstart(hotstart_file)

def save_hotstart(self,hotstart_file):

"""
Save the current state of the model to a hotstart file.
Save the current state of the model to a hotstart file.

This can be run at any point during the simultion.

:param str hotstart_file: Path to hotstart file.
"""
self._model.swmm_save_hotstart(hotstart_file)
self._model.swmm_save_hotstart(hotstart_file)
14 changes: 6 additions & 8 deletions pyswmm/swmm5.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright (c) 2014 Bryant E. McDonnell
# Copyright (c) 2023 Bryant E. McDonnell (See AUTHORS)
#
# Licensed under the terms of the BSD2 License
# See LICENSE.txt for details
# -----------------------------------------------------------------------------
"""
Python extensions for the SWMM5 Programmers toolkit.

Open Water Analytics (http:https://wateranalytics.org/)
"""

# Standard library imports
import distutils.version
import packaging.version
import sys
from datetime import datetime

Expand Down Expand Up @@ -363,8 +361,8 @@ def swmm_close(self):

def swmm_save_hotstart(self, hotstart_filename):
"""
Save the current state of the model to a hotstart file.
Save the current state of the model to a hotstart file.

This can be run at any point during the simultion.

:param str hotstart_filename: Name of hotstart file to save to.
Expand Down Expand Up @@ -392,7 +390,7 @@ def swmm_getVersion(self):
:rtype: int
"""
major, minor, patch = solver.swmm_version_info().split('.')
return distutils.version.LooseVersion('.'.join([major, minor, patch]))
return packaging.version.parse('.'.join([major, minor, patch]))

return
def swmm_getMassBalErr(self):
Expand Down Expand Up @@ -443,7 +441,7 @@ def setSimulationDateTime(self, timeType, newDateTime):
datetime(2009, 10, 1, 12,30))
>>>
"""
solver.simulation_set_datetime(timeType, newDateTime.year, newDateTime.month,
solver.simulation_set_datetime(timeType, newDateTime.year, newDateTime.month,
newDateTime.day, newDateTime.hour, newDateTime.minute, newDateTime.second)

def getSimUnit(self, unit_type):
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
wheel
pytest
julian==0.14
swmm-toolkit==0.15.0
aenum==3.1.11
swmm-toolkit==0.15.3
aenum==3.1.11
setuptools
Loading