Skip to content

Commit

Permalink
Merge pull request #248 from phonopy/release
Browse files Browse the repository at this point in the history
Set version 3.3.0
  • Loading branch information
atztogo authored Jul 8, 2024
2 parents d52aae6 + c40299e commit 3f90329
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 146 deletions.
21 changes: 6 additions & 15 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,21 @@ on:
jobs:
build-linux:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
python-version: ["3.10", ]
python-version: [3.12, ]

steps:
- uses: actions/checkout@v4
# Use conda-incubator/setup-miniconda for precise control of conda infrastructure
- uses: conda-incubator/setup-miniconda@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
auto-update-conda: true
channels: conda-forge
channel-priority: strict
python-version: ${{ matrix.python-version }}
- name: Make sdist
run: |
conda activate test
conda install --yes python=${{ matrix.python-version }}
conda install --yes "libblas=*=*openblas" openblas cmake c-compiler numpy
./get_nanoversion.sh
cat __nanoversion__.txt
python setup.py sdist
git tag v`grep __version__ phono3py/version.py|awk -F'"' '{print($2)}'`
pip install build
python -m build --sdist
- name: Publish package to TestPyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/rc')
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
68 changes: 35 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
cmake_minimum_required(VERSION 3.20)

option(PHPHCALC "Option to build phph calculation module" OFF)
option(PHONONCALC "Option to build phonon calculation module" OFF)
option(GRIDSYS "Option to build gridsys module" OFF)
option(WITH_Fortran "enable fortran interface" OFF)
option(BUILD_PHPHCALC_LIB "Option to build phph calculation module" OFF)
option(BUILD_PHONONCALC_LIB "Option to build phonon calculation module" OFF)
option(BUILD_GRIDSYS_LIB "Option to build gridsys module" OFF)
option(PHONO3PY_WITH_Fortran "enable fortran interface" OFF)
option(PHONO3PY_USE_OMP "Option to search OpenMP library" ON)
option(PHPHCALC_USE_MTBLAS "Use multithread BLAS is it exists" OFF)
option(WITH_TESTS "build unit tests" OFF)
option(PHONO3PY_USE_MTBLAS "Use multithread BLAS if it exists" ON)
option(PHONO3PY_WITH_TESTS "build unit tests" OFF)
option(BUILD_SHARED_LIBS "Option to build shared library" OFF)

if(WITH_Fortran)
if(PHONO3PY_WITH_Fortran)
enable_language(Fortran)
set(GRIDSYS ON)
set(BUILD_GRIDSYS_LIB ON)
endif()

if(WITH_TESTS)
if(PHONO3PY_WITH_TESTS)
set(BUILD_SHARED_LIBS ON)
set(GRIDSYS ON)
set(BUILD_GRIDSYS_LIB ON)
endif()

if((NOT PHPHCALC)
AND (NOT PHONONCALC)
AND (NOT GRIDSYS))
if((NOT BUILD_PHPHCALC_LIB)
AND (NOT BUILD_PHONONCALC_LIB)
AND (NOT BUILD_GRIDSYS_LIB))
set(BUILD_NANOBIND_MODULE ON)
message(STATUS "Build nanobind module of ${SKBUILD_PROJECT_NAME}")
else()
Expand Down Expand Up @@ -86,8 +86,8 @@ else()
set(OpenMP_FOUND OFF) # cmake-lint: disable=C0103
endif()

if(PHPHCALC
OR PHONONCALC
if(BUILD_PHPHCALC_LIB
OR BUILD_PHONONCALC_LIB
OR BUILD_NANOBIND_MODULE)
find_package(BLAS REQUIRED) # set BLAS_LIBRARIES

Expand All @@ -104,28 +104,30 @@ if(PHPHCALC
endif()

if(BLAS_LIBRARIES MATCHES "libmkl")
message(STATUS "MKL detected: Set C-macros MKL_LAPACKE MULTITHREADED_BLAS")
message(STATUS "Use multithreaded BLAS for phonon calculation.")
message(STATUS "MKL detected: Set C-macro MKL_LAPACKE.")

if(PHPHCALC_USE_MTBLAS)
message(STATUS "Use multithreaded BLAS for ph-ph calculation.")
if(PHONO3PY_USE_MTBLAS)
message(
STATUS "Set C-macro MULTITHREADED_BLAS to avoid nested OpenMP calls."
)
endif()
endif()

if(BLAS_LIBRARIES MATCHES "libopenblas")
message(STATUS "OpenBLAS detected: Set C-macro MULTITHREADED_BLAS")
message(STATUS "Use multithreaded BLAS for phonon calculation.")
message(STATUS "OpenBLAS detected.")

if(PHPHCALC_USE_MTBLAS)
message(STATUS "Use multithreaded BLAS for ph-ph calculation.")
if(PHONO3PY_USE_MTBLAS)
message(
STATUS "Set C-macro MULTITHREADED_BLAS to avoid nested OpenMP calls."
)
endif()
endif()
endif()

# ###################################################################################
# Build phphcalc module #
# ###################################################################################
if(PHPHCALC OR BUILD_NANOBIND_MODULE)
if(BUILD_PHPHCALC_LIB OR BUILD_NANOBIND_MODULE)
# Source code
set(SOURCES_PHPHCALC
${PROJECT_SOURCE_DIR}/c/bzgrid.c
Expand Down Expand Up @@ -163,7 +165,7 @@ if(PHPHCALC OR BUILD_NANOBIND_MODULE)
target_include_directories(phphcalc_lib PRIVATE ${MY_INCLUDES})

if(BLAS_LIBRARIES MATCHES "libmkl")
if(PHPHCALC_USE_MTBLAS)
if(PHONO3PY_USE_MTBLAS)
target_compile_definitions(
phphcalc_lib PRIVATE MKL_LAPACKE MULTITHREADED_BLAS
THM_EPSILON=1e-10)
Expand All @@ -174,7 +176,7 @@ if(PHPHCALC OR BUILD_NANOBIND_MODULE)
endif()

if(BLAS_LIBRARIES MATCHES "libopenblas")
if(PHPHCALC_USE_MTBLAS)
if(PHONO3PY_USE_MTBLAS)
target_compile_definitions(phphcalc_lib PRIVATE MULTITHREADED_BLAS
THM_EPSILON=1e-10)
else()
Expand All @@ -195,7 +197,7 @@ if(PHPHCALC OR BUILD_NANOBIND_MODULE)
target_include_directories(phphcalc_lib PRIVATE ${MY_INCLUDES})

if(BLAS_LIBRARIES MATCHES "libmkl")
if(PHPHCALC_USE_MTBLAS)
if(PHONO3PY_USE_MTBLAS)
target_compile_definitions(
phphcalc_lib PRIVATE MKL_LAPACKE MULTITHREADED_BLAS
THM_EPSILON=1e-10)
Expand All @@ -206,7 +208,7 @@ if(PHPHCALC OR BUILD_NANOBIND_MODULE)
endif()

if(BLAS_LIBRARIES MATCHES "libopenblas")
if(PHPHCALC_USE_MTBLAS)
if(PHONO3PY_USE_MTBLAS)
target_compile_definitions(phphcalc_lib PRIVATE MULTITHREADED_BLAS
THM_EPSILON=1e-10)
else()
Expand Down Expand Up @@ -236,7 +238,7 @@ endif()
# ###################################################################################
# phononcalc #
# ###################################################################################
if(PHONONCALC OR BUILD_NANOBIND_MODULE)
if(BUILD_PHONONCALC_LIB OR BUILD_NANOBIND_MODULE)
# Source code
set(SOURCES_PHONONCALC
${PROJECT_SOURCE_DIR}/c/dynmat.c ${PROJECT_SOURCE_DIR}/c/lapack_wrapper.c
Expand Down Expand Up @@ -311,7 +313,7 @@ endif()
# ###################################################################################
# grid #
# ###################################################################################
if(GRIDSYS)
if(BUILD_GRIDSYS_LIB)
# Source code
set(SOURCES_GRIDSYS
${PROJECT_SOURCE_DIR}/c/bzgrid.c
Expand Down Expand Up @@ -360,12 +362,12 @@ if(GRIDSYS)
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()

if(WITH_Fortran)
if(PHONO3PY_WITH_Fortran)
add_subdirectory(fortran)
endif()

if(WITH_TESTS)
if(WITH_Fortran)
if(PHONO3PY_WITH_TESTS)
if(PHONO3PY_WITH_Fortran)
set(LIB_MOD_DIR ${CMAKE_CURRENT_BINARY_DIR}/fortran)
endif()

Expand Down
6 changes: 6 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

# Change Log

## Jul-8-2024: Version 3.3.0

- Build system of phono3py was renewed. Now nanobind, cmake, and
scikit-build-core are used for the building, and the receipt is written in
`CMakeLists.txt` and `pyproject.toml`.

## Jun-29-2024: Version 3.2.0

- `--rd` and `--rd-fc2` options for generating random directional displacements.
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
# built documents.
#
# The short X.Y version.
version = "3.2"
version = "3.3"
# The full version, including alpha/beta/rc tags.
release = "3.2.0"
release = "3.3.0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
94 changes: 15 additions & 79 deletions doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,23 @@ All dependent packages should be installed.
(install_from_source_code)=
## Installation from source code

When installing phono3py using `setup.py` from the source code, a few libraries
are required before running `setup.py` script.
When installing phono3py from the source code, a few libraries are required
before running `pip install`.

Note that at version 3.3.0, the build system of phono3py was modernized.
Nanobind, cmake, and scikit-build-core are used for the building. The receipt is
written in `CMakeLists.txt` and `pyproject.toml`. The old `setup.py` was
removed.

If phono3py is compiled with a special compiler or special options, manual
modification of `CMakeLists.txt` may be needed.

- {ref}`Linear algebra library <install_lapacke>`: BLAS, LAPACK, and LAPACKE
- {ref}`OpenMP library <install_openmp>`: For the multithreding support.

These packages may be installed by the package manager of OS (e.g. `apt`) or
conda environment. Automatic search of required libraries and flags that are
already on the system is performed by cmake. If cmake is installed on the
system, this automatic search is invoked as default. For the installation with
custom configurations without using cmake, the environment variable
`PHONO3PY_USE_CMAKE=false` has to be set.
already on the system is performed by cmake.

(install_with_cmake)=
### Build with automatic search of library configurations by cmake
Expand All @@ -56,57 +61,6 @@ See an example at {ref}`install_an_example`. In the standard output, flags and
libraries found by cmake are shown. Please carefully check if those
configurations are expected ones or not.

(install_custom)=
### Build with custom library configurations by `site.cfg` file

Custom installation is achieved by creating `site.cfg` file on the same
directory as `setup.py`. Users will write configurations of compiler flags and
linked libraries in `site.cfg`. If `setup.py` finds `site.cfg`, the
configurations are used as the default configurations. If cmake is found in the
system, cmake tries to find required libraries and found configurations are
appended. To deactivate cmake's library search, the environment variable
`PHONO3PY_USE_CMAKE=false` has to be set before running the phono3py build:
```
% export PHONO3PY_USE_CMAKE=false
```
In previous versions, `site.cfg` was processed by numpy,
but from version 2.4.0, it is processed by script in `setup.py`.
`extra_link_args`, `extra_compile_args`, `extra_objects`, and `include_dirs` can
be specified. How they used is found at [setuptools web
site](https://setuptools.pypa.io/en/latest/userguide/ext_modules.html#extension-api-reference).

In most cases, users want to enable multithreading support with OpenMP. Its
minimum setting with gcc as the compiler is:

```
extra_compile_args = -fopenmp
```

Additional configuration can be necessary. It is recommended first starting only
with `extra_compile_args = -fopenmp` and run `setup.py`, then check if phono3py
works properly or not without error or warning. When phono3py doesn't work with
the above setting, add another configuration one by one to test compilation.
Some examples are given below.

For MKL (for gcc and clang), `site.cfg`

```
extra_compile_args = -fopenmp
```

For openblas and clang

```
extra_compile_args = -fopenmp
```

For openblas and gcc

```
extra_compile_args = -fopenmp
extra_link_args = -lgomp
```

(install_an_example)=

## Installation instruction of latest development version of phono3py
Expand All @@ -117,7 +71,8 @@ wrong python libraries can be imported.
1. Download miniforge

Miniforge is downloaded at https://github.com/conda-forge/miniforge. The
detailed installation instruction is found in the same page. If usual conda or miniconda is used, the following `~/.condarc` setting is recommended:
detailed installation instruction is found in the same page. If usual conda
or miniconda is used, the following `~/.condarc` setting is recommended:

```
channel_priority: strict
Expand Down Expand Up @@ -148,7 +103,7 @@ wrong python libraries can be imported.
For x86-64 system:

```bash
% conda install numpy scipy h5py pyyaml matplotlib-base c-compiler "libblas=*=*mkl" spglib mkl-include cmake
% conda install numpy scipy h5py pyyaml matplotlib-base c-compiler cxx-compiler "libblas=*=*mkl" spglib mkl-include cmake
```

A libblas library can be chosen among `[openblas, mkl, blis, netlib]`. If
Expand All @@ -161,7 +116,7 @@ wrong python libraries can be imported.
For macOS ARM64 system, currently only openblas can be chosen:

```bash
% conda install numpy scipy h5py pyyaml matplotlib-base c-compiler spglib cmake openblas
% conda install numpy scipy h5py pyyaml matplotlib-base c-compiler cxx-compiler spglib cmake openblas
```

Note that using hdf5 files on NFS mounted file system, you may have to disable
Expand All @@ -179,10 +134,8 @@ wrong python libraries can be imported.
% git clone https://github.com/phonopy/phonopy.git
% git clone https://github.com/phonopy/phono3py.git
% cd phonopy
% git checkout develop
% pip install -e . -vvv
% cd ../phono3py
% git checkout develop
% pip install -e . -vvv
```

Expand Down Expand Up @@ -215,23 +168,6 @@ Ubuntu package manager (`liblapacke` and `liblapacke-dev`):
% sudo apt-get install liblapack-dev liblapacke-dev
```

### Compiling Netlib LAPACKE

The compilation procedure is found at the LAPACKE web site. After creating the
LAPACKE library, `liblapacke.a` (or the dynamic link library), `setup.py` must
be properly modified to link it. As an example, the procedure of compiling
LAPACKE is shown below.

```bash
% tar xvfz lapack-3.6.0.tgz
% cd lapack-3.6.0
% cp make.inc.example make.inc
% make lapackelib
```

BLAS, LAPACK, and LAPACKE, these all may have to be compiled with `-fPIC` option
to use it with python.

(install_openmp)=
## Multithreading and its controlling by C macro

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

import argparse
import os
import sys
Expand Down Expand Up @@ -139,5 +137,6 @@ def main(args: argparse.Namespace):
plot(args)


if __name__ == "__main__":
def run():
"""Run phono3py-coleigplot script."""
main(get_options())
Loading

0 comments on commit 3f90329

Please sign in to comment.