Skip to content

Commit

Permalink
Merge pull request #119 from pyswmm/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
karosc committed Sep 5, 2023
2 parents 7d00e9d + a352ade commit 3fb9b17
Show file tree
Hide file tree
Showing 16 changed files with 282 additions and 241 deletions.
120 changes: 120 additions & 0 deletions .github/workflows/build_wheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Build Wheels

# Cross compile wheels only on main branch and tags
on:
pull_request:
branches:
- master
push:
branches:
- master
tags:
- v*
workflow_dispatch:

jobs:
build_nrtest_plugin:
name: Build nrtest-swmm plugin
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./nrtest-swmm

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: true

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: 3.7

- name: Build wheel
run: |
pip install wheel
python setup.py bdist_wheel
- uses: actions/upload-artifact@v3
with:
path: nrtest-swmm/dist/*.whl



build_wheels:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-2022, macos-12]
pyver: [cp38, cp39, cp310, cp311]

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: true

- name: Build wheels
uses: pypa/cibuildwheel@v2.15.0
with:
package-dir: ./swmm-toolkit
env:
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
# 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
# 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: cp36-* cp37-* cp312-* 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_arm64 *-macosx_universal2:arm64"

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

build_cross_wheels:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest,macos-12]
pyver: [cp38, cp39, cp310, cp311]

steps:
- name: Checkout repo
uses: actions/checkout@v3
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/cibuildwheel@v2.15.0
with:
package-dir: ./swmm-toolkit
env:
# mac needs ninja to build
CIBW_BEFORE_BUILD_MACOS: brew install ninja
# configure cibuildwheel to build native archs ('auto'), and some emulated ones
CIBW_ARCHS_LINUX: aarch64
CIBW_ARCHS_MACOS: 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: cp36-* cp37-* cp312-* pp* *-musllinux*

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
50 changes: 0 additions & 50 deletions .github/workflows/conda-test.yml

This file was deleted.

116 changes: 0 additions & 116 deletions .github/workflows/python-package.yml

This file was deleted.

63 changes: 63 additions & 0 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Unit Test

on:
push:
branches-ignore:
- 'master'
tags-ignore:
- v*
pull_request:
branches-ignore:
- 'master'

jobs:
build_and_test:
name: Build and test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./swmm-toolkit

strategy:
fail-fast: false
matrix:
os: [windows-2022, macos-12, ubuntu-latest]
include:
- os: windows-2022
sys_pkgs: choco install swig
activate: ./build-env/Scripts/activate

- os: macos-12
sys_pkgs: brew install swig ninja
activate: source ./build-env/bin/activate

- os: ubuntu-latest
activate: source ./build-env/bin/activate

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: true

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install required system packages
run: ${{matrix.sys_pkgs}}

- name: Build wheel in virtual env
run: |
python -m venv --clear ./build-env
${{matrix.activate}}
python -m pip install -r build-requirements.txt
python setup.py bdist_wheel
deactivate
- name: Test wheel
run: |
pip install -r test-requirements.txt
pip install --no-index --find-links=./dist swmm_toolkit
pytest
17 changes: 5 additions & 12 deletions swmm-toolkit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cmake_minimum_required (VERSION 3.17)

project(swmm-toolkit
VERSION
0.14.0
0.15.0
)


Expand All @@ -36,17 +36,10 @@ cmake_policy(SET CMP0078 NEW)
cmake_policy(SET CMP0086 NEW)
include(${SWIG_USE_FILE})


# If wheel build on Apple fetch and build OpenMP Library
if (APPLE)
include(./extern/openmp.cmake)
else()
find_package(OpenMP
OPTIONAL_COMPONENTS
C
)
endif()

find_package(OpenMP
OPTIONAL_COMPONENTS
C
)

# Add project subdirectories
add_subdirectory(swmm-solver)
Expand Down

0 comments on commit 3fb9b17

Please sign in to comment.