Skip to content
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
107 changes: 48 additions & 59 deletions .github/workflows/build_wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@ jobs:
defaults:
run:
working-directory: ./nrtest-swmm

steps:
- name: Checkout repo
uses: actions/checkout@v5

- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

python-version: "3.10"
- name: Build wheel
run: |
pip install wheel
Expand All @@ -39,22 +36,41 @@ jobs:
with:
name: nrtest-swmm-wheel
path: nrtest-swmm/dist/*.whl


build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./swmm-toolkit
steps:
- name: Checkout repo
uses: actions/checkout@v5
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build sdist
run: |
pip install build
python -m build --sdist --outdir ./dist
- name: Upload sdist artifact
uses: actions/upload-artifact@v4
with:
name: swmm-toolkit-sdist
path: swmm-toolkit/dist/*.tar.gz

build_wheels:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
pyver: [cp39, cp310, cp311, cp312, cp313]

os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-13, macos-latest]
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v5
with:
submodules: true

- name: Build wheels
uses: pypa/[email protected]
with:
Expand All @@ -63,65 +79,38 @@ jobs:
MACOSX_DEPLOYMENT_TARGET: "11.0"
CIBW_TEST_COMMAND: "pytest {package}/tests"
CIBW_BEFORE_TEST: pip install -r {package}/test-requirements.txt
# mac needs ninja to build
CIBW_BEFORE_BUILD_MACOS: brew install ninja
CIBW_ENVIRONMENT_MACOS: |
MACOSX_DEPLOYMENT_TARGET=11.0
# remove system swig (cmake bug doesn't respect python venv)
# https://github.com/swig/swig/issues/2481#issuecomment-1949573105
CIBW_BEFORE_BUILD_LINUX: rm -f $(which swig) && rm -f $(which swig4.0)
# configure cibuildwheel to build native archs ('auto'), and some emulated ones
CIBW_ARCHS_LINUX: x86_64
CIBW_ARCHS_WINDOWS: AMD64
CIBW_ARCHS_MACOS: x86_64 arm64
# only build current supported python: https://devguide.python.org/versions/
# don't build pypy or musllinux to save build time. TODO: find a good way to support those archs
CIBW_BUILD: ${{matrix.pyver}}-*
CIBW_SKIP: cp38-* pp* *-musllinux*
# Will avoid testing on emulated architectures
# Skip trying to test arm64 builds on Intel Macs
CIBW_TEST_SKIP: "*-*linux_{aarch64,ppc64le,s390x} *-macosx_universal2:arm64"
# skip 3.8 and any free threaded variants
CIBW_SKIP: cp38-* cp3??t-*
CIBW_ARCHS: native
CIBW_BUILD_VERBOSITY: 1

- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.pyver }}
name: swmm-toolkit-bdist-${{ matrix.os }}
path: ./wheelhouse/*.whl

build_cross_wheels:
merge_wheels:
name: Consolidate all wheel artifacts
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
pyver: [cp39, cp310, cp311, cp312, cp313]

needs:
- build_wheels
- build_sdist
steps:
- name: Checkout repo
uses: actions/checkout@v5
- name: Download all distribution artifacts
uses: actions/download-artifact@v5
with:
submodules: true

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Build wheels
uses: pypa/[email protected]
path: dist
pattern: swmm-toolkit-*dist*
merge-multiple: true

- name: Upload consolidated archive
uses: actions/upload-artifact@v4
with:
package-dir: ./swmm-toolkit
env:
# remove system swig (cmake bug doesn't respect python venv)
# https://github.com/swig/swig/issues/2481#issuecomment-1949573105
CIBW_BEFORE_BUILD_LINUX: rm -f $(which swig) && rm -f $(which swig4.0)
# configure cibuildwheel to build native archs ('auto'), and some emulated ones
CIBW_ARCHS_LINUX: aarch64
# only build current supported python: https://devguide.python.org/versions/
# don't build pypy or musllinux to save build time. TODO: find a good way to support those archs
CIBW_BUILD: ${{matrix.pyver}}-*
CIBW_SKIP: cp-*38 pp* *-musllinux*
CIBW_BUILD_VERBOSITY: 1
name: swmm_toolkit_dist
path: ./dist/*

- uses: actions/upload-artifact@v4
with:
name: wheels-linux-aarch64-${{ matrix.pyver }}
path: ./wheelhouse/*.whl

18 changes: 9 additions & 9 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ jobs:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"

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

- name: Test wheel
run: |
Expand Down
4 changes: 2 additions & 2 deletions swmm-toolkit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ project(swmm-toolkit
set(Python_FIND_VIRTUALENV FIRST)
#set(CMAKE_FIND_DEBUG_MODE TRUE)
if(NOT MSVC)
find_package (Python3 ${PYTHON_VERSION_STRING} COMPONENTS Interpreter Development.Module REQUIRED)
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
else()
find_package (Python3 ${PYTHON_VERSION_STRING} COMPONENTS Interpreter Development REQUIRED)
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
endif()
#set(CMAKE_FIND_DEBUG_MODE FALSE)

Expand Down
21 changes: 20 additions & 1 deletion swmm-toolkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

## Community

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

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

Expand All @@ -37,4 +37,23 @@ Run a SWMM simulation.
from swmm.toolkit import solver

solver.run('input_file.inp', 'report_file.rpt', 'output_file.out')

```

## Build From Source

> [!NOTE]
> Since version version 0.16.1, swmm-toolkit by default has been built and published
> using the [python stable ABI](https://docs.python.org/3/c-api/stable.html#stable-abi) for
> python 3.9 onward. Using the stable ABI introduces very minor performance reduction while
> substantially simplifying our release process and compatibility with future python versions.
>
> The commands below show how to build this package with and without using the python stable ABI.

### Build with python stable ABI

` python -m build .`

### Build without python stable ABI

` NO_STABLE_ABI=1 python -m build`
8 changes: 0 additions & 8 deletions swmm-toolkit/build-requirements.txt

This file was deleted.

Loading
Loading