Skip to content

Commit

Permalink
Merge pull request #74 from SMTG-Bham/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
kavanase authored May 23, 2024
2 parents 7de6f56 + 2b90ba3 commit 235bc8d
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pip_install_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
sleep 360 # wait 10 minutes for PyPI to update with the new release
python -m pip install --upgrade pip
pip install doped[tests] # install only from PyPI
pip install git+https://github.com/spglib/spglib --config-settings=cmake.define.SPGLIB_SHARED_LIBS=OFF # avoid spglib warnings
- name: Test
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -e .[tests]
pip install git+https://github.com/spglib/spglib --config-settings=cmake.define.SPGLIB_SHARED_LIBS=OFF # avoid spglib warnings
- name: Test
run: |
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Change Log
==========

v.2.4.3
----------
- Remove ``spglib<=2.0.2`` dependency (set to avoid unnecessary warnings), and update installation instructions accordingly.

v.2.4.2
----------
- Allow cases where the calculated host material is unstable wrt competing phases (above the hull), by downshifting to the hull and warning the user about this.
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ displacements from DFT supercell calculations. See the [JOSS paper](https://doi.
## Installation
```bash
pip install doped # install doped and dependencies
conda install -c conda-forge spglib # bundle C libraries with spglib
```

Note that either `conda install -c conda-forge spglib` or
`pip install git+https://github.com/spglib/spglib --config-settings=cmake.define.SPGLIB_SHARED_LIBS=OFF`
should be used after `pip install doped`, which ensures that the correct C libraries are bundled with
`spglib`, to prevent unnecessary warnings.

Alternatively if desired, `doped` can also be installed from `conda` with:

```bash
Expand Down
13 changes: 13 additions & 0 deletions docs/Installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ Installation
.. code-block:: bash
pip install doped # install doped and dependencies
conda install -c conda-forge spglib # bundle C libraries with spglib
Note that either ``conda install -c conda-forge spglib`` or
``pip install git+https://github.com/spglib/spglib --config-settings=cmake.define.SPGLIB_SHARED_LIBS=OFF``
should be used after ``pip install doped``, which ensures that the correct C libraries are bundled with
``spglib``, to prevent unnecessary warnings. You can check that the correct C libraries have been bundled
by running the following in Python, and confirming that the same version numbers are printed:

.. code-block:: python
import spglib
print(spglib.__version__)
print(spglib.spg_get_version_full())
Alternatively if desired, ``doped`` can also be installed from ``conda`` with:

Expand Down
20 changes: 6 additions & 14 deletions docs/Troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ that it is rebuilt with the new ``numpy`` C API:
``spglib`` Errors/Warnings
--------------------------
A previous known issue with ``spglib`` is that it could give an error or warnings similar to:
A known issue with ``spglib`` is that it can give unnecessary errors or warnings similar to:

.. code:: python
Expand All @@ -76,20 +76,12 @@ A previous known issue with ``spglib`` is that it could give an error or warning
spglib: get_bravais_exact_positions_and_lattice failed
spglib: ref_get_exact_structure_and_symmetry failed.
This can be fixed by reinstalling ``spglib`` with ``conda install -c conda-forge spglib==2.0.2``.
Sometimes installation with ``conda`` rather than ``pip`` is required, as ``conda`` will bundle the C
and Fortran libraries, while using version ``2.0.2`` for now avoids some unnecessary warnings (see this
`Issue <https://github.com/spglib/spglib/issues/338>`_ on the ``spglib`` GitHub for details).
This can be fixed by reinstalling ``spglib`` with ``conda install -c conda-forge spglib`` or
``pip install git+https://github.com/spglib/spglib --config-settings=cmake.define.SPGLIB_SHARED_LIBS=OFF``
as detailed in the `Installation <https://doped.readthedocs.io/en/latest/Installation.html>`__ instructions.
This ensures the correct C libraries are bundled with ``spglib``.

.. If this still does not remove these warnings, then setting the environment variable: ``SPGLIB_WARNING=OFF``
and re-installing ``spglib`` with:

.. .. code:: bash
.. pip uninstall spglib
pip install git+https://github.com/spglib/spglib --config-settings=cmake.define.SPGLIB_SHARED_LIBS=OFF
.. should fix it. – STILL DOESN'T FULLY FIX IT YET (see doped_spglib_warnings.ipynb)
.. see doped_spglib_warnings.ipynb
``ShakeNBreak``
-------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
author = 'Seán R. Kavanagh'

# The full version, including alpha/beta/rc tags
release = '2.4.2'
release = '2.4.3'


# -- General configuration ---------------------------------------------------
Expand Down
32 changes: 32 additions & 0 deletions doped/utils/symmetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,38 @@
)


def _set_spglib_warnings_env_var():
"""
Set the SPGLIB environment variable to suppress spglib warnings.
"""
os.environ["SPGLIB_WARNING"] = "OFF"


def _check_spglib_version():
"""
Check the versions of spglib and its C libraries, and raise a warning if
the correct installation instructions have not been followed.
"""
import spglib

python_version = spglib.__version__
c_version = spglib.spg_get_version_full()

if python_version != c_version:
warnings.warn(
f"Your spglib Python version (spglib.__version__ = {python_version}) does not match its C "
f"library version (spglib.spg_get_version_full() = {c_version}). This can lead to unnecessary "
f"spglib warning messages, but can be avoided by installing spglib with `conda install -c "
f"conda-forge spglib` or `pip install git+https://github.com/spglib/spglib "
f"--config-settings=cmake.define.SPGLIB_SHARED_LIBS=OFF` as detailed in the doped "
f"installation instructions: https://doped.readthedocs.io/en/latest/Installation.html"
)


_check_spglib_version()
_set_spglib_warnings_env_var()


def _round_floats(obj, places=5):
"""
Recursively round floats in a dictionary to ``places`` decimal places.
Expand Down
9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "doped"
version = "2.4.2"
version = "2.4.3"
description = "Python package to setup, process and analyse solid-state defect calculations with VASP"
authors = [{name = "Seán Kavanagh", email = "skavanagh@seas.harvard.edu"}]
readme = "README.md"
Expand All @@ -22,8 +22,11 @@ dependencies = [
"matplotlib>=3.5.2",
"numpy>=1.21.0",
"pymatgen>=2023.11.12", # limiting factor: POTCAR_STATS_PATH available from pymatgen.io.vasp.inputs
"spglib<=2.0.2", # dependent of pymatgen, but explicitly set to <=2.0.2 here to avoid unnecessary warnings
# see https://github.com/spglib/spglib/issues/338; remove this limit when issue resolved
"spglib>=2.4.0", # previously explicitly set to <=2.0.2 to avoid unnecessary warnings
# (https://github.com/spglib/spglib/issues/338) but causing dependency issues
# (https://github.com/SMTG-Bham/doped/issues/73), being worked on in
# https://github.com/spglib/spglib/issues/462 -- update Troubleshooting.rst and spglib warning in
# doped.utils.symmetry when finally resolved
"pymatgen-analysis-defects>=2023.8.22",
"shakenbreak>=3.3.1",
"pandas",
Expand Down

0 comments on commit 235bc8d

Please sign in to comment.