Skip to content

Commit 5966f12

Browse files
author
cbuahin
committed
Configuring cibuildwheel for portability
Signed-off-by: cbuahin <caleb.buahin@gmail.com>
1 parent 4bf8951 commit 5966f12

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+8603
-1008
lines changed

.github/workflows/unit_testing.yml

Lines changed: 93 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,39 @@ on:
77
branches: [ master]
88

99
env:
10-
BUILD_TYPE: Release
1110
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
1211
VCPKG_EXE: ${{ github.workspace }}/vcpkg/vcpkg
13-
NUGET_FEED_URL: https://nuget.pkg.github.com/USEPA/index.json
1412
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
1513
OMP_NUM_THREADS: 1
16-
BUILD_HOME: build
17-
NUGET_USER_NAME: ${{ secrets.CALEB_NUGET_USER_NAME }}
18-
NUGET_API_KEY: ${{ secrets.GITHUB_TOKEN }}
19-
2014
jobs:
2115
engine_unit_test:
22-
name: Build and Unit Testing of Engine
16+
name: Build and Unit Test C/C++ Engine
2317
permissions: write-all
2418
strategy:
2519
fail-fast: false
2620
matrix:
27-
os: [windows-latest] #, ubuntu-latest, macos-13, macos-latest]
21+
os: [windows-latest, ubuntu-latest, macos-13, macos-latest]
2822
include:
29-
# - os: ubuntu-latest
30-
# alias: Linux
31-
# shell: bash
32-
# cmake_preset: Linux
33-
# shell_extension: .sh
34-
# vcpkg_triplet: x64-linux
35-
36-
# - os: macos-13
37-
# alias: intel-mac
38-
# cmake_preset: Darwin
39-
# shell: bash
40-
# shell_extension: .sh
41-
# vcpkg_triplet: x64-osx
42-
43-
# - os: macos-latest
44-
# alias: apple-silicon
45-
# cmake_preset: Darwin
46-
# shell: bash
47-
# shell_extension: .sh
48-
# vcpkg_triplet: arm64-osx
23+
- os: ubuntu-latest
24+
alias: Linux
25+
shell: bash
26+
cmake_preset: Linux
27+
shell_extension: .sh
28+
vcpkg_triplet: x64-linux
29+
30+
- os: macos-13
31+
alias: intel-mac
32+
cmake_preset: Darwin
33+
shell: bash
34+
shell_extension: .sh
35+
vcpkg_triplet: x64-osx
36+
37+
- os: macos-latest
38+
alias: apple-silicon
39+
cmake_preset: Darwin
40+
shell: bash
41+
shell_extension: .sh
42+
vcpkg_triplet: arm64-osx
4943

5044
- os: windows-latest
5145
alias: win64
@@ -65,11 +59,10 @@ jobs:
6559
repository: microsoft/vcpkg
6660
ref: 2025.02.14
6761
path: vcpkg
68-
69-
- name: Install OpenMP on MacOS
62+
63+
- name: Install OpenMP (MacOS)
7064
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'macos-13' }}
7165
run: |
72-
# brew reinstall --build-from-source libomp
7366
brew reinstall libomp
7467
brew link --force --overwrite libomp
7568
@@ -94,22 +87,15 @@ jobs:
9487
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
9588
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
9689
97-
- name: Install Required Libraries (Windows)
98-
if: ${{ matrix.os == 'windows-latest' }}
99-
run: |
100-
${{ env.VCPKG_EXE }} install
101-
10290
- name: Build Binaries
103-
env:
104-
VCPKG_ROOT: ${{ env.VCPKG_ROOT }}
10591
run: |
106-
cmake -B build-${{ matrix.vcpkg_triplet }} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON --preset=${{ matrix.cmake_preset }}
107-
cmake --build build-${{ matrix.vcpkg_triplet }} --target package
108-
92+
cmake --preset=${{ matrix.cmake_preset }}-debug -B build-${{ matrix.vcpkg_triplet }} -DBUILD_TESTS=ON
93+
cmake --build build-${{ matrix.vcpkg_triplet }} --target package
94+
10995
- name: Unit Test
110-
run: ctest --test-dir build-${{ matrix.vcpkg_triplet }} -C Debug --output-on-failure
96+
run: |
97+
ctest --test-dir ./build-${{ matrix.vcpkg_triplet }} -C Debug --output-on-failure
11198
112-
11399
- name: Upload Artifacts
114100
if: ${{ always() }}
115101
uses: actions/upload-artifact@v4
@@ -118,17 +104,23 @@ jobs:
118104
path: |
119105
build-${{ matrix.vcpkg_triplet }}/*.tar.gz
120106
build-${{ matrix.vcpkg_triplet }}/*.zip
121-
build-${{ matrix.vcpkg_triplet }}/*.nupkg
122-
123107
124108
python_binding_unit_test:
125-
name: Build and Unit Test and Python Bindings
126-
needs: engine_unit_test
109+
name: Build and Unit Test Python Bindings
127110
strategy:
111+
fail-fast: false
128112
matrix:
129113
os: [windows-latest, ubuntu-latest, macos-13, macos-latest]
130114
python: [3.13]
131115
include:
116+
117+
- os: windows-latest
118+
alias: win64
119+
cmake_preset: Windows
120+
shell: cmd
121+
shell_extension: .bat
122+
vcpkg_triplet: x64-windows
123+
132124
- os: ubuntu-latest
133125
alias: Linux
134126
shell: bash
@@ -150,22 +142,50 @@ jobs:
150142
shell_extension: .sh
151143
vcpkg_triplet: arm64-osx
152144

153-
- os: windows-latest
154-
alias: win64
155-
cmake_preset: Windows
156-
shell: cmd
157-
shell_extension: .bat
158-
vcpkg_triplet: x64-windows
159-
160145
runs-on: ${{ matrix.os }}
161146
defaults:
162147
run:
163148
shell: ${{ matrix.shell }}
164149

165150
steps:
166-
# - name: Checkout SWMM Repo
167-
# uses: actions/checkout@v4
151+
- name: Checkout SWMM Repo
152+
uses: actions/checkout@v4
153+
154+
- name: Checkout VCPKG
155+
uses: actions/checkout@v4
156+
with:
157+
repository: microsoft/vcpkg
158+
ref: 2025.02.14
159+
path: vcpkg
160+
161+
- name: Install OpenMP and Ninja (MacOS)
162+
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'macos-13' }}
163+
run: |
164+
brew reinstall libomp
165+
brew link --force --overwrite libomp
166+
brew install ninja
167+
168+
- name: Bootstrap VCPKG (Windows)
169+
if: ${{ matrix.os == 'windows-latest' }}
170+
working-directory: ${{ env.VCPKG_ROOT }}
171+
run: |
172+
.\bootstrap-vcpkg${{ matrix.shell_extension }}
173+
.\vcpkg.exe integrate install
174+
175+
- name: Bootstrap VCPKG (Unix like)
176+
if: ${{ matrix.os != 'windows-latest' }}
177+
working-directory: ${{ env.VCPKG_ROOT }}
178+
run: |
179+
./bootstrap-vcpkg${{ matrix.shell_extension }}
180+
chmod +x vcpkg
168181
182+
- name: Export GitHub Actions cache environment variables
183+
uses: actions/github-script@v7
184+
with:
185+
script: |
186+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
187+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
188+
169189
- name: Setup python
170190
uses: actions/setup-python@v4
171191
with:
@@ -175,23 +195,33 @@ jobs:
175195
working-directory: ${{ github.workspace }}/python
176196
run: |
177197
python -m pip install --upgrade pip
178-
python -m pip install -r requirements-swmm.txt
198+
python -m pip install -r requirements.txt
179199
180-
- name: Build Wheels
181-
working-directory: ${{ github.workspace }}/python
182-
run: |
183-
python -m build --sduild
184-
cibuildwheel --output-dir wheelhouse
185-
186200
- name: Build and Install
187201
working-directory: ${{ github.workspace }}/python
188202
run: |
203+
pyclean .
204+
python setup.py build_ext --inplace
189205
python -m pip install .
190206
191207
- name: Unit Test
192208
working-directory: ${{ github.workspace }}/python
193209
run: |
194210
python -m pytest -v tests
211+
python setup.py clean --all
212+
python -m build .
213+
214+
- name: Build Wheels
215+
uses: pypa/cibuildwheel@v2.23.2
216+
with:
217+
package-dir: ./python
218+
output-dir: ./python/wheelhouse
219+
env:
220+
# CIBW_TEST_COMMAND: "python {package}/setup.py build_ext --inplace && python -m pip install {package} && python -m pytest {package}/tests -v"
221+
CIBW_BEFORE_TEST: "pip install -r {package}/requirements.txt && python -m pip install ninja"
222+
CIBW_BUILD_VERBOSITY: 1
223+
CIBW_BEFORE_BUILD_MACOS: brew install ninja
224+
CIBW_REPAIR_WHEEL_COMMAND: ''
195225

196226
- name: Upload Python Wheels
197227
if: ${{ always() }}

CMakeLists.txt

Lines changed: 66 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,22 @@
1111
# US EPA ORD/CESER
1212
#
1313

14-
cmake_minimum_required (VERSION 3.27)
14+
cmake_minimum_required (VERSION 3.15...3.31)
1515

1616
if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
1717
message(FATAL_ERROR "In-source builds are disabled.")
1818
endif()
1919

20-
project(swmm-solver
20+
project(swmm
2121
VERSION 5.3.0
2222
LANGUAGES C CXX
2323
)
2424

25-
# Append local dir to module search path
26-
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
25+
set(CMAKE_MACOSX_RPATH ON)
2726

2827
# Sets the position independent code property for all targets
2928
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
3029

31-
# Sets default install prefix when cmakecache is initialized for first time
32-
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
33-
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "..." FORCE)
34-
endif()
35-
36-
37-
# Define install locations (will be prepended by install prefix)
38-
set(TOOL_DIST "bin")
39-
set(INCLUDE_DIST "include")
40-
set(LIBRARY_DIST "lib")
41-
set(CONFIG_DIST "cmake")
42-
43-
4430
# Define build options
4531
option(BUILD_TESTS "Builds component tests (requires Boost)" OFF)
4632
option(BUILD_DEF "Builds library with def file interface" OFF)
@@ -56,10 +42,72 @@ if(BUILD_TESTS)
5642
add_subdirectory(tests)
5743
endif()
5844

45+
# CONFIGURE BUILD_NUMBER, BUILD_ID, BUILD_COMMIT, BUILD_BRANCH, BUILD_DATE
46+
string(TIMESTAMP BUILD_TIMESTAMP "%Y-%m-%d %H:%M:%S UTC")
47+
set(BUILD_DATE "${BUILD_TIMESTAMP}" CACHE STRING "Build date" FORCE)
48+
49+
execute_process(
50+
COMMAND git rev-parse HEAD
51+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
52+
OUTPUT_VARIABLE GIT_COMMIT_HASH
53+
OUTPUT_STRIP_TRAILING_WHITESPACE
54+
)
55+
56+
# Get the branch name
57+
execute_process(
58+
COMMAND git rev-parse --abbrev-ref HEAD
59+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
60+
OUTPUT_VARIABLE GIT_BRANCH_NAME
61+
OUTPUT_STRIP_TRAILING_WHITESPACE
62+
)
63+
64+
string(
65+
UUID BUILD_ID
66+
NAMESPACE "00000000-0000-0000-0000-000000000000"
67+
NAME "https://www.epa.gov/water-research/storm-water-management-model-swmm"
68+
TYPE MD5
69+
)
70+
set(BUILD_ID "${BUILD_ID}" CACHE STRING "Build ID" FORCE)
71+
set(BUILD_BRANCH "${GIT_BRANCH_NAME}" CACHE STRING "Build branch" FORCE)
72+
set(BUILD_COMMIT "${GIT_COMMIT_HASH}" CACHE STRING "Build commit" FORCE)
5973

6074
# Create install rules for vcruntime.dll, msvcp.dll, vcomp.dll etc.
6175
set(CMAKE_INSTALL_OPENMP_LIBRARIES TRUE)
62-
include(InstallRequiredSystemLibraries)
76+
include(GNUInstallDirs)
77+
include(CMakePackageConfigHelpers)
78+
79+
# Configure the package configuration file
80+
configure_file(
81+
${CMAKE_CURRENT_SOURCE_DIR}/cmake/swmmConfig.cmake.in
82+
${CMAKE_CURRENT_BINARY_DIR}/swmmConfig.cmake
83+
@ONLY
84+
)
85+
86+
# Generate the version file
87+
write_basic_package_version_file(
88+
${CMAKE_CURRENT_BINARY_DIR}/swmmConfigVersion.cmake
89+
VERSION ${PROJECT_VERSION}
90+
COMPATIBILITY AnyNewerVersion
91+
)
92+
93+
# Define install locations (will be prepended by install prefix)
94+
install(
95+
FILES
96+
${CMAKE_CURRENT_BINARY_DIR}/swmmConfig.cmake
97+
${CMAKE_CURRENT_BINARY_DIR}/swmmConfigVersion.cmake
98+
DESTINATION
99+
${CMAKE_INSTALL_LIBDIR}/cmake/swmm
100+
)
101+
102+
# Install the config file
103+
install(
104+
EXPORT
105+
swmmTargets
106+
NAMESPACE
107+
swmm::
108+
DESTINATION
109+
${CMAKE_INSTALL_LIBDIR}/cmake/swmm
110+
)
63111

64112

65113
# Configure CPack driven installer package

0 commit comments

Comments
 (0)