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
185 changes: 136 additions & 49 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# This workflow builds binary wheels using cibuildwheel and a source distribution.
# cibuildwheel handles manylinux and Windows wheel building across Python versions.
# Publishes to TestPyPI on pushes to dev, and PyPI on pushes to main.

name: Build Packages

Expand All @@ -10,80 +11,166 @@ on:
branches: [ "main", "dev" ]

jobs:
build:

make-wheels:
name: Build wheels on ${{ matrix.os }} (compiler ${{ matrix.compiler-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.10","3.11","3.12","3.13"]
os: [ubuntu-latest, windows-latest] #, macos-latest]
compiler: [gcc]
compiler-version: [13, 15]
exclude:
- os: windows-latest
compiler-version: 15
include:
- os: ubuntu-latest
compiler: gcc
compiler-version: 15
- os: windows-latest
compiler: gcc
compiler-version: 13

steps:
- name: Fortran Setup
uses: fortran-lang/setup-fortran@v1
id: setup-fortran
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}
compiler: ${{ matrix.compiler }}
version: ${{ matrix.compiler-version }}

- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
cache: 'pip'

- name: show-versions
fetch-depth: 0

- name: Show compiler versions
run: |
gcc --version
gfortran --version

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install click numpy pandas matplotlib build wheel setuptools setuptools_scm meson-python pytest ninja

- name: Install Patchelf
if: runner.os == 'Linux'
run: |
python -m pip install patchelf

- name: Build and package
run: |
python -m build --no-isolation

- name: Store Wheel
uses: actions/upload-artifact@v4
- name: Build wheels
uses: pypa/cibuildwheel@v3.4.1
env:
# Build for Python 3.10–3.13, 64-bit only
CIBW_BUILD: cp310-* cp311-* cp312-* cp313-* cp314-*
CIBW_SKIP: "*-win32 *-manylinux_i686 *-musllinux*"
CIBW_ARCHS_LINUX: x86_64
CIBW_ARCHS_WINDOWS: AMD64

# Use manylinux_2_28 to get a gfortran-15-capable image
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64

# Install build dependencies inside the wheel-build environment
CIBW_BEFORE_BUILD_LINUX: |
dnf install -y gcc-gfortran ninja-build &&
pip install click numpy pandas build wheel setuptools setuptools_scm meson-python ninja patchelf

CIBW_BEFORE_BUILD_WINDOWS: |
pip install click numpy pandas build wheel setuptools setuptools_scm meson-python ninja

CIBW_BUILD_FRONTEND: "build"
CIBW_BUILD_VERBOSITY: 1

with:
output-dir: dist

- name: Store wheels
uses: actions/upload-artifact@v7
with:
name: pyfvs-${{ runner.os }}-py${{ matrix.python-version }}-wheels
name: pyfvs-${{ matrix.os }}-wheels
path: dist/*.whl
if-no-files-found: warn
overwrite: true

- name: Store Sdist
uses: actions/upload-artifact@v4

make-sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
architecture: x64
cache: pip

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install click numpy pandas build wheel \
setuptools setuptools_scm meson-python ninja patchelf

- name: Create sdist
run: python -m build --sdist --no-isolation

- name: Store sdist
uses: actions/upload-artifact@v7
with:
name: pyfvs-sdist
path: dist/*.tar.gz
if-no-files-found: warn
overwrite: true

- name: Test with pytest
working-directory: .
run: |
pip install confuse typing-extensions openpyxl
pip install dist/*.whl
pytest
publish-testpypi:
name: Publish to TestPyPI (dev branch)
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
needs: [ make-wheels, make-sdist ]
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/pyfvs
permissions:
id-token: write # Required for OIDC trusted publishing

steps:
- name: Download all wheels
uses: actions/download-artifact@v4
with:
pattern: pyfvs-*-wheels
path: dist
merge-multiple: true

- name: Download sdist
uses: actions/download-artifact@v4
with:
name: pyfvs-sdist
path: dist

- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
verbose: true

publish-pypi:
name: Publish to PyPI (main branch)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [ make-wheels, make-sdist ]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pyfvs
permissions:
id-token: write # Required for OIDC trusted publishing

steps:
- name: Download all wheels
uses: actions/download-artifact@v4
with:
pattern: pyfvs-*-wheels
path: dist
merge-multiple: true

- name: Download sdist
uses: actions/download-artifact@v4
with:
name: pyfvs-sdist
path: dist

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
verbose: true
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ Python wrappers and utilities for using the Forest Vegetation Simulator

The PyFVS [FVS source code](https://github.com/forest-modeling/ForestVegetationSimulator/tree/open-dev) is forked from the [USFS FVS GitHub](https://github.com/USDAForestService/ForestVegetationSimulator) repository, [open-dev](https://github.com/USDAForestService/ForestVegetationSimulator/tree/open-dev) branch

_____ ______ __ __ _____
| __ \ | ____|\ \ / / / ____|
| |__) | _ _ | |__ \ \ / / | (____
| ___/ | | | | | __| \ \/ / \___ \
| | | |__| | | | \ / ____) |
|_| \____ | |_| \/ |______/
__/ |
|___/

## Documentation

Check out the new AI generated documentation [wiki](https://deepwiki.com/forest-modeling/PyFVS).
Expand Down
44 changes: 22 additions & 22 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ foreach variant : variants
variant_args += '-DFVS_MORTS_WRAP'

# Add the wrappers to the file lists
f_sources += 'api/variant/@0@/morts_fvs.f'.format(variant)
f90_sources += 'api/morts_wrap.f90'
f_sources += 'src/api/variant/@0@/morts_fvs.f'.format(variant)
f90_sources += 'src/api/morts_wrap.f90'

endif

Expand All @@ -368,7 +368,7 @@ foreach variant : variants
conf_data = configuration_data()
conf_data.set('variant', variant)
configure_file(
input: 'api/globals.f90.in',
input: 'src/api/globals.f90.in',
output: variant + '_globals.f90',
configuration: conf_data
)
Expand All @@ -377,26 +377,26 @@ foreach variant : variants
f90_sources += join_paths(meson.project_build_root(), variant + '_globals.f90')

# Additional API files to compile
# f90_sources += 'api/apisubs.f90'

f90_sources += 'api/version.f90'
f90_sources += 'api/fvs_api.f90'
# f90_sources += 'api/sim_monitor.f90'
# f90_sources += 'api/initialize.f90'
f90_sources += 'api/inventory_trees.f90'
f90_sources += 'api/fvs_step.f90'
f90_sources += 'api/tree_data.f90'
f90_sources += 'api/snag_data.f90'
f90_sources += 'api/carbon_data.f90'
f90_sources += 'api/downwood_data.f90'
# f90_sources += 'api/step_tregro.f90'
f90_sources += 'api/prtrls_wrap.f90'
# f90_sources += 'api/stop_wrap.f90'
# f90_sources += 'api/foo.f90'
# f90_sources += 'api/test.f90'
# f90_sources += 'src/api/apisubs.f90'

f90_sources += 'src/api/version.f90'
f90_sources += 'src/api/fvs_api.f90'
# f90_sources += 'src/api/sim_monitor.f90'
# f90_sources += 'src/api/initialize.f90'
f90_sources += 'src/api/inventory_trees.f90'
f90_sources += 'src/api/fvs_step.f90'
f90_sources += 'src/api/tree_data.f90'
f90_sources += 'src/api/snag_data.f90'
f90_sources += 'src/api/carbon_data.f90'
f90_sources += 'src/api/downwood_data.f90'
# f90_sources += 'src/api/step_tregro.f90'
f90_sources += 'src/api/prtrls_wrap.f90'
# f90_sources += 'src/api/stop_wrap.f90'
# f90_sources += 'src/api/foo.f90'
# f90_sources += 'src/api/test.f90'

# ## TODO: Auto-generate F90 includes from F77
# f90_inc_dirs += 'api/gen/@0@/include'.format(variant)
# f90_inc_dirs += 'src/api/gen/@0@/include'.format(variant)

# # Add the include folders as a dependency to trigger
# inc_dep = declare_dependency(
Expand Down Expand Up @@ -537,4 +537,4 @@ foreach variant : variants
# End variant loop
endforeach

subdir('pyfvs')
subdir('src/pyfvs')
4 changes: 2 additions & 2 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
option('fvsvariants', type: 'array',
choices: ['pn','wc','so','op','oc','ec','ca','nc','bm','ie','ci','ak','ws'], #,'em','tt','cr','ut','ls','cs','sn','ne'],
value: ['pn','wc','so','op','oc','ec','ca','nc','bm','ie','ci','ak','ws'], #,'em','tt','cr','ut','ls','cs','sn','ne'],
# value: ['pn','wc','so','op','oc','ec','ca','nc','bm','ie','ci','ak','ws'], #,'em','tt','cr','ut','ls','cs','sn','ne'],
# value: ['pn','wc','so','op','oc','ec','ca','nc','bm'],
# value: ['ie','ci','ak',],
# value: ['pn',],
value: ['pn',],
# value: ['ws',],
description: 'FVS variants to build'
)
39 changes: 0 additions & 39 deletions pyfvs/pyfvs.cfg

This file was deleted.

Loading
Loading