Skip to content

Commit 32bbaac

Browse files
authored
Configure GitHub Actions to Build Wheels on Windows, Linux, and MacOS (pyswmm#45)
Updates GitHub Actions to build wheels
1 parent 75f429b commit 32bbaac

File tree

6 files changed

+85
-18
lines changed

6 files changed

+85
-18
lines changed

Diff for: .github/workflows/python-package.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build Wheels
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build_wheels:
7+
name: Build wheels on ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
os: [windows-2016, ubuntu-latest, macos-latest]
13+
py: [3.6, 3.7, 3.8]
14+
15+
steps:
16+
- name: Checkout repo
17+
uses: actions/checkout@v2
18+
with:
19+
submodules: true
20+
21+
- name: Install Python
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.py }}
25+
26+
- name: Install build requirements
27+
if: ${{ contains(matrix.os, 'windows') }}
28+
run: choco install swig
29+
30+
- if: ${{ contains(matrix.os, 'ubuntu') }}
31+
run: sudo apt-get install swig
32+
33+
- if: ${{ contains(matrix.os, 'macos') }}
34+
run: brew install libomp swig
35+
36+
- name: Build wheel
37+
run: pip wheel --wheel-dir=./dist ./swmm-toolkit
38+
39+
- name: Upload artifacts
40+
uses: actions/upload-artifact@v2
41+
with:
42+
path: ./dist/swmm_toolkit*.whl

Diff for: .gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
# .gitignore for swmm-python repo
33
#
44

5+
!.git*
56

6-
.*
7-
!.gitignore
8-
!.gitmodules
97
.DS_Store
108

119
*.pyc

Diff for: README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33

44
## Contents
5-
* nrtest-swmm - Plugin for performing numerical regression testing on swmm-solver.
6-
* swmm-toolkit - SWIG based wrappers for the swmm-solver and swmm-output libraries.
7-
* ...
5+
nrtest-swmm - Plugin for performing numerical regression testing on swmm-solver.
6+
7+
8+
swmm-toolkit - SWIG based wrappers for the swmm-solver and swmm-output libraries.
9+
10+
![Build Wheels](https://github.com/SWMM-Project/swmm-python/workflows/Build%20Wheels/badge.svg)

Diff for: swmm-toolkit/CMakeLists.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ cmake_minimum_required (VERSION 3.17)
1414
project(swmm-toolkit)
1515

1616

17-
set(Python_FIND_VIRTUALENV FIRST)
18-
set(Python_ROOT_DIR "/usr/local/anaconda3")
19-
find_package(Python 3.7 COMPONENTS Development Interpreter REQUIRED)
17+
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
18+
set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR})
19+
set(Python_LIBRARY ${PYTHON_LIBRARY})
20+
find_package (Python ${PYTHON_VERSION_STRING} COMPONENTS Interpreter Development)
2021

2122

2223
find_package(SWIG REQUIRED)

Diff for: swmm-toolkit/pyproject.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
3+
4+
[build-system]
5+
requires = ["setuptools", "wheel", "scikit-build", "cmake"]
6+
build-backend = "setuptools.build_meta"

Diff for: swmm-toolkit/src/swmm/toolkit/CMakeLists.txt

+26-9
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,27 @@ set(CMAKE_SWIG_FLAGS -py3)
1313

1414
# Determine filename suffix for python extension
1515
if(WIN32)
16-
set(Python_EXTENSION ".${Python_SOABI}.pyd")
16+
set(LIB_EXT "pyd")
1717
else()
18-
set(Python_EXTENSION ".${Python_SOABI}.so")
18+
set(LIB_EXT "so")
1919
endif()
2020

21+
set(Python_EXTENSION ".${Python_SOABI}.${LIB_EXT}")
22+
2123

2224
# Location of package at runtime on MacOS/Linux
2325
if(APPLE)
24-
set(PACKAGE_RPATH "@loader_path/../../../..;@loader_path/../../../../extern")
26+
set(LIB_ROOT "@loader_path")
2527
else()
26-
set(PACKAGE_RPATH "$ORIGIN/../../../..;$ORIGIN/../../../../extern")
28+
set(LIB_ROOT "$ORIGIN")
2729
endif()
2830

31+
set(PACKAGE_RPATH "${LIB_ROOT}/../../../..;${LIB_ROOT}/../../../../extern")
32+
2933

30-
####### OUTPUT TARGET #######
34+
#############################################################
35+
#################### OUTPUT TARGET ####################
36+
#############################################################
3137

3238
set_property(SOURCE output.i
3339
PROPERTY
@@ -48,9 +54,14 @@ target_link_options(output
4854
$<$<BOOL:${APPLE}>:-undefineddynamic_lookup>
4955
)
5056

57+
target_include_directories(output
58+
PUBLIC
59+
${Python_INCLUDE_DIRS}
60+
)
61+
5162
target_link_libraries(output
5263
PUBLIC
53-
Python::Module
64+
$<$<BOOL:$<C_COMPILER_ID:MSVC>>:Python::Module>
5465
swmm-output
5566
)
5667

@@ -82,8 +93,9 @@ install(
8293
"src/swmm/toolkit"
8394
)
8495

85-
86-
####### SOLVER TARGET #######
96+
#############################################################
97+
#################### SOLVER TARGET ####################
98+
#############################################################
8799

88100
set_property(SOURCE solver.i
89101
PROPERTY
@@ -104,9 +116,14 @@ target_link_options(solver
104116
$<$<BOOL:${APPLE}>:-undefineddynamic_lookup>
105117
)
106118

119+
target_include_directories(solver
120+
PUBLIC
121+
${Python_INCLUDE_DIRS}
122+
)
123+
107124
target_link_libraries(solver
108125
PUBLIC
109-
Python::Module
126+
$<$<BOOL:$<C_COMPILER_ID:MSVC>>:Python::Module>
110127
swmm5
111128
)
112129

0 commit comments

Comments
 (0)