Skip to content

Commit 906c7c1

Browse files
authored
Merge pull request #153 from pyswmm/dev
staging for v0.16.1 release
2 parents e741e6d + 283f40e commit 906c7c1

12 files changed

Lines changed: 611 additions & 292 deletions

File tree

.github/workflows/build_wheel.yml

Lines changed: 76 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,65 @@ jobs:
1919
defaults:
2020
run:
2121
working-directory: ./nrtest-swmm
22-
2322
steps:
2423
- name: Checkout repo
2524
uses: actions/checkout@v5
26-
2725
- name: Install Python
2826
uses: actions/setup-python@v5
2927
with:
30-
python-version: '3.10'
31-
28+
python-version: "3.10"
3229
- name: Build wheel
3330
run: |
34-
pip install wheel
35-
python setup.py bdist_wheel
36-
31+
pip install wheel
32+
python setup.py bdist_wheel
33+
3734
- name: Upload wheel artifact
3835
uses: actions/upload-artifact@v4
3936
with:
4037
name: nrtest-swmm-wheel
4138
path: nrtest-swmm/dist/*.whl
42-
39+
40+
build_sdist:
41+
name: Build source distribution
42+
runs-on: ubuntu-latest
43+
defaults:
44+
run:
45+
working-directory: ./swmm-toolkit
46+
steps:
47+
- name: Checkout repo
48+
uses: actions/checkout@v5
49+
- name: Install Python
50+
uses: actions/setup-python@v5
51+
with:
52+
python-version: "3.12"
53+
- name: Build sdist
54+
run: |
55+
pip install build
56+
python -m build --sdist --outdir ./dist
57+
- name: Upload sdist artifact
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: swmm-toolkit-sdist
61+
path: swmm-toolkit/dist/*.tar.gz
4362

4463
build_wheels:
4564
runs-on: ${{ matrix.os }}
4665
strategy:
4766
fail-fast: false
4867
matrix:
49-
os: [ubuntu-latest, windows-latest, macos-latest]
50-
pyver: [cp39, cp310, cp311, cp312, cp313]
51-
68+
os:
69+
[
70+
ubuntu-24.04,
71+
ubuntu-24.04-arm,
72+
windows-2025,
73+
macos-15-intel,
74+
macos-15,
75+
]
5276
steps:
5377
- name: Checkout repo
54-
uses: actions/checkout@v3
78+
uses: actions/checkout@v5
5579
with:
56-
submodules: true
57-
80+
submodules: true
5881
- name: Build wheels
5982
uses: pypa/cibuildwheel@v3.1.4
6083
with:
@@ -63,65 +86,57 @@ jobs:
6386
MACOSX_DEPLOYMENT_TARGET: "11.0"
6487
CIBW_TEST_COMMAND: "pytest {package}/tests"
6588
CIBW_BEFORE_TEST: pip install -r {package}/test-requirements.txt
66-
# mac needs ninja to build
67-
CIBW_BEFORE_BUILD_MACOS: brew install ninja
89+
CIBW_ENVIRONMENT_MACOS: |
90+
MACOSX_DEPLOYMENT_TARGET=11.0
6891
# remove system swig (cmake bug doesn't respect python venv)
6992
# https://github.com/swig/swig/issues/2481#issuecomment-1949573105
7093
CIBW_BEFORE_BUILD_LINUX: rm -f $(which swig) && rm -f $(which swig4.0)
71-
# configure cibuildwheel to build native archs ('auto'), and some emulated ones
72-
CIBW_ARCHS_LINUX: x86_64
73-
CIBW_ARCHS_WINDOWS: AMD64
74-
CIBW_ARCHS_MACOS: x86_64 arm64
75-
# only build current supported python: https://devguide.python.org/versions/
76-
# don't build pypy or musllinux to save build time. TODO: find a good way to support those archs
77-
CIBW_BUILD: ${{matrix.pyver}}-*
78-
CIBW_SKIP: cp38-* pp* *-musllinux*
79-
# Will avoid testing on emulated architectures
80-
# Skip trying to test arm64 builds on Intel Macs
81-
CIBW_TEST_SKIP: "*-*linux_{aarch64,ppc64le,s390x} *-macosx_universal2:arm64"
94+
# skip 3.8 and any free threaded variants
95+
CIBW_SKIP: cp38-* cp3??t-*
96+
CIBW_ARCHS: native
8297
CIBW_BUILD_VERBOSITY: 1
83-
8498
- uses: actions/upload-artifact@v4
8599
with:
86-
name: wheels-${{ matrix.os }}-${{ matrix.pyver }}
100+
name: swmm-toolkit-bdist-${{ matrix.os }}
87101
path: ./wheelhouse/*.whl
88102

89-
build_cross_wheels:
103+
merge_wheels:
104+
name: Consolidate all wheel artifacts
90105
runs-on: ubuntu-latest
91-
strategy:
92-
fail-fast: false
93-
matrix:
94-
pyver: [cp39, cp310, cp311, cp312, cp313]
95-
106+
needs:
107+
- build_wheels
108+
- build_sdist
96109
steps:
97-
- name: Checkout repo
98-
uses: actions/checkout@v5
110+
- name: Download all distribution artifacts
111+
uses: actions/download-artifact@v5
99112
with:
100-
submodules: true
113+
path: dist
114+
pattern: swmm-toolkit-*dist*
115+
merge-multiple: true
101116

102-
- name: Set up QEMU
103-
if: runner.os == 'Linux'
104-
uses: docker/setup-qemu-action@v2
117+
- name: Upload consolidated archive
118+
uses: actions/upload-artifact@v4
105119
with:
106-
platforms: all
120+
name: swmm_toolkit_dist
121+
path: ./dist/*
107122

108-
- name: Build wheels
109-
uses: pypa/cibuildwheel@v3.1.4
110-
with:
111-
package-dir: ./swmm-toolkit
112-
env:
113-
# remove system swig (cmake bug doesn't respect python venv)
114-
# https://github.com/swig/swig/issues/2481#issuecomment-1949573105
115-
CIBW_BEFORE_BUILD_LINUX: rm -f $(which swig) && rm -f $(which swig4.0)
116-
# configure cibuildwheel to build native archs ('auto'), and some emulated ones
117-
CIBW_ARCHS_LINUX: aarch64
118-
# only build current supported python: https://devguide.python.org/versions/
119-
# don't build pypy or musllinux to save build time. TODO: find a good way to support those archs
120-
CIBW_BUILD: ${{matrix.pyver}}-*
121-
CIBW_SKIP: cp-*38 pp* *-musllinux*
122-
CIBW_BUILD_VERBOSITY: 1
123-
124-
- uses: actions/upload-artifact@v4
123+
publish_toolkit:
124+
name: Publish Python 🐍 distribution 📦 to PyPI
125+
needs:
126+
- merge_wheels
127+
# only publish to PyPI on tag pushes
128+
if: startsWith(github.ref, 'refs/tags/')
129+
runs-on: ubuntu-latest
130+
environment:
131+
name: pypi
132+
url: https://pypi.org/p/swmm-toolkit
133+
permissions:
134+
id-token: write
135+
steps:
136+
- name: Download all the dists
137+
uses: actions/download-artifact@v5
125138
with:
126-
name: wheels-linux-aarch64-${{ matrix.pyver }}
127-
path: ./wheelhouse/*.whl
139+
name: swmm_toolkit_dist
140+
path: dist/
141+
- name: Publish distribution 📦 to PyPI
142+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/unit_test.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ jobs:
4141
- name: Install Python
4242
uses: actions/setup-python@v5
4343
with:
44-
python-version: "3.10"
44+
python-version: "3.12"
4545

46-
- name: Build wheel in virtual env
47-
env:
48-
MACOSX_DEPLOYMENT_TARGET: "11.0"
46+
- name: Build wheel
4947
run: |
50-
python -m venv --clear ./build-env
51-
${{matrix.activate}}
52-
python -m pip install -r build-requirements.txt
53-
python setup.py bdist_wheel
54-
deactivate
48+
pip install build
49+
python -m build
50+
- name: Upload Wheel
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: swmm_toolkit_${{ matrix.os }}
54+
path: ./swmm-toolkit/dist/*.whl
5555

5656
- name: Test wheel
5757
run: |

swmm-toolkit/CMakeLists.txt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,38 @@
44
# Created: Feb 6, 2020
55
# Modified Sep 2, 2025
66
#
7-
# Author: See AUTHORS
7+
# Author: See AUTHORS
88
#
99

10-
################################################################################
11-
################## CMAKELISTS FOR SWMM-TOOLKIT PROJECT ###################
12-
################################################################################
10+
# ###############################################################################
11+
# ################# CMAKELISTS FOR SWMM-TOOLKIT PROJECT ###################
12+
# ###############################################################################
1313

14-
cmake_minimum_required (VERSION 4.0.2)
14+
cmake_minimum_required(VERSION 4.0.2)
1515

1616
project(swmm-toolkit
1717
VERSION
18-
0.15.5
18+
0.16.1
1919
)
2020

21-
2221
# Trick here is to perform build in a python virtual environment
2322
set(Python_FIND_VIRTUALENV FIRST)
24-
#set(CMAKE_FIND_DEBUG_MODE TRUE)
23+
24+
# set(CMAKE_FIND_DEBUG_MODE TRUE)
2525
if(NOT MSVC)
26-
find_package (Python3 ${PYTHON_VERSION_STRING} COMPONENTS Interpreter Development.Module REQUIRED)
26+
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
2727
else()
28-
find_package (Python3 ${PYTHON_VERSION_STRING} COMPONENTS Interpreter Development REQUIRED)
28+
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
2929
endif()
30-
#set(CMAKE_FIND_DEBUG_MODE FALSE)
3130

31+
# set(CMAKE_FIND_DEBUG_MODE FALSE)
3232

3333
# SWIG is a build requirement so needs to be installed first
3434
find_package(SWIG REQUIRED)
3535
cmake_policy(SET CMP0078 NEW)
3636
cmake_policy(SET CMP0086 NEW)
3737
include(${SWIG_USE_FILE})
3838

39-
4039
# Add project subdirectories
4140
add_subdirectory(swmm-solver)
4241

swmm-toolkit/README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
## Community
1818

19-
[![Discord](https://img.shields.io/badge/Discord-Join%20Chat-7289da?logo=discord&logoColor=white)](https://discord.com/channels/1412143058463756421/1412144907312955532)
19+
[![Discord](https://img.shields.io/badge/Discord-Join%20Chat-7289da?logo=discord&logoColor=white)](https://discord.gg/U8wqxgjt9C)
2020

2121
Join the discussion! We will do everything we can to help you!
2222

@@ -37,4 +37,23 @@ Run a SWMM simulation.
3737
from swmm.toolkit import solver
3838
3939
solver.run('input_file.inp', 'report_file.rpt', 'output_file.out')
40+
4041
```
42+
43+
## Build From Source
44+
45+
> [!NOTE]
46+
> Since version version 0.16.1, swmm-toolkit by default has been built and published
47+
> using the [python stable ABI](https://docs.python.org/3/c-api/stable.html#stable-abi) for
48+
> python 3.9 onward. Using the stable ABI introduces very minor performance reduction while
49+
> substantially simplifying our release process and compatibility with future python versions.
50+
>
51+
> The commands below show how to build this package with and without using the python stable ABI.
52+
53+
### Build with python stable ABI
54+
55+
` python -m build .`
56+
57+
### Build without python stable ABI
58+
59+
` NO_STABLE_ABI=1 python -m build`

swmm-toolkit/build-requirements.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)