Skip to content

Commit

Permalink
Update dependencies (#56)
Browse files Browse the repository at this point in the history
### What kind of change does this PR introduce?

* Raises dependency versions to be stricter
* Adds more dedicated Windows builds to the CI

### Does this PR introduce a breaking change?

It should not.
  • Loading branch information
Zeitsperre authored Nov 4, 2024
2 parents 6bcbf08 + 9e92ce8 commit fcb4935
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 50 deletions.
10 changes: 8 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ updates:
directory: /
schedule:
interval: monthly
open-pull-requests-limit: 10
groups:
python:
patterns:
- "*"

- package-ecosystem: pip
directory: /
schedule:
interval: monthly
open-pull-requests-limit: 10
groups:
python:
patterns:
- "*"
114 changes: 87 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,54 +28,115 @@ jobs:
python-version: "3.x"
cache: "pip"
- name: Run pre-commit hooks
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

build:
build-windows:
name: Python${{ matrix.python-version }} (Windows, conda=${{ matrix.conda }})
needs: black
runs-on: 'windows-latest'
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
conda: [ true, false ]
defaults:
run:
shell: bash -l {0}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
submodules: true
- name: Setup Python${{ matrix.python-version }}
if: ${{ !matrix.conda }}
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Set up Python${{ matrix.python-version }} with NetCDF4 (conda)
if: ${{ matrix.conda }}
uses: mamba-org/setup-micromamba@f8b8a1e23a26f60a44c853292711bacfd3eac822 # v1.9.0
with:
cache-downloads: true
cache-environment: true
environment-file: environment.yml
create-args: >-
python=${{ matrix.python-version }}
post-cleanup: 'all'
# - name: Check for OPeNDAP Support
# if: ${{ matrix.conda }}
# run: |
# nc-config.exe --has-dap

- name: Install raven-hydro
if: ${{ !matrix.conda }}
run: |
python -m pip install --editable . -C cmake.define.USE_NETCDF=false
- name: Install raven-hydro
if: ${{ matrix.conda }}
run: |
python -m pip install --editable .
- name: Check versions
run: |
python -m pip list
python -m pip check
- name: Test raven-hydro
run: |
python -c "import raven_hydro; print(f'Description: {raven_hydro.__doc__}')"
python -c "import raven_hydro; print(f'Built with netcdf: {raven_hydro.__netcdf__}')"
python -c "import raven_hydro; print(f'RavenHydroFramework version: {raven_hydro.__raven_version__}')"
python -c "import raven_hydro; print(f'raven_hydro version: {raven_hydro.__version__}')"
- name: Test raven
run: |
raven -v
build-unix:
name: Python${{ matrix.python-version }} (${{ matrix.os }}, conda=${{ matrix.conda }}, args=${{ matrix.install_args }})
needs: black
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13.0-rc.2"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
os:
- ubuntu-latest
# - macos-latest # macOS with Apple Silicon is not supported yet
conda: [ false ]
conda: [ true, false ]
install_args: [ "" ]
include:
- python-version: "3.8"
os: windows-latest
conda: true
- python-version: "3.9"
os: ubuntu-latest
conda: true
- python-version: "3.10"
os: ubuntu-latest
conda: true
- python-version: "3.10"
os: windows-latest
conda: true
# - python-version: "3.10" # macOS with Apple Silicon is not supported yet
# os: macos-latest
# conda: true
- python-version: "3.11"
os: ubuntu-latest
conda: false
install_args: "-Ccmake.define.USE_NETCDF=false"
- python-version: "3.12"
os: ubuntu-latest
conda: true
conda: false
install_args: "-C cmake.define.USE_NETCDF=false"
defaults:
run:
shell: bash -l {0}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
egress-policy: block
allowed-endpoints: >
api.github.com:443
azure.archive.ubuntu.com:80
conda.anaconda.org:443
esm.ubuntu.com:443
files.pythonhosted.org:443
github.com:443
motd.ubuntu.com:443
objects.githubusercontent.com:443
packages.microsoft.com:443
pypi.org:443
repo.anaconda.com:443
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0
submodules: true
Expand All @@ -95,7 +156,6 @@ jobs:
environment-file: environment.yml
create-args: >-
python=${{ matrix.python-version }}
micromamba-version: "1.5.10-0" # pinned to avoid the breaking changes with mamba and micromamba (2.0.0).
- name: Install NetCDF4 (Ubuntu/apt)
if: (matrix.os == 'ubuntu-latest') && (!matrix.install_args) && (!matrix.conda)
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 0.3.2 (unreleased)

* `raven-hydro` now officially supports `Python` 3.13.
* Several build dependencies have been updated to their latest versions.

## 0.3.1 (2024-06-17)

Expand Down
36 changes: 27 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@ option(COMPILE_LIB "If ON, will create a dynamic lib file (default: OFF)" OFF)
option(COMPILE_EXE "If ON, will create a executable file (default: ON)" ON)
option(PYTHON, "If ON, will create a share library for python (default: OFF)" ON)

# Compiler flags for Windows
IF(WIN32)
message(STATUS "Compiling for Windows")
message(STATUS "Setting MSVC flags for Windows")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
ELSEIF(UNIX)
message(STATUS "Compiling for Unix-like OS")
ENDIF()

# Add CMake module path
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# Set C++ standard explicitly
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_EXTENSIONS OFF)

# Set default build type in CMake if skbuild is set
message(STATUS "CMAKE_BUILD_TYPE set to '${CMAKE_BUILD_TYPE}'")
Expand All @@ -33,7 +42,7 @@ message(STATUS "CMAKE_BUILD_TYPE set to '${CMAKE_BUILD_TYPE}'")
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wno-deprecated)
message(STATUS "Modified compile flags with '-Wno-deprecated'")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
ENDIF()

# Setup Raven Project
PROJECT(${SKBUILD_PROJECT_NAME} LANGUAGES CXX VERSION ${SKBUILD_PROJECT_VERSION})
Expand Down Expand Up @@ -82,17 +91,26 @@ FILE(GLOB HEADER "${raven_SOURCE_DIR}/src/*.h")
FILE(GLOB SOURCE "${raven_SOURCE_DIR}/src/*.cpp")

# Add Python files
if (PYTHON)
IF(PYTHON)
SET(PYBIND11_NEWPYTHON ON)
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
find_package(pybind11 CONFIG REQUIRED)
pybind11_add_module(libraven MODULE "${raven_SOURCE_DIR}/src/py/libraven.cpp")
target_include_directories(libraven PUBLIC "${raven_SOURCE_DIR}/src")
target_compile_features(libraven PUBLIC cxx_std_11)
target_compile_definitions(libraven PUBLIC BMI_LIBRARY)
endif()
ENDIF()

# File extension is OS dependent (Linux: none, Windows: .exe)
IF(WIN32)
SET(EXE_EXTENSION ".exe")
SET(LIB_EXTENSION ".dll")
ELSE()
SET(EXE_EXTENSION "")
SET(LIB_EXTENSION ".so")
ENDIF()

# Create executable; File extension is OS dependent (Linux: none, Windows: .exe)
# Create executable
IF(COMPILE_EXE)
add_executable(raven
${HEADER}
Expand Down Expand Up @@ -144,5 +162,5 @@ IF(COMPILE_EXE)
ENDIF()

# Unset CMake variables to avoid polluting the cache
unset(COMPILE_LIB CACHE)
unset(COMPILE_EXE CACHE)
UNSET(COMPILE_LIB CACHE)
UNSET(COMPILE_EXE CACHE)
12 changes: 6 additions & 6 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ channels:
- defaults
dependencies:
- python >=3.8,<3.14
- pip >=23.3.0
- hatch-fancy-pypi-readme
- hatchling
- pybind11
- scikit-build-core >=0.8
- setuptools-scm >=8
- pip >=24.2.0
- hatch-fancy-pypi-readme >=23.1.0
- hatchling >=1.23.0
- pybind11 >=2.13.0
- scikit-build-core >=0.10
- setuptools-scm >=8.0
- libnetcdf
- zlib
2 changes: 1 addition & 1 deletion helpers/FindNetCDF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ if (PkgConfig_FOUND)
INTERFACE_LINK_LIBRARIES "PkgConfig::_NetCDF")
endif ()

FindNetCDF_get_is_parallel_aware("${_NetCDF_INCLUDEDIR}")
FindNetCDF_get_is_parallel_aware("${_NetCDF_INCLUDE_DIRS}")
# Skip the rest of the logic in this file.
return ()
endif ()
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[build-system]
requires = [
"hatch-fancy-pypi-readme",
"hatchling",
"pybind11",
"scikit-build-core>=0.9",
"setuptools_scm>=8"
"hatch-fancy-pypi-readme >=23.1.0",
"hatchling >=1.23.0",
"pybind11 >=2.13.0,<3.0",
"scikit-build-core>=0.10",
"setuptools_scm>=8.0"
]
build-backend = "scikit_build_core.build"

Expand Down

0 comments on commit fcb4935

Please sign in to comment.