From 2f1193181d4d4666a1c5292771fbbaa3f0c52008 Mon Sep 17 00:00:00 2001 From: David Elsing Date: Tue, 3 Jun 2025 22:56:54 +0200 Subject: [PATCH] gnu: Add python-pyscf. * gnu/packages/chemistry.scm (python-pyscf): New variable. Change-Id: I4e265c97644a6f8765c5d509de126de0312a3f98 Signed-off-by: Sharlatan Hellseher --- gnu/packages/chemistry.scm | 77 +++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/gnu/packages/chemistry.scm b/gnu/packages/chemistry.scm index 0a415a0838..77a0293c8d 100644 --- a/gnu/packages/chemistry.scm +++ b/gnu/packages/chemistry.scm @@ -38,6 +38,7 @@ #:use-module (gnu packages bison) #:use-module (gnu packages boost) #:use-module (gnu packages check) + #:use-module (gnu packages cmake) #:use-module (gnu packages compression) #:use-module (gnu packages c) #:use-module (gnu packages cpp) @@ -58,6 +59,7 @@ #:use-module (gnu packages pkg-config) #:use-module (gnu packages python) #:use-module (gnu packages python-build) + #:use-module (gnu packages python-science) #:use-module (gnu packages python-xyz) #:use-module (gnu packages qt) #:use-module (gnu packages serialization) @@ -69,7 +71,9 @@ #:use-module (gnu packages xml) #:use-module (guix build-system cmake) #:use-module (guix build-system gnu) - #:use-module (guix build-system python)) + #:use-module (guix build-system pyproject) + #:use-module (guix build-system python) + #:use-module (srfi srfi-1)) ;;; Please: Try to add new module packages in alphabetic order. ;;; @@ -732,6 +736,77 @@ used to prepare publication-quality figures, to share interactive results with your colleagues, or to generate pre-rendered animations.") (license license:bsd-3))) +(define-public python-pyscf + (package + (name "python-pyscf") + (version "2.9.0") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/pyscf/pyscf") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "1lj48c749aqf9zd5xbshjsfr0y972r2nsm8lf3760jbfadg9jdsi")))) + (build-system pyproject-build-system) + (arguments + (list + #:modules + '((guix build pyproject-build-system) + (guix build utils) + (ice-9 textual-ports)) + ;; Some tests take a very long time and libxc support is not enabled. + #:tests? #f + #:phases + #~(modify-phases %standard-phases + (add-before 'build 'set-cmake-arguments + (lambda _ + ;; Copied from cmake-build-system. This is passed to 'cmake' in + ;; setup.py. + (setenv "CMAKE_CONFIGURE_ARGS" + (string-join + `("-DCMAKE_BUILD_TYPE=RelWithDebInfo" + ,(string-append "-DCMAKE_INSTALL_PREFIX=" #$output) + ;; ensure that the libraries are installed into /lib + "-DCMAKE_INSTALL_LIBDIR=lib" + ;; add input libraries to rpath + "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE" + ;; add (other) libraries of the project itself to rpath + ,(string-append "-DCMAKE_INSTALL_RPATH=" #$output "/lib") + ;; enable verbose output from builds + "-DCMAKE_VERBOSE_MAKEFILE=ON" + "-DENABLE_LIBXC=OFF" + "-DBUILD_LIBXC=OFF" + "-DBUILD_XCFUN=OFF" + "-DBUILD_LIBCINT=OFF")))))))) + (native-inputs + (list cmake-minimal + python-setuptools + python-wheel)) + (inputs + (list + ;; Use qcint when tuning for x86_64. + (if (and (assq 'cpu-tuning (package-properties this-package)) + (target-x86-64?)) + qcint + libcint) + xcfun + openblas)) + (propagated-inputs + (list python-numpy + python-scipy + python-h5py)) + (home-page "https://github.com/pyscf/pyscf") + (synopsis "Python library for quantum chemistry calculations") + (description + "@code{PySCF} (Python-based Simulations of Chemistry Framework) is a +Python library for quantum chemistry calculations and method development. +Most of the functionality is implemented in Python, while computationally +critical parts are implemented in C.") + (properties '((tunable? . #t))) + (license license:asl2.0))) + ;; Depends on at least SSE3 and should only be used for a tuned build of ;; python-pyscf. (define-public qcint