From c6f07b47d7805702ff1a12585c8ae7ad41ec1c92 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Sun, 19 May 2019 18:38:39 +0200
Subject: [PATCH] Switch to conda-forge

---
 conda/plumed/build.sh     | 24 ++++++++++++++++
 conda/plumed/meta.yaml    | 58 +++++++++++++++++++++++++++++++++++++++
 conda/py-plumed/build.sh  |  4 +--
 conda/py-plumed/meta.yaml |  6 ++--
 conda/recipe/build.sh     | 37 -------------------------
 conda/recipe/meta.yaml    | 46 -------------------------------
 conda/run-conda-build.sh  |  6 ++--
 7 files changed, 90 insertions(+), 91 deletions(-)
 create mode 100644 conda/plumed/build.sh
 create mode 100644 conda/plumed/meta.yaml
 delete mode 100644 conda/recipe/build.sh
 delete mode 100644 conda/recipe/meta.yaml

diff --git a/conda/plumed/build.sh b/conda/plumed/build.sh
new file mode 100644
index 000000000..a0d488bab
--- /dev/null
+++ b/conda/plumed/build.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+if [[ $(uname) == "Linux" ]]; then
+# STATIC_LIBS is a PLUMED specific option and is required on Linux for the following reason:
+# When using env modules the dependent libraries can be found through the
+# LD_LIBRARY_PATH or encoded configuring with -rpath.
+# Conda does not use LD_LIBRARY_PATH and it is thus necessary to suggest where libraries are.
+  export STATIC_LIBS=-Wl,-rpath-link,$PREFIX/lib
+fi
+
+# we also store path so that software linking libplumedWrapper.a knows where libplumedKernel can be found.
+export CPPFLAGS="-D__PLUMED_DEFAULT_KERNEL=$PREFIX/lib/libplumedKernel$SHLIB_EXT $CPPFLAGS"
+
+# libraries are explicitly listed here due to --disable-libsearch
+export LIBS="-lgsl -lgslcblas -llapack -lblas -lxdrfile -lz $LIBS"
+
+# python is disabled since it should be provided as a separate package
+# --disable-libsearch forces to link only explicitely requested libraries
+# --disable-static-patch avoid tests that are only required for static patches
+./configure --prefix=$PREFIX --disable-python --disable-libsearch --disable-static-patch
+
+make -j${CPU_COUNT}
+make install
+
diff --git a/conda/plumed/meta.yaml b/conda/plumed/meta.yaml
new file mode 100644
index 000000000..916b987c3
--- /dev/null
+++ b/conda/plumed/meta.yaml
@@ -0,0 +1,58 @@
+{% set name = "plumed" %}
+{% set version = environ['VERSION'] %}
+
+package:
+  name: {{ name|lower }}
+  version: {{ version }}
+
+source:
+  path: ../..
+
+build:
+  number: 0
+  skip: True  # [win]
+# Most programs should link libplumedWrapper.a so that libplumedKernel.so will be loaded
+# with dlopen. There is no need for pinning thus.
+# Programs linking libplumed.so should pin to min_pin='x.x', max_pin='x'.
+# Programs linking libplumedKernel.so should pin to min_pin='x.x.x'. max_pin='x.x.x'.
+
+requirements:
+  build:
+    - {{ compiler('c') }}
+    - {{ compiler('cxx') }}
+# xxd is provided by package vim and used during build
+    - vim  # [linux]
+  host:
+    - gsl
+    - libblas
+    - liblapack
+    - xdrfile
+    - zlib
+
+test:
+  commands:
+    - plumed info --root
+    - plumed info --long-version
+    - plumed-patch -h
+    - plumed config has external_blas external_lapack gsl xdrfile zlib
+    - $PREFIX/lib/plumed/plumed-runtime -h
+    - test -f $PREFIX/lib/libplumed.a
+    - test -f $PREFIX/lib/libplumed$SHLIB_EXT
+    - test -f $PREFIX/lib/libplumedWrapper.a
+    - test -f $PREFIX/lib/libplumedKernel$SHLIB_EXT
+    - conda inspect linkages -p $PREFIX $PKG_NAME
+    - conda inspect objects -p $PREFIX $PKG_NAME  # [osx]
+
+about:
+  home: http://www.plumed.org/
+  license: LGPL-3.0
+  license_family: LGPL
+  license_file: COPYING.LESSER
+  summary: 'Free energy calculations in molecular systems'
+  description: |
+    PLUMED is an open source library for free energy calculations in
+    molecular systems which works together with some of the most
+    popular molecular dynamics engines.
+  doc_url: https://plumed.github.io/doc-v2.5/user-doc/html/index.html
+  dev_url: https://github.com/plumed/plumed2
+
diff --git a/conda/py-plumed/build.sh b/conda/py-plumed/build.sh
index c93d32285..98077bd25 100644
--- a/conda/py-plumed/build.sh
+++ b/conda/py-plumed/build.sh
@@ -1,9 +1,7 @@
 #!/bin/bash
 
-env | sort
-
 cd python
 make pip
 export plumed_default_kernel=$PREFIX/lib/libplumedKernel$SHLIB_EXT
-$PYTHON -m pip install .
+$PYTHON -m pip install . --no-deps -vv
 
diff --git a/conda/py-plumed/meta.yaml b/conda/py-plumed/meta.yaml
index e990bdb50..1a78b89b5 100644
--- a/conda/py-plumed/meta.yaml
+++ b/conda/py-plumed/meta.yaml
@@ -26,16 +26,16 @@ requirements:
 test:
   requires:
     - plumed
-  # TODO. In principle these could be the official regtests.
   commands:
     - python -c "import plumed; p=plumed.Plumed(); print(p)"
 
 about:
   home: http://www.plumed.org/
-  license: LGPL
+  license: LGPL-3.0
+  license_family: GPL
   license_file: COPYING.LESSER
   summary: 'Python wrappers for plumed library'
-  description: >
+  description: |
     PLUMED is an open source library for free energy calculations in
     molecular systems which works together with some of the most
     popular molecular dynamics engines.
diff --git a/conda/recipe/build.sh b/conda/recipe/build.sh
deleted file mode 100644
index fc1c13d21..000000000
--- a/conda/recipe/build.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-env | sort
-
-# GB: install xdrfile library
-if true; then
-    wget http://ftp.gromacs.org/pub/contrib/xdrfile-1.1.4.tar.gz
-    tar xzf xdrfile-1.1.4.tar.gz
-    cd xdrfile-1.1.4
-    ./configure --prefix=$PREFIX --enable-shared
-    make
-    make install
-    cd ../
-fi
-
-# TODO: install docs?
-
-# python wrapper is installed with pip
-# we temporarily use internal lapack/blas (should probably be fixed)
-# STATIC_LIBS is required on Linux for the following reason:
-# When using env modules the dependent libraries can be found through the
-# LD_LIBRARY_PATH or encoded configuring with -rpath.
-# Conda does not use LD_LIBRARY_PATH and it is thus necessary to suggest where libraries are.
-
-if test -n "$MACOSX_DEPLOYMENT_TARGET" ; then
-  opt=""
-else
-  opt=STATIC_LIBS=-Wl,-rpath-link,$PREFIX/lib
-fi
-
-export CPPFLAGS="-D__PLUMED_DEFAULT_KERNEL=$PREFIX/lib/libplumedKernel$SHLIB_EXT $CPPFLAGS"
-
-./configure --prefix=$PREFIX --enable-shared --disable-python --disable-external-lapack --disable-external-blas $opt
-
-make -j4
-make install
-
diff --git a/conda/recipe/meta.yaml b/conda/recipe/meta.yaml
deleted file mode 100644
index dadffe837..000000000
--- a/conda/recipe/meta.yaml
+++ /dev/null
@@ -1,46 +0,0 @@
-{% set name = "plumed" %}
-{% set version = environ['VERSION'] %}
-
-package:
-  name: {{ name|lower }}
-  version: {{ version }}
-
-source:
-  path: ../..
-
-build:
-  number: 0
-  skip: True  # [win]
-
-requirements:
-  build:
-    - {{ compiler('c') }}
-    - {{ compiler('cxx') }}
-  host:
-    - zlib
-# cannot link gsl on MacOS
-    - gsl # [linux]
-  run:
-    - zlib
-    - gsl # [linux]
-
-test:
-  # TODO. In principle these could be the official regtests.
-  commands:
-    - plumed info --root
-    - plumed info --version
-    - plumed info --long-version
-    - $PREFIX/lib/plumed/plumed-runtime -h
-
-about:
-  home: http://www.plumed.org/
-  license: LGPL
-  license_file: COPYING.LESSER
-  summary: 'Free energy calculations in molecular systems'
-  description: >
-    PLUMED is an open source library for free energy calculations in
-    molecular systems which works together with some of the most
-    popular molecular dynamics engines.
-  doc_url: https://plumed.github.io/doc-v2.5/user-doc/html/index.html
-  dev_url: https://github.com/plumed/plumed2
-
diff --git a/conda/run-conda-build.sh b/conda/run-conda-build.sh
index 05d1e199c..2b78e2456 100644
--- a/conda/run-conda-build.sh
+++ b/conda/run-conda-build.sh
@@ -23,8 +23,10 @@ conda update -q conda
 conda info -a
 conda install conda-build conda-verify anaconda-client
 
-conda-build recipe
-conda-build py-plumed
+export CPU_COUNT=4
+
+conda-build -c conda-forge plumed
+conda-build -c conda-forge py-plumed
 
 ls -l $CONDA_HOME/conda-bld/
 ls -l $CONDA_HOME/conda-bld/$TRAVIS_OS_NAME-64
-- 
GitLab