From 339d9db052108d5e20188bf5eb71c2ea199578dd Mon Sep 17 00:00:00 2001 From: George Breyiannis Date: Sun, 25 Feb 2024 14:36:20 +0100 Subject: [PATCH] finalize conda recipe (#101) * finalize conda recipe * update conda recipe Include python as differentiator --- conda.recipe/README | 42 ++++++++++++--- conda.recipe/build.sh | 45 ++++++++++------ conda.recipe/conda_build_config.yaml | 71 +++++++++++++++++++++--- conda.recipe/cross-linux.cmake | 20 ------- conda.recipe/meta.yaml | 81 ++++++++++++++-------------- 5 files changed, 167 insertions(+), 92 deletions(-) delete mode 100644 conda.recipe/cross-linux.cmake diff --git a/conda.recipe/README b/conda.recipe/README index 026bf89fd..6fbdee76d 100644 --- a/conda.recipe/README +++ b/conda.recipe/README @@ -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. diff --git a/conda.recipe/build.sh b/conda.recipe/build.sh index b71e02a74..e7453a1db 100755 --- a/conda.recipe/build.sh +++ b/conda.recipe/build.sh @@ -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 - diff --git a/conda.recipe/conda_build_config.yaml b/conda.recipe/conda_build_config.yaml index a102efb17..0902d5664 100644 --- a/conda.recipe/conda_build_config.yaml +++ b/conda.recipe/conda_build_config.yaml @@ -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 diff --git a/conda.recipe/cross-linux.cmake b/conda.recipe/cross-linux.cmake deleted file mode 100644 index bb837eea5..000000000 --- a/conda.recipe/cross-linux.cmake +++ /dev/null @@ -1,20 +0,0 @@ -# this one is important -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_PLATFORM Linux) -#this one not so much -set(CMAKE_SYSTEM_VERSION 1) - -# specify the cross compiler -set(CMAKE_C_COMPILER $ENV{CC}) - -# where is the target environment -set(CMAKE_FIND_ROOT_PATH $ENV{PREFIX} $ENV{BUILD_PREFIX}/$ENV{HOST}/sysroot) - -# search for programs in the build host directories -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -# for libraries and headers in the target directories -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) - -# god-awful hack because it seems to not run correct tests to determine this: -set(__CHAR_UNSIGNED___EXITCODE 1) diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index aff5f2469..36dcd1d42 100644 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -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 @@ -61,4 +58,4 @@ about: extra: recipe-maintainers: -# - brey + - brey