Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
24fbb48
Switch from micromamba action to miniforge
mdpiper Dec 18, 2024
4d2a587
Only test on python=3.13
mdpiper Dec 18, 2024
5508b17
Set up Windows job
mdpiper Dec 18, 2024
e166789
Checkout submodule on Windows
mdpiper Dec 18, 2024
bf375a6
Back to micromamba, I guess
mdpiper Dec 18, 2024
4cd8676
Set the FC environment variable
mdpiper Dec 18, 2024
a367e80
Use an absolute path to flang
mdpiper Dec 18, 2024
a3cc21c
Use ninja build backend
mdpiper Dec 18, 2024
4243fc3
Set PREFIX environment variable
mdpiper Dec 18, 2024
75a191b
Use contexts for env vars in cmake call
mdpiper Dec 18, 2024
92fb754
Make a LINKER variable pointing to the VS linker
mdpiper Dec 18, 2024
a64c012
Quote LINKER variable in cmake call
mdpiper Dec 18, 2024
66e102e
Checkout bmi-example-fortran v2.1.4
mdpiper Dec 19, 2024
20a8f4f
Restructure for flang 19
mdpiper Dec 19, 2024
a36cef4
Use build isolation with pip install
mdpiper Dec 19, 2024
de31738
CONDA_PREFIX is now available
mdpiper Dec 19, 2024
b20157d
Push MSVC link.exe to front of path
mdpiper Dec 19, 2024
43f829f
Remove the link.exe in the Git install
mdpiper Dec 19, 2024
8286103
Quote path to link.exe
mdpiper Dec 19, 2024
d986152
Use dependency function and pkg-config to find deps
mdpiper Dec 20, 2024
d658e72
Use LIBRARY_PREFIX env var to install HeatModelF
mdpiper Dec 20, 2024
4a972b1
Try to best match working example
mdpiper Dec 20, 2024
a37ddf3
Thanks, VS Code
mdpiper Dec 20, 2024
fdcfd11
Append conda libpath to Windows LIB
mdpiper Dec 20, 2024
03f74b2
Add tests
mdpiper Dec 20, 2024
104e954
Specify path to config file for bmi-tester
mdpiper Dec 20, 2024
9c417af
Also set absolute path to bmi-tester root dir
mdpiper Dec 20, 2024
5fe6965
Don't run bmi-tester on Windows
mdpiper Dec 20, 2024
10a7705
Add notes on workflow steps
mdpiper Dec 21, 2024
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
86 changes: 83 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
BUILD_DIR: _build

jobs:
build-and-test:
build-test-unix:
if:
github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

Expand All @@ -19,7 +19,6 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand All @@ -42,13 +41,94 @@ jobs:
run: |
make install

- name: Test BMI
- name: Test imports
working-directory: ${{ github.workspace }}/examples
run: |
python -c 'import pymt_heatf'
python -c 'from pymt.models import HeatModelF'

- name: Test BMI
run: |
make test

- name: Run examples
working-directory: ${{ github.workspace }}/examples
run: |
python heatf_ex.py
python pymt_heatf_ex.py

build-test-windows:
if:
github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

runs-on: windows-latest

env:
LIBRARY_PREFIX: $env:CONDA_PREFIX\Library

defaults:
run:
shell: pwsh

steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: ilammy/msvc-dev-cmd@v1

- uses: mamba-org/setup-micromamba@v2
with:
micromamba-version: latest
environment-file: environment.yml
init-shell: >-
powershell

# The Fortran conda compiler, flang, needs to be set over the gfortran installed by chocolatety.
- name: Set the FC environment variable
run: |
echo "FC=$env:CONDA_PREFIX\Library\bin\flang-new.exe" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append

# A link.exe installed by chocolatey was ahead of the MSVC link.exe in the path.
- name: Remove link.exe in the Git install
run: |
Remove-Item -Path "C:\Program Files\Git\usr\bin\link.exe" -Force

# The flang FortranRuntime.lib wasn't being found. This recommendation comes from the Meson docs.
- name: Add conda environment libpath to Windows LIB (not LIBPATH)
run: |
echo "LIB=$env:LIB;$env:CONDA_PREFIX\Library\lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: View environment variables
run: |
ls env:

# The install prefix must be quoted.
- name: Configure, build, and install HeatModelF
run: |
pushd ./external/bmi-example-fortran
cmake -B ${{ env.BUILD_DIR }} -LA -G Ninja -DCMAKE_INSTALL_PREFIX="${{ env.LIBRARY_PREFIX }}" -DCMAKE_BUILD_TYPE=Release
cmake --build ${{ env.BUILD_DIR }} --target install --config Release
popd

- name: Build and install package
run: |
make install

- name: Test imports
working-directory: ${{ github.workspace }}/examples
run: |
python -c 'import pymt_heatf'
python -c 'from pymt.models import HeatModelF'

# Weird Windows stuff here. If the examples in the next step run to completion, the BMI works.
# - name: Test BMI
# working-directory: ${{ github.workspace }}
# run: |
# bmi-test pymt_heatf._bmi:HeatModelF --config-file=${{ github.workspace }}\examples\test.cfg --root-dir=examples -vvv

- name: Run examples
working-directory: ${{ github.workspace }}/examples
run: |
python heatf_ex.py
python pymt_heatf_ex.py
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ dist: clean ## builds source and wheel package
ls -l dist

install: clean ## install the package to the active Python's site-packages
python -m pip install . -v
python -m pip install . -v --no-build-isolation
12 changes: 8 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(
'pymt_heatf',
'c', 'cython', 'fortran',
version: '3.1.dev0',
version: '3.2.dev0',
license: 'MIT',
)

Expand All @@ -25,10 +25,14 @@ incs = include_directories(
]
)

# gfortran on Linux/macOS can find these libraries with fc.find_library(); flang 19 on Windows cannot.
bmif_dep = dependency('bmif', method: 'pkg-config')
heatf_dep = dependency('heatf', method: 'pkg-config')
bmiheatf_dep = dependency('bmiheatf', method: 'pkg-config')
deps = [
fc.find_library('bmif'),
fc.find_library('heatf'),
fc.find_library('bmiheatf'),
bmif_dep,
heatf_dep,
bmiheatf_dep,
py.dependency(),
]

Expand Down
Loading