git: e1e1584924ed - main - science/{,py-}spglib: update 2.3.0 → 2.3.1

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Sun, 11 Feb 2024 19:02:59 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e1e1584924edc207c91ecb16ee6dad8468ff7b54

commit e1e1584924edc207c91ecb16ee6dad8468ff7b54
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2024-02-11 18:44:14 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2024-02-11 19:02:55 +0000

    science/{,py-}spglib: update 2.3.0 → 2.3.1
    
    Reported by:    portscout
---
 science/py-spglib/Makefile                     | 23 +++++++++++----
 science/py-spglib/distinfo                     |  6 ++--
 science/py-spglib/files/patch-CMakeLists.txt   | 37 +++++++++++++-----------
 science/py-spglib/files/patch-spglib_spglib.py | 31 ++++++++++++++++++++
 science/py-spglib/files/quick-test.py          | 39 ++++++++++++++++++++++++++
 science/spglib/Makefile                        |  2 +-
 science/spglib/distinfo                        |  6 ++--
 science/spglib/pkg-plist                       |  5 ++--
 8 files changed, 118 insertions(+), 31 deletions(-)

diff --git a/science/py-spglib/Makefile b/science/py-spglib/Makefile
index e39cd68c2410..b9208a124902 100644
--- a/science/py-spglib/Makefile
+++ b/science/py-spglib/Makefile
@@ -1,16 +1,18 @@
 PORTNAME=	spglib
 DISTVERSIONPREFIX=	v
-DISTVERSION=	2.3.0
+DISTVERSION=	2.3.1
 CATEGORIES=	science python
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
 
 MAINTAINER=	yuri@FreeBSD.org
 COMMENT=	Library for finding and handling crystal symmetries (python binding)
-WWW=		https://atztogo.github.io/spglib/
+WWW=		https://spglib.readthedocs.io/en/stable/
 
 LICENSE=	BSD3CLAUSE
 
-BUILD_DEPENDS=	${PYNUMPY}
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}setuptools_scm>0:devel/py-setuptools_scm@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}scikit-build-core>0:devel/py-scikit-build-core@${PY_FLAVOR} \
+		${PYNUMPY}
 LIB_DEPENDS=	libsymspg.so:science/spglib
 RUN_DEPENDS=	${PYNUMPY}
 
@@ -22,8 +24,19 @@ CMAKE_ARGS=	-DPython3_EXECUTABLE=${PYTHON_CMD}
 
 WRKSRC_SUBDIR=	python
 
+MAKE_ENV=	SETUPTOOLS_SCM_PRETEND_VERSION=${DISTVERSION}
+
+TEST_WRKSRC=	${WRKSRC}
+TEST_ENV=	${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
+
 post-patch:
-	#@cd ${WRKSRC} && ${RLN} ../test .
-	@cd ${WRKSRC} && ${CP} -r ../test .
+	##@cd ${WRKSRC} && ${RLN} ../test .
+	#@cd ${WRKSRC} && ${CP} -r ../test .
+	# workaround for https://github.com/spglib/spglib/issues/429
+	@${REINPLACE_CMD} -i '' -e 's|^from ._version import|#&|' ${WRKSRC}/spglib/__init__.py
+	# patch in the correct symspg lib
+	@${REINPLACE_CMD} -i '' \
+		-e 's|, bundled_lib)|, "${LOCALBASE}/lib/libsymspg.so")|' \
+		${WRKSRC}/spglib/spglib.py
 
 .include <bsd.port.mk>
diff --git a/science/py-spglib/distinfo b/science/py-spglib/distinfo
index a7dbde1d3c56..29c3fb3df15a 100644
--- a/science/py-spglib/distinfo
+++ b/science/py-spglib/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1706473147
-SHA256 (spglib-spglib-v2.3.0_GH0.tar.gz) = 2fc3b42867d12a41b952ffd5896426797a39564e129c04c9c626d880371614ad
-SIZE (spglib-spglib-v2.3.0_GH0.tar.gz) = 2910603
+TIMESTAMP = 1707671341
+SHA256 (spglib-spglib-v2.3.1_GH0.tar.gz) = 6eb977053b35cd80eb2b5c3fa506a538ff2dad7092a43a612f4f0d4dc2069253
+SIZE (spglib-spglib-v2.3.1_GH0.tar.gz) = 2910916
diff --git a/science/py-spglib/files/patch-CMakeLists.txt b/science/py-spglib/files/patch-CMakeLists.txt
index ffabaf7a1e8c..7c42c23d1d4b 100644
--- a/science/py-spglib/files/patch-CMakeLists.txt
+++ b/science/py-spglib/files/patch-CMakeLists.txt
@@ -1,4 +1,4 @@
---- CMakeLists.txt.orig	2023-09-10 07:23:28 UTC
+--- CMakeLists.txt.orig	2024-02-11 01:27:19 UTC
 +++ CMakeLists.txt
 @@ -1,8 +1,13 @@
 +cmake_minimum_required(VERSION 3.15)
@@ -15,25 +15,28 @@
  if (NOT Python_INSTALL_DIR)
  	if (SKBUILD)
  		# If built with scikit-build-core, let it handle the installation
-@@ -12,7 +17,7 @@ if (NOT Python_INSTALL_DIR)
+@@ -12,16 +17,16 @@ endif ()
  		set(Python_INSTALL_DIR ${Python3_SITEARCH}/spglib)
  	endif ()
  endif ()
 -if (SPGLIB_INSTALL)
 +if (TRUE)
- 	if (WIN32)
- 		# Windows needs RUNTIME as well to install the .dll file to
- 		install(TARGETS Spglib_symspg
-@@ -22,9 +27,9 @@ if (SPGLIB_INSTALL)
- 	else ()
- 		# TODO: Cmake forces to install PUBLIC_HEADER when defined
- 		# https://gitlab.kitware.com/cmake/cmake/-/issues/24326
--		install(TARGETS Spglib_symspg
--				LIBRARY DESTINATION ${Python_INSTALL_DIR} COMPONENT Spglib_Runtime
--				PUBLIC_HEADER DESTINATION ${Python_INSTALL_DIR} COMPONENT Spglib_Runtime)
-+		#install(TARGETS Spglib_symspg
-+		#		LIBRARY DESTINATION ${Python_INSTALL_DIR} COMPONENT Spglib_Runtime
-+		#		PUBLIC_HEADER DESTINATION ${Python_INSTALL_DIR} COMPONENT Spglib_Runtime)
- 	endif ()
+ 	# TODO: Cmake forces to install PUBLIC_HEADER when defined
+ 	# https://gitlab.kitware.com/cmake/cmake/-/issues/24326
+-	install(TARGETS Spglib_symspg
+-			LIBRARY DESTINATION ${Python_INSTALL_DIR} COMPONENT Spglib_Runtime
+-			NAMELINK_COMPONENT Spglib_Development
+-			ARCHIVE DESTINATION ${Python_INSTALL_DIR} COMPONENT Spglib_Development
+-			PUBLIC_HEADER DESTINATION ${Python_INSTALL_DIR} COMPONENT Spglib_Development
+-			RUNTIME DESTINATION ${Python_INSTALL_DIR} COMPONENT Spglib_Runtime
+-	)
++	#install(TARGETS Spglib_symspg
++	#		LIBRARY DESTINATION ${Python_INSTALL_DIR} COMPONENT Spglib_Runtime
++	#		NAMELINK_COMPONENT Spglib_Development
++	#		ARCHIVE DESTINATION ${Python_INSTALL_DIR} COMPONENT Spglib_Development
++	#		PUBLIC_HEADER DESTINATION ${Python_INSTALL_DIR} COMPONENT Spglib_Development
++	#		RUNTIME DESTINATION ${Python_INSTALL_DIR} COMPONENT Spglib_Runtime
++	#)
  	install(TARGETS Spglib_python
- 			LIBRARY DESTINATION ${Python_INSTALL_DIR} COMPONENT Spglib_Runtime)
+ 			LIBRARY DESTINATION ${Python_INSTALL_DIR} COMPONENT Spglib_Runtime
+ 	)
diff --git a/science/py-spglib/files/patch-spglib_spglib.py b/science/py-spglib/files/patch-spglib_spglib.py
new file mode 100644
index 000000000000..bbe9f70d0a64
--- /dev/null
+++ b/science/py-spglib/files/patch-spglib_spglib.py
@@ -0,0 +1,31 @@
+--- spglib/spglib.py.orig	2024-02-11 17:45:53 UTC
++++ spglib/spglib.py
+@@ -46,17 +46,17 @@ except ImportError:
+     import re
+     from ctypes import cdll
+ 
+-    bundled_lib = next(
+-        filter(
+-            lambda fl: re.match(".*symspg\\..*", fl),
+-            sorted(os.listdir(os.path.dirname(__file__))),
+-        ),
+-        None,
+-    )
+-    if not bundled_lib:
+-        raise FileNotFoundError(
+-            "Spglib C library is not installed and no bundled version was detected"
+-        )
++    #bundled_lib = next(
++    #    filter(
++    #        lambda fl: re.match(".*symspg\\..*", fl),
++    #        sorted(os.listdir(os.path.dirname(__file__))),
++    #    ),
++    #    None,
++    #)
++    #if not bundled_lib:
++    #    raise FileNotFoundError(
++    #        "Spglib C library is not installed and no bundled version was detected"
++    #    )
+     cdll.LoadLibrary(os.path.join(os.path.dirname(__file__), bundled_lib))
+     from spglib import _spglib as spg  # type: ignore[attr-defined]
+ 
diff --git a/science/py-spglib/files/quick-test.py b/science/py-spglib/files/quick-test.py
new file mode 100644
index 000000000000..c73b1e342b42
--- /dev/null
+++ b/science/py-spglib/files/quick-test.py
@@ -0,0 +1,39 @@
+import numpy as np
+import spglib
+
+lattice = np.array([[0.0, 0.5, 0.5],
+                    [0.5, 0.0, 0.5],
+                    [0.5, 0.5, 0.0]]) * 5.4
+positions = [[0.875, 0.875, 0.875],
+            [0.125, 0.125, 0.125]]
+numbers= [1,] * 2
+cell = (lattice, positions, numbers)
+print(spglib.get_spacegroup(cell, symprec=1e-5))
+mesh = [8, 8, 8]
+
+#
+# Gamma centre mesh
+#
+mapping, grid = spglib.get_ir_reciprocal_mesh(mesh, cell, is_shift=[0, 0, 0])
+
+# All k-points and mapping to ir-grid points
+for i, (ir_gp_id, gp) in enumerate(zip(mapping, grid)):
+    print("%3d ->%3d %s" % (i, ir_gp_id, gp.astype(float) / mesh))
+
+# Irreducible k-points
+print("Number of ir-kpoints: %d" % len(np.unique(mapping)))
+print(grid[np.unique(mapping)] / np.array(mesh, dtype=float))
+
+#
+# With shift
+#
+mapping, grid = spglib.get_ir_reciprocal_mesh(mesh, cell, is_shift=[1, 1, 1])
+
+# All k-points and mapping to ir-grid points
+for i, (ir_gp_id, gp) in enumerate(zip(mapping, grid)):
+    print("%3d ->%3d %s" % (i, ir_gp_id, (gp + [0.5, 0.5, 0.5]) / mesh))
+
+# Irreducible k-points
+print("Number of ir-kpoints: %d" % len(np.unique(mapping)))
+print((grid[np.unique(mapping)] + [0.5, 0.5, 0.5]) / mesh)
+
diff --git a/science/spglib/Makefile b/science/spglib/Makefile
index 4dee78e7c396..637aceb28671 100644
--- a/science/spglib/Makefile
+++ b/science/spglib/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	spglib
 DISTVERSIONPREFIX=	v
-DISTVERSION=	2.3.0
+DISTVERSION=	2.3.1
 CATEGORIES=	science
 
 MAINTAINER=	yuri@FreeBSD.org
diff --git a/science/spglib/distinfo b/science/spglib/distinfo
index 7d1221a1c958..922298e099b7 100644
--- a/science/spglib/distinfo
+++ b/science/spglib/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1706472993
-SHA256 (spglib-spglib-v2.3.0_GH0.tar.gz) = 2fc3b42867d12a41b952ffd5896426797a39564e129c04c9c626d880371614ad
-SIZE (spglib-spglib-v2.3.0_GH0.tar.gz) = 2910603
+TIMESTAMP = 1707671227
+SHA256 (spglib-spglib-v2.3.1_GH0.tar.gz) = 6eb977053b35cd80eb2b5c3fa506a538ff2dad7092a43a612f4f0d4dc2069253
+SIZE (spglib-spglib-v2.3.1_GH0.tar.gz) = 2910916
diff --git a/science/spglib/pkg-plist b/science/spglib/pkg-plist
index e81892aca86c..6749e800c471 100644
--- a/science/spglib/pkg-plist
+++ b/science/spglib/pkg-plist
@@ -8,11 +8,12 @@ lib/cmake/Spglib/SpglibConfigVersion.cmake
 %%FORTRAN%%lib/cmake/Spglib/SpglibTargets_fortran.cmake
 lib/cmake/Spglib/SpglibTargets_shared-%%CMAKE_BUILD_TYPE%%.cmake
 lib/cmake/Spglib/SpglibTargets_shared.cmake
+%%FORTRAN%%lib/cmake/Spglib/try_compile.f90
 %%FORTRAN%%lib/libspglib_f08.so
 %%FORTRAN%%lib/libspglib_f08.so.2
-%%FORTRAN%%lib/libspglib_f08.so.2.3.0
+%%FORTRAN%%lib/libspglib_f08.so.2.3.1
 lib/libsymspg.so
 lib/libsymspg.so.2
-lib/libsymspg.so.2.3.0
+lib/libsymspg.so.2.3.1
 libdata/pkgconfig/spglib.pc
 %%FORTRAN%%libdata/pkgconfig/spglib_f08.pc