add script to install libxc

This commit is contained in:
Gaspard Jankowiak 2024-02-26 12:18:19 +01:00
parent 36cfd96016
commit 03d1eb4514

33
install_libxc.sh Normal file
View file

@ -0,0 +1,33 @@
#!/bin/bash
set -e
if [[ -z "$CONDA_PREFIX" ]]; then
echo "You do not seem to have an active conda environment active, aborting"
exit 1
fi
# Get and unzip archive
LIBXC_VERSION=6.1.0
wget "https://github.com/ElectronicStructureLibrary/libxc/archive/refs/tags/$LIBXC_VERSION.zip"
unzip "$LIBXC_VERSION.zip"
rm "$LIBXC_VERSION.zip"
cd "libxc-$LIBXC_VERSION"
# Compile
cmake -H. -Bobjdir -DENABLE_PYTHON=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX"
cd objdir && make
# Test
make test
# Install
make install
# Link the python library
PYTHON_VERSION=$(python --version | sed -e 's/.* \([0-9]\.[0-9]\{2\}\).*/\1/')
echo "Detected python v$PYTHON_VERSION"
echo "Creating symlink to pylibxc library (python bindings for libxc)"
ln -v -s "$CONDA_PREFIX/lib64/pylibxc" "$CONDA_PREFIX/lib/python$PYTHON_VERSION/site-packages"
echo 'Install successful'