Skip to content

Commit

Permalink
finalize conda recipe (#101)
Browse files Browse the repository at this point in the history
* finalize conda recipe

* update conda recipe

Include python as differentiator
  • Loading branch information
brey authored Feb 25, 2024
1 parent 081db36 commit 339d9db
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 92 deletions.
42 changes: 35 additions & 7 deletions conda.recipe/README
Original file line number Diff line number Diff line change
@@ -1,17 +1,45 @@
# This are the recipe files for conda.

# This is the recipe for conda.

## Files:

meta.yaml : conda config
**meta.yaml** : conda config

**build.sh** : Bash script for compiling based on `CMake`.

build.sh : Bash script for compiling based on CMake.
**conda\_build\_config.yaml** : Used for defining various variants.

conda_build_config.yaml: Used for defining various variants. Currently mpich options.
## Procedure:

cross-linux.cmake : left there for testing. Probably not needed.
Set the options in `conda_build_config.yaml`.

Note that having both false/true in the options would create all combinations.

## Procedure:
It's better if the binaries are then differenciated by adding in the `meta.yaml` file the variable to the name definition e.g.

```python
name: {{ name|lower }}-{{ TVD_LIM|lower }}
```

Edit `meta.yaml` file setting

- version

```python
{% set version = "5.9" %}
```

- branch

```python
git_tag: v5.9
```

Make sure that you have `conda-build` and `conda-verify` in your env. You can use

`conda install conda-build conda-verify`

Build by executing from the folder containing the *conda.recipe* folder:

`conda build conda.recipe`

Upload to your private channel. See [here](https://docs.conda.io/projects/conda-build/en/latest/user-guide/tutorials/build-pkgs.html#optional-uploading-new-packages-to-anaconda-org) for more info.
45 changes: 29 additions & 16 deletions conda.recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,54 @@

set -xeuo pipefail

#export mpi=mpich
export CC=mpicc
export CXX=mpicxx
export FC=mpif90
export F77=mpif77
export F90=mpif90

#Remove metis from cmake
sed -i -e "s|set(PARMETIS_VER|#set(PARMETIS_VER|g" src/CMakeLists.txt
sed -i -e "s|set(PARMETIS_DIR|#set(PARMETIS_DIR|g" src/CMakeLists.txt
sed -i -e "s|add_subdirectory( \${PARMETIS_VER} )|#add_subdirectory( \${PARMETIS_VER} )|g" src/CMakeLists.txt

# build and install schism
mkdir build
cd build

# check if needed on Linux
#CMAKE_PLATFORM_FLAGS+=(-DCMAKE_TOOLCHAIN_FILE="${RECIPE_DIR}/cross-linux.cmake")
# ${CMAKE_PLATFORM_FLAGS[@]} \

cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_Fortran_FLAGS_RELEASE_INIT="-O2 -ffree-line-length-none" \
-DCMAKE_Fortran_FLAGS_DEBUG_INIT="-g -ffree-line-length-none" \
-DCMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT="-O2 -g -ffree-line-length-none" \
-DC_PREPROCESS_FLAG="-cpp" \
-DNetCDF_FORTRAN_DIR="$PREFIX/lib" \
-DNetCDF_C_DIR="$PREFIX/lib" \
-DNetCDF_LIBRARIES="$PREFIX/lib/libnetcdff.dylib;$PREFIX/lib/libnetcdf.dylib" \
-DNetCDF_INCLUDE_DIR="$PREFIX/include" \
-DTVD_LIM="VL" \
-DTVD_LIM=$TVD_LIM \
-DOLDIO=$OLDIO \
-DPREC_EVAP=$PREC_EVAP \
-DUSE_GOTM=$GOTM \
-DUSE_HA=$HA \
-DUSE_SED2D=$SED2D \
-DUSE_MARSH=$MARSH \
-DUSE_WWM=$WWM \
-DUSE_WW3=$WW3 \
-DUSE_ICE=$ICE \
-DUSE_ICM=$ICM \
-DUSE_GEN=$GEN \
-DUSE_AGE=$AGE \
-DUSE_ECO=$ECO \
-DICM_PH=$PH \
-DUSE_COSINE=$COSINE \
-DUSE_FIB=$FIB \
-DUSE_FABM=$FABM \
-DUSE_SED=$SED \
../src
#make -j${CPU_COUNT:-1} # It doesn't seem to work because of the build of parmetis

make

#make install
##make install
cp -r bin/* $PREFIX/bin/
#ln -s $PREFIX/bin/pschism_TVD-VL $PREFIX/bin/schism # optional to be discussed
#make a symlink for convenience
ln -s $PREFIX/bin/pschism_TVD-$TVD_LIM $PREFIX/bin/schism

#clean up
cd ..
rm -r build

cd $BUILD_PREFIX

71 changes: 64 additions & 7 deletions conda.recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,67 @@
python:
- 3.8
- 3.9
- 3.10
- 3.11
mpi:
- openmpi # [not win]
- mpich # [not win]

#pin_run_as_build:
# openmpi: x.x

#pin_run_as_build:
# mpich: x.x

WWM:
# - true
- false
WW3:
# - true
- false
TVD_LIM:
# - SB
- VL
# - MM
# - OS
PREC_EVAP:
# - true
- false
GOTM:
# - true
- false
HA:
# - true
- false
OLDIO:
# - true
- false
SED2D:
# - true
- false
ICE:
# - true
- false
GEN:
# - true
- false
AGE:
# - true
- false
ECO:
# - true
- false
ICM:
# - true
- false
PH:
# - true
- false
COSINE:
# - true
- false
FIB:
# - true
- false
FABM:
# - true
- false
MARSH:
# - true
- false
SED:
# - true
- false
20 changes: 0 additions & 20 deletions conda.recipe/cross-linux.cmake

This file was deleted.

81 changes: 39 additions & 42 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,56 +1,53 @@
{% set name = "schism" %}
{% set version = "5.9.0" %}
{% set name = "pschism" %}
{% set version = "5.10.1" %}
{% set build = 0 %}

# Based on https://github.com/conda-forge/netcdf-fortran-feedstock/blob/master/recipe/meta.yaml
#{% set data = load_setup_py_data() %}

package:
name: {{ name|lower }}
name: {{ name|lower }} #-{{ TVD_LIM|lower }}
version: {{ version }}

source:
# path: ..
url: https://github.com/schism-dev/schism/archive/refs/tags/v5.9.0.tar.gz
sha256: 3f990b8f005079a07a62f08f491ba2818000fb2905772ce50e2253a1334d8420
git_url: https://github.com/schism-dev/schism.git
git_tag: v5.10

build:
number: {{ build }}
skip: true #[win]
merge_build_host: true

outputs:
- name: pschism
script: build.sh
{% set mpi_prefix = "mpi_" + mpi %}
string: {{ mpi_prefix }}_h{{ PKG_HASH }}_{{ build }}
{% set build_pin = mpi_prefix + '_*' %}

requirements:
build:
host:
- {{ compiler('cxx') }}
- {{ compiler('c') }}
- {{ compiler('fortran') }}
- cmake ##>=3.17
- sed
- python #=3.8
- {{ mpi }}
- {{ mpi }}-mpifort
- {{ mpi }}-mpicc
- {{ mpi }}-mpicxx
- netcdf-fortran * {{ mpi_prefix }}_*
run:
- {{ mpi }}
- parmetis
- metis
- netcdf-fortran * {{ mpi_prefix }}_*
# test:
# commands:
# - echo $BUILD_PREFIX
# - echo {{ environ.get('PREFIX') }}
# - echo {{ environ.get('SRC_DIR') }}

{% set mpi_prefix = "mpi_" + mpi %}
string: {{ mpi_prefix }}_py{{ python }}_h{{ PKG_HASH }}_{{ build }}
{% set build_pin = mpi_prefix + '_*' %}

requirements:
build:
host:
- python {{ python }}
- git
- {{ compiler('cxx') }}
- {{ compiler('c') }}
- {{ compiler('fortran') }}
- cmake
- sed
- {{ mpi }}
- {{ mpi }}-mpifort
- {{ mpi }}-mpicc
- {{ mpi }}-mpicxx
- llvm-openmp
- parmetis
- metis
- netcdf-fortran * {{ mpi_prefix }}_*
- libgfortran5
run:
- python {{ python }}
- {{ mpi }}
- llvm-openmp
- parmetis
- metis
- netcdf-fortran * {{ mpi_prefix }}_*
test:
commands:
- schism -v

about:
home: https://github.com/schism-dev/schism
Expand All @@ -61,4 +58,4 @@ about:

extra:
recipe-maintainers:
# - brey
- brey

0 comments on commit 339d9db

Please sign in to comment.