Skip to content

Commit

Permalink
License Compliance (#35)
Browse files Browse the repository at this point in the history
### What kind of change does this PR introduce?

* There are now two ways of building the source distribution:
* The source files for RavenHydroFramework can be completely left out of
the source distribution (`.sdist`) and fetched via CMake when a user
installs the package or compiles the package to create a binary and
wheel (`.whl`)
* The source files can be packaged with the source distribution (this
will be the default for packages published on PyPI)
* The license for RavenHydroFramework is now always installed under
site-packages when installing the compiled wheel (under the raven-hydro
metadata licenses folder).
* There are now clear directions in the `README.md` on how to directly
access the RavenHydroFramework source code.

### Does this PR introduce a breaking change?

No. All this does is make the packaged source (and wheel) compliant with
the terms of use of the `Artistic License v2.0`.

### Other information:

These changes will also allow for us to easily package the license for
both projects within the compiled conda package as well, e.g.:
```yaml
about:
  license_file:
    - LICENSE
    - RavenHydroFramework/LICENSE
```
  • Loading branch information
Zeitsperre authored Mar 7, 2024
2 parents 3fdf543 + 3dc106d commit e6724bb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changes

## 0.3.0 (2024-03-06)
## 0.3.0 (2024-03-07)

* Updated the `RavenHydroFramework` to v3.8.
* `raven-hydro` now builds `RavenHydroFramework` directly from the GitHub official source code base.
Expand All @@ -14,6 +14,7 @@
* `setuptools_scm` >=8.0.0
* Now using `dependabot` for dependency and workflow management.
* Now using TestPyPI and PyPI Trusted Publishers infrastructure for signing and verification of packages.
* Numerous packaging fixes to ensure conformant and license-compliant packaging.

## 0.2.4 (2023-08-25)

Expand Down
21 changes: 14 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
PROJECT(${SKBUILD_PROJECT_NAME} LANGUAGES CXX VERSION ${SKBUILD_PROJECT_VERSION})

# Set the RavenHydroFramework source code directory
SET(raven_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/RavenHydroFramework/src)
SET(raven_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/RavenHydroFramework")

# Remove deprecation warnings for GCC
IF(CMAKE_COMPILER_IS_GNUCXX)
Expand Down Expand Up @@ -75,16 +75,16 @@ ENDIF()

# Find header & source
include_directories(${raven_SOURCE_DIR})
FILE(GLOB HEADER "${raven_SOURCE_DIR}/*.h")
FILE(GLOB SOURCE "${raven_SOURCE_DIR}/*.cpp")
FILE(GLOB HEADER "${raven_SOURCE_DIR}/src/*.h")
FILE(GLOB SOURCE "${raven_SOURCE_DIR}/src/*.cpp")

# Add Python files
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}/py/libraven.cpp)
target_include_directories(libraven PUBLIC ${raven_SOURCE_DIR})
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()
Expand All @@ -95,7 +95,7 @@ IF(COMPILE_EXE)
${HEADER}
${SOURCE}
)
target_include_directories(raven PUBLIC ${raven_SOURCE_DIR})
target_include_directories(raven PUBLIC "${raven_SOURCE_DIR}/src")

# FIXME: The issue is that one of these flags determines which files are included in the build, See RavenMain.cpp
# Add flag to indicate which version of ExitGracefully to use (set in RavenMain.cpp)
Expand Down Expand Up @@ -129,7 +129,14 @@ IF(COMPILE_EXE)
ELSE()
add_custom_command(
TARGET raven POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/raven ${SKBUILD_SCRIPTS_DIR}/raven)
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/raven" "${SKBUILD_SCRIPTS_DIR}/raven")
ENDIF()

IF(${raven_POPULATED})
# Add license for RavenHydroFramework to source distribution after building library from sources (fetched via Cmake_FetchContent)
add_custom_command(
TARGET raven POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${raven_SOURCE_DIR}/LICENSE" "${SKBUILD_PLATLIB_DIR}/RavenHydroFramework/LICENSE")
ENDIF()
ENDIF()

Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ Raven-hydro is a Python-based installer for the hydrologic modelling framework [

### Purpose

The goal of this project is to provide a multiplatform installer for the Raven hydrological model using [scikit-build-core](https://github.com/scikit-build/scikit-build-core) and [pybind11](https://github.com/pybind/pybind11). The compiled binary is built with support for [NetCDF4](https://www.unidata.ucar.edu/software/netcdf/), and uses a custom `CMakeLists.txt`, rather than the one provided with the [Raven source code](http://raven.uwaterloo.ca/Downloads.html), in order to leverage `pip` for handling the installation of binaries and libraries.
The goal of this project is to provide a Python-based multiplatform installer for the Raven hydrological model using [scikit-build-core](https://github.com/scikit-build/scikit-build-core) and [pybind11](https://github.com/pybind/pybind11). The compiled binary is built with support for [NetCDF4](https://www.unidata.ucar.edu/software/netcdf/), and uses a custom `CMakeLists.txt`, rather than the one provided with the [Raven source code](http://raven.uwaterloo.ca/Downloads.html), in order to leverage *pip* for handling the installation and management of binaries and libraries.

This project differs from [RavenPy](https://github.com/CSHS-CWRA/RavenPy) by solely providing a means for downloading, compiling, and installing the Raven binary (with NetCDF4 support) on multiple platforms and as well as providing version control and updating via `pip`/PyPI.
This project differs from [RavenPy](https://github.com/CSHS-CWRA/RavenPy) by solely providing a means for downloading, compiling, and installing the Raven binary (with NetCDF4 support) on multiple platforms and as well as providing version control and updating via *pip*/PyPI.

The source code for Raven is not included in this repository, but is fetched from the releases of [RavenHydroFramework GitHub repository](https://github.com/CSHS-CWRA/RavenHydroFramework) and compiled during the installation process.

### Features

- Download and/or compile the Raven hydrological model with `pip`
- Download, compile, version control, and package updating of the Raven Hydrologic model via *pip*/PyPI
- Preserve copyright notices and licensing information
- Multiplatform support (macOS, Linux, Windows, BSD, etc.)

### Installation
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ classifiers = [
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"License :: OSI Approved :: Artistic License",
"Natural Language :: English",
"Programming Language :: C++",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand All @@ -32,7 +34,7 @@ classifiers = [
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Scientific/Engineering :: Hydrology"
]
keywords = ["raven", "hydrologic", "model", "cmake"]
keywords = ["raven", "hydrologic", "hydrology", "model", "cmake", "scikit-build", "pybind11", "python", "wrapper"]
dynamic = ["readme", "version"]
dependencies = []

Expand Down Expand Up @@ -88,6 +90,7 @@ version.provider = "scikit_build_core.metadata.setuptools_scm"

[tool.scikit-build.sdist]
include = [
".zenodo.json",
"AUTHORS.md",
"CHANGES.md",
"CMakeLists.txt",
Expand Down

0 comments on commit e6724bb

Please sign in to comment.