Skip to content

Commit

Permalink
Merge pull request #212 from timcallow/libxc_reqs_update
Browse files Browse the repository at this point in the history
Simplify libxc installation
  • Loading branch information
timcallow authored Nov 6, 2023
2 parents 0f72539 + 50479ef commit cbbf8f2
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 307 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.12'

- name: Upgrade pip
run: python3 -m pip install --upgrade pip
Expand All @@ -44,7 +44,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.12'

- name: Upgrade pip
run: python3 -m pip install --upgrade pip
Expand Down
44 changes: 1 addition & 43 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.12'

- name: Upgrade pip
run: python -m pip install --upgrade pip
Expand All @@ -35,54 +35,12 @@ jobs:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}_v2

- name: Get latest commit SHA of libxc master branch
id: get-sha
run: |
echo "::set-output name=sha::$(git ls-remote https://github.com/ElectronicStructureLibrary/libxc.git refs/heads/master | cut -f 1)"
- name: Cache external library
id: cache-libxc
uses: actions/cache@v3
with:
path: ~/libxc/sharedlib/
key: libxc-${{ runner.os }}-${{ steps.get-sha.outputs.sha }}

- name: Build and install libxc
if: steps.cache-libxc.outputs.cache-hit != 'true'
run: |
install_path=~/libxc/sharedlib/
cd ~
git clone https://github.com/ElectronicStructureLibrary/libxc.git
cd ~/libxc
mkdir -p $install_path
cmake -H. -Bobjdir -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$install_path -DENABLE_PYTHON=ON
cd objdir && make
make test
make install
- name: Set LD_LIBRARY_PATH
run: echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/libxc/sharedlib/" >> $GITHUB_ENV

- name: Cache Python bindings
id: cache-bindings
uses: actions/cache@v3
with:
path: ~/libxc
key: bindings-${{ runner.os }}-${{ steps.get-libxc-sha.outputs.sha }}

- name: Install dependencies
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
cd ${{ github.workspace }}
pipenv install --dev
- name: Install Python bindings
if: steps.cache-bindings.outputs.cache-hit != 'true'
run: |
pipenv run pip install ~/libxc/
- name: Install atoMEC
run: |
cd ${{ github.workspace }}
Expand Down
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ scipy = ">=1.6.3"
mendeleev = ">=0.7.0"
tabulate = ">=0.8.9"
joblib = ">=1.0.1"
pylibxc = {file = "https://gitlab.com/libxc/libxc/-/archive/6.2.2/libxc-6.2.2.tar.gz"}

[requires]
python_version = "3"
python_version = "3.12"

[dev-packages]
pytest = ">=7.1.3"
Expand Down
362 changes: 164 additions & 198 deletions Pipfile.lock

Large diffs are not rendered by default.

40 changes: 17 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# atoMEC: Average-Atom Code for Matter under Extreme Conditions

[![docs](https://github.com/atomec-project/atoMEC/actions/workflows/gh-pages.yml/badge.svg)](https://github.com/atomec-project/atoMEC/actions/workflows/gh-pages.yml)
[![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3100/)
[![Python 3.12](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/release/python-3100/)
[![image](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![codecov](https://codecov.io/gh/atomec-project/atoMEC/branch/develop/graph/badge.svg?token=V66CJJ3KPI)](https://codecov.io/gh/atomec-project/atoMEC)
[![CodeFactor](https://www.codefactor.io/repository/github/atomec-project/atomec/badge)](https://www.codefactor.io/repository/github/atomec-project/atomec)
Expand All @@ -27,7 +27,17 @@ This repository is structured as follows:

## Installation

Please see below sub-sections on supported operating systems and Python versions before continuing.
The latest stable release of `atoMEC` can be installed via `pip`:

`pip install atoMEC`

Note that atoMEC does not (yet) support Windows installation (please see the section below on supported operating systems).

The installation takes some time due to the dependence on `pylibxc`, which currently has no official wheels distribution on PyPI.

Read on for instructions on how to install `atoMEC` from source, using the recommended `pipenv` installation route.

### Installation via `pipenv`

First, clone the atoMEC repository and ``cd`` into the main directory.

Expand All @@ -38,26 +48,10 @@ First, clone the atoMEC repository and ``cd`` into the main directory.
1. First, install `pipenv` if it is not already installed, for example via `pip install pipenv` (or see [pipenv](https://pypi.org/project/pipenv/) for installation instructions)
2. Next, install `atoMEC`'s dependencies with `pipenv install` (use `--dev` option to install the test dependencies in the same environment)
3. Use `pipenv shell` to activate the virtual environment
4. Install Python bindings for `libxc`. See below section for installation instructions.
5. Install atoMEC with `pip install atoMEC` (for developers: `pip install -e .`)
6. Now run scripts from inside the `atoMEC` virtual environment, e.g. `python examples/simple.py`

* Run the tests (see Testing section below) and report any failures (for example by raising an issue)

### Libxc installation

atoMEC relies on the [libxc](https://tddft.org/programs/libxc/) library for exchange-correlation functionals.

Unfortunately, there is no official pip installation available for libxc (yet). There are two options for installation.

First, ensure the virtual environment is activated (e.g. with `pipenv shell`). Then:

1. Easy but **not** recommended `pip install pylibxc2`: This is an unofficial pip package for the `libxc` Python bindings. However, besides lacking official support, it does not seem to be under active maintenance. It also works only for Python <= 3.9. Nevertheless, it's an easy way to get started with atoMEC.
2. Recommended route: Follow [official installation instructions](https://tddft.org/programs/libxc/installation/) for `libxc`'s Python bindings. Note that this requires the `cmake` build pathway with Python bindings and shared library options enabled:

`cmake -H. -Bobjdir -DBUILD_SHARED_LIBS=ON -DENABLE_PYTHON=ON`
4. Install atoMEC with `pip install atoMEC` (for developers: `pip install -e .`)
5. Now run scripts from inside the `atoMEC` virtual environment, e.g. `python examples/simple.py`

Note that we provide a script `install_libxc.sh` which performs the full `libxc` installation workflow. This script has been tested on Ubuntu 22.04 and Python >= 3.8.
* Run the tests (see Testing section below) and report any failures (for example by raising an issue).

### Supported operating systems

Expand All @@ -69,8 +63,8 @@ Note that we provide a script `install_libxc.sh` which performs the full `libxc`

* atoMEC has been tested and is expected to work for all Python versions >= 3.8 and <= 3.12
* atoMEC does not work for Python <= 3.7
* Until 09.10.2023 (release 1.4.0), all development and CI testing was done with Python 3.8. As of this date, development and CI testing is done with Python 3.10.
* Python 3.10 is therefore the recommended version for atoMEC >= 1.4.0, since this is used for the current testing and development environment
* Until 09.10.2023 (release 1.4.0), all development and CI testing was done with Python 3.8. As of this date, development and CI testing is done with Python 3.12.
* Python 3.12 is therefore the recommended version for atoMEC >= 1.4.0, since this is used for the current testing and development environment


## Running
Expand Down
35 changes: 0 additions & 35 deletions install_libxc.sh

This file was deleted.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ scipy>=1.6.3
mendeleev>=0.7.0
tabulate>=0.8.9
joblib>=1.0.1
https://gitlab.com/libxc/libxc/-/archive/6.2.2/libxc-6.2.2.tar.gz
13 changes: 8 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,26 @@
license = f.read()

extras = {
'dev': ['bump2version'],
'docs': open('docs/requirements.txt').read().splitlines(),
'tests': open('tests/requirements.txt').read().splitlines(),
"dev": ["bump2version"],
"docs": open("docs/requirements.txt").read().splitlines(),
"tests": open("tests/requirements.txt").read().splitlines(),
}

setup(
name="atoMEC",
version="1.3.0",
description="KS-DFT average-atom code",
long_description=readme,
long_description_content_type='text/markdown',
long_description_content_type="text/markdown",
author="Tim Callow et al.",
author_email="t.callow@hzdr.de",
url="https://github.com/atomec-project/atoMEC",
license=license,
packages=find_packages(exclude=("tests", "docs", "examples")),
install_requires=open('requirements.txt').read().splitlines(),
install_requires=open("requirements.txt").read().splitlines()[:-1],
dependency_links=[
"https://gitlab.com/libxc/libxc/-/archive/6.2.2/libxc-6.2.2.tar.gz",
],
extras_require=extras,
python_requires=">=3.6",
)

0 comments on commit cbbf8f2

Please sign in to comment.