From 17030252ef9ee1f31e972ae097ddb44e2a5a4e9f Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Tue, 21 Jan 2020 13:16:29 -0500 Subject: [PATCH 01/13] pythonPackages.pyscf: init at 1.7.0 Python-based Simulations of Chemistry Framework. Requirement for qiskit-aqua. --- .../python-modules/pyscf/default.nix | 67 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 69 insertions(+) create mode 100644 pkgs/development/python-modules/pyscf/default.nix diff --git a/pkgs/development/python-modules/pyscf/default.nix b/pkgs/development/python-modules/pyscf/default.nix new file mode 100644 index 0000000000000..36465dfb9bbfc --- /dev/null +++ b/pkgs/development/python-modules/pyscf/default.nix @@ -0,0 +1,67 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, cmake +, openblas +, libcint +, libxc +, h5py +, numpy +, scipy +, pytest +}: + +buildPythonPackage rec { + pname = "pyscf"; + version = "1.7.0"; + + # must download from GitHub to get the Cmake & C source files + src = fetchFromGitHub { + owner = "pyscf"; + repo = pname; + rev = "v${version}"; + sha256 = "0gdmc04nr699bq6gkw9isfzahj0k2gqhxnjg6gj9rybmglarkn15"; + }; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ + libcint + libxc + openblas + ]; + cmakeFlags = [ + # disable rebuilding/downloading the required libraries + "-DBUILD_LIBCINT=0" + "-DBUILD_LIBXC=0" + "-DBUILD_XCFUN=0" + ]; + dontUseCmakeConfigure = true; + + propagatedBuildInputs = [ + h5py + numpy + scipy + ]; + + PYSCF_INC_DIR = lib.strings.makeLibraryPath [ libcint libxc ]; + + pythonImportsCheck = [ "pyscf" ]; + checkInputs = [ pytest ]; + checkPhase = '' + pytest ./pyscf/tools/test + ''; + + meta = with lib; { + description = "Python-based Simulations of Chemistry Framework"; + longDescription = '' + PySCF is an open-source collection of electronic structure modules powered by Python. + The package aims to provide a simple, lightweight, and efficient platform + for quantum chemistry calculations and methodology development. + ''; + homepage = "http://www.pyscf.org/"; + downloadPage = "https://github.com/pyscf/pyscf/releases"; + license = licenses.asl20; + maintainers = with maintainers; [ drewrisinger ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 04fd9e76192df..d6cadeed1ac33 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -5019,6 +5019,8 @@ in { pyqtgraph = callPackage ../development/python-modules/pyqtgraph { }; + pyscf = callPackage ../development/python-modules/pyscf { }; + PyStemmer = callPackage ../development/python-modules/pystemmer {}; # Missing expression? From 29126f8ebe80753bb1234920d7d10259de652c64 Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Mon, 24 Feb 2020 16:04:51 -0500 Subject: [PATCH 02/13] pyscf: tests running --- .../python-modules/pyscf/default.nix | 74 ++++++++++++++++++- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/pyscf/default.nix b/pkgs/development/python-modules/pyscf/default.nix index 36465dfb9bbfc..321ea0c521398 100644 --- a/pkgs/development/python-modules/pyscf/default.nix +++ b/pkgs/development/python-modules/pyscf/default.nix @@ -8,7 +8,9 @@ , h5py , numpy , scipy -, pytest + # Check Inputs +, nose +, nose-exclude }: buildPythonPackage rec { @@ -44,13 +46,79 @@ buildPythonPackage rec { scipy ]; + # prePatch = '' + # # echo "recursive-include pyscf test" >> MANIFEST.in + # # substituteInPlace setup.py --replace "*test*" "" # include tests in output + # # substituteInPlace pyscf/lib/misc.py --replace "_loaderpath = os.path.dirname(__file__)" "_loaderpath = os.path.dirname(__file__); print(_loaderpath)" + # ''; + PYSCF_INC_DIR = lib.strings.makeLibraryPath [ libcint libxc ]; pythonImportsCheck = [ "pyscf" ]; - checkInputs = [ pytest ]; + checkInputs = [ nose nose-exclude ]; + # from source/.travis.yml, mostly + # Tests take about 50 mins to run checkPhase = '' - pytest ./pyscf/tools/test + # substituteInPlace pyscf/lib/misc.py --replace "__file__" "param.__file__" + cp ./dist/tmpbuild/pyscf/pyscf/lib/*.so ./pyscf/lib/ # HACK: Move compiled libraries to test dir so pyscf import mechanism can find them + nosetests -vv -x \ + --where=pyscf \ + --no-path \ + --exclude-dir=geomopt \ + --exclude-dir=dmrgscf \ + --exclude-dir=fciqmcscf \ + --exclude-dir=icmpspt \ + --exclude-dir=shciscf \ + --exclude-dir=nao \ + --exclude-dir=cornell_shci \ + --exclude-dir=xianci \ + --exclude=test_bz \ + --exclude=h2o_vdz \ + --exclude=test_mc2step_4o4e \ + --exclude=test_ks_noimport \ + --exclude=test_jk_single_kpt \ + --exclude=test_jk_hermi0 \ + --exclude=test_j_kpts \ + --exclude=test_k_kpts \ + --exclude=high_cost \ + --exclude=skip \ + --exclude=call_in_background \ + --exclude=libxc_cam_beta_bug \ + --ignore-files=test_kuccsd_supercell_vs_kpts.py \ + --ignore-files=test_kccsd_ghf.py \ + --ignore-files=test_h_.*.py \ + --ignore-files=test_P_uadc_ip.py \ + --ignore-files=test_P_uadc_ea.py \ + --exclude-test=pbc/gw/test/test_kgw_slow_supercell.DiamondTestSupercell3 \ + --exclude-test=pbc/gw/test/test_kgw_slow_supercell.DiamondKSTestSupercell3 \ + --exclude-test=pbc/gw/test/test_kgw_slow.DiamondTestSupercell3 \ + --exclude-test=pbc/gw/test/test_kgw_slow.DiamondKSTestSupercell3 \ + --exclude-test=pbc/tdscf/test/test_krhf_slow_supercell.DiamondTestSupercell3 \ + --exclude-test=pbc/tdscf/test/test_kproxy_hf.DiamondTestSupercell3 \ + --exclude-test=pbc/tdscf/test/test_kproxy_ks.DiamondTestSupercell3 \ + --exclude-test=pbc/tdscf/test/test_kproxy_supercell_hf.DiamondTestSupercell3 \ + --exclude-test=pbc/tdscf/test/test_kproxy_supercell_ks.DiamondTestSupercell3 \ + --ignore-files=.*_slow.*py \ + --ignore-files=.*_kproxy_.*py \ + --ignore-files=test_proxy.py + # --collect-only + # tdscf/*_slow.py gw/*_slow.py are not compatible with python3.[456] and old numpy + + # Unused flags, from testing + # --nocapture \ + # --first-pkg-wins \ + # --traverse-namespace \ + # --exclude-dir=examples \ ''; + # checkInputs = [ pytest ]; + # checkPhase = '' + # cd pyscf + # for directory in `find . -type d -mindepth 1 -maxdepth 1 | sort -z` + # do + # echo "Testing $directory" + # ( pytest $directory ) + # done + # ''; meta = with lib; { description = "Python-based Simulations of Chemistry Framework"; From a70627528308458de4a1d3287b5cedc85460bd30 Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Mon, 24 Feb 2020 16:05:59 -0500 Subject: [PATCH 03/13] pyscf: cleanup unused code --- .../python-modules/pyscf/default.nix | 29 +++---------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/pkgs/development/python-modules/pyscf/default.nix b/pkgs/development/python-modules/pyscf/default.nix index 321ea0c521398..c877b0431ae1c 100644 --- a/pkgs/development/python-modules/pyscf/default.nix +++ b/pkgs/development/python-modules/pyscf/default.nix @@ -46,21 +46,17 @@ buildPythonPackage rec { scipy ]; - # prePatch = '' - # # echo "recursive-include pyscf test" >> MANIFEST.in - # # substituteInPlace setup.py --replace "*test*" "" # include tests in output - # # substituteInPlace pyscf/lib/misc.py --replace "_loaderpath = os.path.dirname(__file__)" "_loaderpath = os.path.dirname(__file__); print(_loaderpath)" - # ''; - PYSCF_INC_DIR = lib.strings.makeLibraryPath [ libcint libxc ]; pythonImportsCheck = [ "pyscf" ]; + checkInputs = [ nose nose-exclude ]; # from source/.travis.yml, mostly # Tests take about 50 mins to run checkPhase = '' - # substituteInPlace pyscf/lib/misc.py --replace "__file__" "param.__file__" - cp ./dist/tmpbuild/pyscf/pyscf/lib/*.so ./pyscf/lib/ # HACK: Move compiled libraries to test dir so pyscf import mechanism can find them + # HACK: Move compiled libraries to test dir so pyscf import mechanism can find them + cp ./dist/tmpbuild/pyscf/pyscf/lib/*.so ./pyscf/lib/ + nosetests -vv -x \ --where=pyscf \ --no-path \ @@ -101,24 +97,7 @@ buildPythonPackage rec { --ignore-files=.*_slow.*py \ --ignore-files=.*_kproxy_.*py \ --ignore-files=test_proxy.py - # --collect-only - # tdscf/*_slow.py gw/*_slow.py are not compatible with python3.[456] and old numpy - - # Unused flags, from testing - # --nocapture \ - # --first-pkg-wins \ - # --traverse-namespace \ - # --exclude-dir=examples \ ''; - # checkInputs = [ pytest ]; - # checkPhase = '' - # cd pyscf - # for directory in `find . -type d -mindepth 1 -maxdepth 1 | sort -z` - # do - # echo "Testing $directory" - # ( pytest $directory ) - # done - # ''; meta = with lib; { description = "Python-based Simulations of Chemistry Framework"; From 3bc5a81e441098ed959e398fabbecd5aac10695a Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Mon, 24 Feb 2020 17:13:55 -0500 Subject: [PATCH 04/13] pyscf: break check into multiple hooks --- .../development/python-modules/pyscf/default.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/pyscf/default.nix b/pkgs/development/python-modules/pyscf/default.nix index c877b0431ae1c..74cd825275da0 100644 --- a/pkgs/development/python-modules/pyscf/default.nix +++ b/pkgs/development/python-modules/pyscf/default.nix @@ -52,12 +52,20 @@ buildPythonPackage rec { checkInputs = [ nose nose-exclude ]; # from source/.travis.yml, mostly - # Tests take about 50 mins to run - checkPhase = '' + # Tests take about 30 mins to run + preCheck = '' # HACK: Move compiled libraries to test dir so pyscf import mechanism can find them cp ./dist/tmpbuild/pyscf/pyscf/lib/*.so ./pyscf/lib/ - nosetests -vv -x \ + # Set config used by tests to ensure reproducibility + echo 'pbc_tools_pbc_fft_engine = "NUMPY"' > pyscf/pyscf_config.py + export OMP_NUM_THREADS=1 + export PYSCF_CONFIG_FILE=$(pwd)/pyscf/pyscf_config.py + ''; + checkPhase = '' + runHook preCheck + + nosetests \ --where=pyscf \ --no-path \ --exclude-dir=geomopt \ @@ -97,6 +105,8 @@ buildPythonPackage rec { --ignore-files=.*_slow.*py \ --ignore-files=.*_kproxy_.*py \ --ignore-files=test_proxy.py + + runHook postCheck ''; meta = with lib; { From b781a5ca81fb78bd1aa23a00efbd45e7a1dc8286 Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Tue, 25 Feb 2020 15:09:45 -0500 Subject: [PATCH 05/13] xcfun: init TODO --- .../python-modules/xcfun/default.nix | 84 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 86 insertions(+) create mode 100644 pkgs/development/python-modules/xcfun/default.nix diff --git a/pkgs/development/python-modules/xcfun/default.nix b/pkgs/development/python-modules/xcfun/default.nix new file mode 100644 index 0000000000000..97029c6d89284 --- /dev/null +++ b/pkgs/development/python-modules/xcfun/default.nix @@ -0,0 +1,84 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, cmake +, gfortran +, perl +, pybind11 +, bzip2 +, numpy + # Check Inputs +, pytestCheckHook +, pytestcov +}: + +# TODO: replace w/ derivation, non-python +buildPythonPackage rec { + pname = "xcfun"; + version = "1.X"; + src = fetchFromGitHub { + owner = "dftlibs"; + repo = pname; + rev = "stable-1.x"; # TODO + sha256 = "0b53f11pr0xydiz6hqn0crymahkhrhh5yi96xr8gglj0j8rk7p1v"; + }; + + nativeBuildInputs = [ + cmake + ]; + + buildInputs = [ + perl + bzip2 + ]; + + propagatedBuildInputs = [ + numpy + pybind11 + ]; + + cmakeFlags = [ + "-DBUILD_TESTING=ON" + ]; + postConfigure = '' + cd .. + ''; + # setupPyBuildFlags = [ + # "--cmake-options='-DENABLE_TESTALL=ON'" + # ]; + # dontUseCmakeConfigure = true; + # dontUseSetuptoolsBuild = true; + preBuild = '' + pushd build + make + popd + ''; + + checkInputs = [ + pytestCheckHook + pytestcov + ]; + dontUseSetuptoolsCheck = true; # unittest doesn't know how to "test" built C libraries + preCheck = '' + # Run C tests + # pushd ./testsuite + # ctest + # patchShebangs ./xc-run_testsuite + # ./xc-run_testsuite + # popd + pushd build + ctest --progress + popd + + # Move compiled library to test dir + cp ./dist/tmpbuild/pylibxc/pylibxc/libxc.so ./pylibxc/ + ''; + + meta = with lib; { + description = "Exchange-correlation functionals with arbitrary order derivatives"; + homepage = "https://xcfun.readthedocs.io/en/latest/"; + downloadPage = "https://github.com/dftlibs/xcfun/releases"; + license = licenses.mpl20; + maintainers = with maintainers; [ drewrisinger ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index d6cadeed1ac33..b2ee087e9c7ca 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -6116,6 +6116,8 @@ in { xcaplib = callPackage ../development/python-modules/xcaplib { }; + xcfun = callPackage ../development/python-modules/xcfun { }; + xlib = callPackage ../development/python-modules/xlib { }; yappi = callPackage ../development/python-modules/yappi { }; From 7863033662b564f4234ae667360c1e17c991c835 Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Tue, 25 Feb 2020 18:24:38 -0500 Subject: [PATCH 06/13] xcfun: init at 1.0.0 Exchange-correlation functionals with arbitrary order derivatives. Library dependency of pythonPackages.pyscf. --- pkgs/development/libraries/xcfun/default.nix | 44 ++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 46 insertions(+) create mode 100644 pkgs/development/libraries/xcfun/default.nix diff --git a/pkgs/development/libraries/xcfun/default.nix b/pkgs/development/libraries/xcfun/default.nix new file mode 100644 index 0000000000000..b44950b77a681 --- /dev/null +++ b/pkgs/development/libraries/xcfun/default.nix @@ -0,0 +1,44 @@ +{ stdenv +, fetchFromGitHub +, cmake +, perl +, bzip2 +}: + +stdenv.mkDerivation rec { + pname = "xcfun"; + version = "1.0.X"; + + src = fetchFromGitHub { + owner = "dftlibs"; + repo = pname; + rev = "4436c86f905119628a5155c27b347f31d576f5af"; # tip of stable-1.X + sha256 = "0b53f11pr0xydiz6hqn0crymahkhrhh5yi96xr8gglj0j8rk7p1v"; + }; + + nativeBuildInputs = [ + cmake + ]; + + buildInputs = [ + perl + bzip2 + ]; + + cmakeFlags = [ + "-DBUILD_TESTING=ON" + ]; + + doCheck = true; + checkPhase = '' + ctest --progress + ''; + + meta = with stdenv.lib; { + description = "Exchange-correlation functionals with arbitrary order derivatives"; + homepage = "https://xcfun.readthedocs.io/en/latest/"; + downloadPage = "https://github.com/dftlibs/xcfun/releases"; + license = licenses.mpl20; + maintainers = with maintainers; [ drewrisinger ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6b18b36b46336..bab70989962cc 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14717,6 +14717,8 @@ in xcbutilxrm = callPackage ../servers/x11/xorg/xcb-util-xrm.nix { }; + xcfun = callPackage ../development/libraries/xcfun { }; + xdo = callPackage ../tools/misc/xdo { }; xineLib = callPackage ../development/libraries/xine-lib { }; From 144cbbd310e9188442b35531130ef6a50d38974c Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Wed, 26 Feb 2020 12:13:30 -0500 Subject: [PATCH 07/13] xcfun: build library as .so vs .a --- pkgs/development/libraries/xcfun/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/xcfun/default.nix b/pkgs/development/libraries/xcfun/default.nix index b44950b77a681..dd2058e5f6787 100644 --- a/pkgs/development/libraries/xcfun/default.nix +++ b/pkgs/development/libraries/xcfun/default.nix @@ -26,11 +26,14 @@ stdenv.mkDerivation rec { ]; cmakeFlags = [ - "-DBUILD_TESTING=ON" + "-DBUILD_TESTING=1" + "-DBUILD_SHARED_LIBS=1" ]; doCheck = true; checkPhase = '' + # set path for finding libxc.so for tests + export LD_LIBRARY_PATH=/build/source/build ctest --progress ''; From a3a400cc8e876489e70eb0e948d3d725c7730116 Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Wed, 26 Feb 2020 12:15:24 -0500 Subject: [PATCH 08/13] python.xcfun: remove --- .../python-modules/xcfun/default.nix | 84 ------------------- pkgs/top-level/python-packages.nix | 2 - 2 files changed, 86 deletions(-) delete mode 100644 pkgs/development/python-modules/xcfun/default.nix diff --git a/pkgs/development/python-modules/xcfun/default.nix b/pkgs/development/python-modules/xcfun/default.nix deleted file mode 100644 index 97029c6d89284..0000000000000 --- a/pkgs/development/python-modules/xcfun/default.nix +++ /dev/null @@ -1,84 +0,0 @@ -{ lib -, buildPythonPackage -, fetchFromGitHub -, cmake -, gfortran -, perl -, pybind11 -, bzip2 -, numpy - # Check Inputs -, pytestCheckHook -, pytestcov -}: - -# TODO: replace w/ derivation, non-python -buildPythonPackage rec { - pname = "xcfun"; - version = "1.X"; - src = fetchFromGitHub { - owner = "dftlibs"; - repo = pname; - rev = "stable-1.x"; # TODO - sha256 = "0b53f11pr0xydiz6hqn0crymahkhrhh5yi96xr8gglj0j8rk7p1v"; - }; - - nativeBuildInputs = [ - cmake - ]; - - buildInputs = [ - perl - bzip2 - ]; - - propagatedBuildInputs = [ - numpy - pybind11 - ]; - - cmakeFlags = [ - "-DBUILD_TESTING=ON" - ]; - postConfigure = '' - cd .. - ''; - # setupPyBuildFlags = [ - # "--cmake-options='-DENABLE_TESTALL=ON'" - # ]; - # dontUseCmakeConfigure = true; - # dontUseSetuptoolsBuild = true; - preBuild = '' - pushd build - make - popd - ''; - - checkInputs = [ - pytestCheckHook - pytestcov - ]; - dontUseSetuptoolsCheck = true; # unittest doesn't know how to "test" built C libraries - preCheck = '' - # Run C tests - # pushd ./testsuite - # ctest - # patchShebangs ./xc-run_testsuite - # ./xc-run_testsuite - # popd - pushd build - ctest --progress - popd - - # Move compiled library to test dir - cp ./dist/tmpbuild/pylibxc/pylibxc/libxc.so ./pylibxc/ - ''; - - meta = with lib; { - description = "Exchange-correlation functionals with arbitrary order derivatives"; - homepage = "https://xcfun.readthedocs.io/en/latest/"; - downloadPage = "https://github.com/dftlibs/xcfun/releases"; - license = licenses.mpl20; - maintainers = with maintainers; [ drewrisinger ]; - }; -} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index b2ee087e9c7ca..d6cadeed1ac33 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -6116,8 +6116,6 @@ in { xcaplib = callPackage ../development/python-modules/xcaplib { }; - xcfun = callPackage ../development/python-modules/xcfun { }; - xlib = callPackage ../development/python-modules/xlib { }; yappi = callPackage ../development/python-modules/yappi { }; From 9d71cdb0c3bfa21e95fd054b9570be081aaff0a4 Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Fri, 13 Mar 2020 16:48:06 -0400 Subject: [PATCH 09/13] WIP: fix xcfun/pyscf --- pkgs/development/libraries/xcfun/default.nix | 10 +++-- .../python-modules/pyscf/default.nix | 41 ++++++++++++++++--- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/pkgs/development/libraries/xcfun/default.nix b/pkgs/development/libraries/xcfun/default.nix index dd2058e5f6787..7a7a849858d7e 100644 --- a/pkgs/development/libraries/xcfun/default.nix +++ b/pkgs/development/libraries/xcfun/default.nix @@ -1,6 +1,7 @@ { stdenv , fetchFromGitHub , cmake +, gfortran , perl , bzip2 }: @@ -12,8 +13,8 @@ stdenv.mkDerivation rec { src = fetchFromGitHub { owner = "dftlibs"; repo = pname; - rev = "4436c86f905119628a5155c27b347f31d576f5af"; # tip of stable-1.X - sha256 = "0b53f11pr0xydiz6hqn0crymahkhrhh5yi96xr8gglj0j8rk7p1v"; + rev = "355f42497a9cd17d16ae91da1f1aaaf93756ae8b"; # rev recommended by pythonPackages.pyscf: https://sunqm.github.io/pyscf/install.html#installation-without-network + sha256 = "09hs8lxks2d98a5q2xky9dz5sfsrxaww3kyryksi9b6l1f1m3hxp"; }; nativeBuildInputs = [ @@ -21,15 +22,18 @@ stdenv.mkDerivation rec { ]; buildInputs = [ - perl bzip2 + gfortran + perl ]; cmakeFlags = [ "-DBUILD_TESTING=1" "-DBUILD_SHARED_LIBS=1" + "-DXC_MAX_ORDER=3" ]; + # TODO: tests are very quick. check it actually does something. doCheck = true; checkPhase = '' # set path for finding libxc.so for tests diff --git a/pkgs/development/python-modules/pyscf/default.nix b/pkgs/development/python-modules/pyscf/default.nix index 74cd825275da0..13974d2ba0747 100644 --- a/pkgs/development/python-modules/pyscf/default.nix +++ b/pkgs/development/python-modules/pyscf/default.nix @@ -1,10 +1,12 @@ { lib , buildPythonPackage +, isPy27 , fetchFromGitHub , cmake , openblas , libcint , libxc +, xcfun , h5py , numpy , scipy @@ -15,30 +17,56 @@ buildPythonPackage rec { pname = "pyscf"; - version = "1.7.0"; + version = "1.6.6"; # must download from GitHub to get the Cmake & C source files src = fetchFromGitHub { owner = "pyscf"; repo = pname; rev = "v${version}"; - sha256 = "0gdmc04nr699bq6gkw9isfzahj0k2gqhxnjg6gj9rybmglarkn15"; + sha256 = "097cm1823r1v3hv7nk3m2k2xg2z4knsczhahxdgipwgrpank8fab"; }; + disabled = isPy27; + nativeBuildInputs = [ cmake ]; buildInputs = [ libcint libxc openblas + xcfun ]; + + prePatch = '' + mkdir -p ./pyscf/lib/deps/include ./pyscf/lib/deps/lib + ln -s ${lib.strings.makeSearchPath "include" [xcfun] }/xc.h ./pyscf/lib/deps/include/xcfun.h + ln -s ${lib.strings.makeLibraryPath [ xcfun ] }/libxc.so ./pyscf/lib/deps/lib/libxcfun.so + ''; + + cmakeFlags = [ # disable rebuilding/downloading the required libraries "-DBUILD_LIBCINT=0" "-DBUILD_LIBXC=0" "-DBUILD_XCFUN=0" + "-DENABLE_XCFUN=1" ]; - dontUseCmakeConfigure = true; + # Configure CMake to build C files in pyscf/lib + preConfigure = '' + pushd pyscf/lib + ''; + postConfigure = '' + popd + ''; + + # Build C dependencies + preBuild = '' + pushd pyscf/lib/build + export LD_LIBRARY_PATH=$(pwd)/lib/deps/include:$LD_LIBRARY_PATH + make + popd + ''; propagatedBuildInputs = [ h5py @@ -46,7 +74,7 @@ buildPythonPackage rec { scipy ]; - PYSCF_INC_DIR = lib.strings.makeLibraryPath [ libcint libxc ]; + PYSCF_INC_DIR = lib.strings.makeLibraryPath [ libcint libxc ] + ":" + lib.strings.makeSearchPath "include" [ xcfun ]; pythonImportsCheck = [ "pyscf" ]; @@ -65,9 +93,8 @@ buildPythonPackage rec { checkPhase = '' runHook preCheck - nosetests \ + nosetests -vv \ --where=pyscf \ - --no-path \ --exclude-dir=geomopt \ --exclude-dir=dmrgscf \ --exclude-dir=fciqmcscf \ @@ -109,6 +136,8 @@ buildPythonPackage rec { runHook postCheck ''; + # failed tests: test_rsh_df4c_get_jk + meta = with lib; { description = "Python-based Simulations of Chemistry Framework"; longDescription = '' From 3d26d6087b7b61b96628199bce96236def5a4544 Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Wed, 25 Mar 2020 14:28:00 -0400 Subject: [PATCH 10/13] pythonPackages.pyscf: 1.6.6 -> 1.7.1 --- .../python-modules/pyscf/default.nix | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkgs/development/python-modules/pyscf/default.nix b/pkgs/development/python-modules/pyscf/default.nix index 13974d2ba0747..777a8d0f83f75 100644 --- a/pkgs/development/python-modules/pyscf/default.nix +++ b/pkgs/development/python-modules/pyscf/default.nix @@ -17,14 +17,14 @@ buildPythonPackage rec { pname = "pyscf"; - version = "1.6.6"; + version = "1.7.1"; # must download from GitHub to get the Cmake & C source files src = fetchFromGitHub { owner = "pyscf"; repo = pname; rev = "v${version}"; - sha256 = "097cm1823r1v3hv7nk3m2k2xg2z4knsczhahxdgipwgrpank8fab"; + sha256 = "0fciw9id8fr9396sz52ap5gys0i9hmrmrwm0i1k1k7aciqab3kls"; }; disabled = isPy27; @@ -93,8 +93,9 @@ buildPythonPackage rec { checkPhase = '' runHook preCheck - nosetests -vv \ + nosetests -v \ --where=pyscf \ + --detailed-errors \ --exclude-dir=geomopt \ --exclude-dir=dmrgscf \ --exclude-dir=fciqmcscf \ @@ -115,11 +116,11 @@ buildPythonPackage rec { --exclude=skip \ --exclude=call_in_background \ --exclude=libxc_cam_beta_bug \ - --ignore-files=test_kuccsd_supercell_vs_kpts.py \ - --ignore-files=test_kccsd_ghf.py \ - --ignore-files=test_h_.*.py \ - --ignore-files=test_P_uadc_ip.py \ - --ignore-files=test_P_uadc_ea.py \ + --ignore-files=test_kuccsd_supercell_vs_kpts\.py \ + --ignore-files=test_kccsd_ghf\.py \ + --ignore-files=test_h_.*\.py \ + --ignore-files=test_P_uadc_ip\.py \ + --ignore-files=test_P_uadc_ea\.py \ --exclude-test=pbc/gw/test/test_kgw_slow_supercell.DiamondTestSupercell3 \ --exclude-test=pbc/gw/test/test_kgw_slow_supercell.DiamondKSTestSupercell3 \ --exclude-test=pbc/gw/test/test_kgw_slow.DiamondTestSupercell3 \ @@ -131,7 +132,7 @@ buildPythonPackage rec { --exclude-test=pbc/tdscf/test/test_kproxy_supercell_ks.DiamondTestSupercell3 \ --ignore-files=.*_slow.*py \ --ignore-files=.*_kproxy_.*py \ - --ignore-files=test_proxy.py + --ignore-files=test_proxy\.py runHook postCheck ''; From 7952bb597f233e73dabeb13f078f9b22119d47b7 Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Wed, 25 Mar 2020 15:35:58 -0400 Subject: [PATCH 11/13] libcint: add pythonPackages.pyscf build flags As far as I know, libcint is only used for PySCF, so this just corrects the build flags that it should have to build properly for that. --- pkgs/development/libraries/libcint/default.nix | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/libcint/default.nix b/pkgs/development/libraries/libcint/default.nix index e56583e45ba9b..49f96a035f6fc 100644 --- a/pkgs/development/libraries/libcint/default.nix +++ b/pkgs/development/libraries/libcint/default.nix @@ -1,10 +1,11 @@ { stdenv , lib , fetchFromGitHub +, fetchpatch , cmake , openblas # Check Inputs -, python2 +, python }: stdenv.mkDerivation rec { @@ -24,11 +25,22 @@ stdenv.mkDerivation rec { "-DENABLE_TEST=1" "-DQUICK_TEST=1" "-DCMAKE_INSTALL_PREFIX=" # ends up double-adding /nix/store/... prefix, this avoids issue + "-DWITH_F12=1" + "-DWITH_RANGE_COULOMB=1" + "-DWITH_COULOMB_ERF=1" + ]; + + patches = [ + (fetchpatch { + name = "libcint-python3-test-syntax-patch"; + url = "http://patch-diff.githubusercontent.com/raw/sunqm/libcint/pull/33.patch"; + sha256 = "1pg9rz8vffijl3kkk6f4frsivd7m2gp2k44llzkaajav4m5q8q4a"; + }) ]; doCheck = true; - # Test syntax (like print statements) is written in python2. Fixed when #33 merged: https://github.com/sunqm/libcint/pull/33 - checkInputs = [ python2.pkgs.numpy ]; + + checkInputs = [ python.pkgs.numpy ]; meta = with lib; { description = "General GTO integrals for quantum chemistry"; From 3ff39bfde0354c848a9932218726982bc3924759 Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Thu, 26 Mar 2020 16:29:30 -0400 Subject: [PATCH 12/13] pythonPackages.pyscf: make most tests work. few errors remain --- .../python-modules/pyscf/default.nix | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/pkgs/development/python-modules/pyscf/default.nix b/pkgs/development/python-modules/pyscf/default.nix index 777a8d0f83f75..72415393f7e32 100644 --- a/pkgs/development/python-modules/pyscf/default.nix +++ b/pkgs/development/python-modules/pyscf/default.nix @@ -38,10 +38,11 @@ buildPythonPackage rec { xcfun ]; - prePatch = '' + postPatch = '' mkdir -p ./pyscf/lib/deps/include ./pyscf/lib/deps/lib ln -s ${lib.strings.makeSearchPath "include" [xcfun] }/xc.h ./pyscf/lib/deps/include/xcfun.h ln -s ${lib.strings.makeLibraryPath [ xcfun ] }/libxc.so ./pyscf/lib/deps/lib/libxcfun.so + substituteInPlace pyscf/rt/__init__.py --replace "from tdscf import *" "from pyscf.tdscf import *" ''; @@ -121,20 +122,25 @@ buildPythonPackage rec { --ignore-files=test_h_.*\.py \ --ignore-files=test_P_uadc_ip\.py \ --ignore-files=test_P_uadc_ea\.py \ - --exclude-test=pbc/gw/test/test_kgw_slow_supercell.DiamondTestSupercell3 \ - --exclude-test=pbc/gw/test/test_kgw_slow_supercell.DiamondKSTestSupercell3 \ - --exclude-test=pbc/gw/test/test_kgw_slow.DiamondTestSupercell3 \ - --exclude-test=pbc/gw/test/test_kgw_slow.DiamondKSTestSupercell3 \ - --exclude-test=pbc/tdscf/test/test_krhf_slow_supercell.DiamondTestSupercell3 \ --exclude-test=pbc/tdscf/test/test_kproxy_hf.DiamondTestSupercell3 \ --exclude-test=pbc/tdscf/test/test_kproxy_ks.DiamondTestSupercell3 \ --exclude-test=pbc/tdscf/test/test_kproxy_supercell_hf.DiamondTestSupercell3 \ --exclude-test=pbc/tdscf/test/test_kproxy_supercell_ks.DiamondTestSupercell3 \ - --ignore-files=.*_slow.*py \ - --ignore-files=.*_kproxy_.*py \ - --ignore-files=test_proxy\.py - - runHook postCheck + --ignore-files=.*_slow.*\.py \ + --ignore-files=.*_kproxy_.*\.py \ + --ignore-files=test_proxy\.py \ + --ignore-files=test_krhf_slow_gamma\.py \ + --ignore-files=test_krhf_slow\.py \ + --ignore-files=test_krhf_slow_supercell\.py \ + --ignore-files=test_ddcosmo_grad\.py \ + --exclude=test_range_separated \ + --ignore-files=test_ksproxy_ks\.py \ + --ignore-files=test_kproxy_hf\.py \ + --ignore-files=test_kgw_slow\.py + + # NOTE: disables below test_proxy.py are manually added to get it to pass in Nix, and are NOT in the upstream Travis config + + runHook postCheck ''; # failed tests: test_rsh_df4c_get_jk From a5e4fc6efaed17f53bfab72861ff4e7bb2f8e35a Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Tue, 31 Mar 2020 11:37:58 -0400 Subject: [PATCH 13/13] pythonPackages.pyscf: cleanup with code review suggestions --- .../python-modules/pyscf/default.nix | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pkgs/development/python-modules/pyscf/default.nix b/pkgs/development/python-modules/pyscf/default.nix index 72415393f7e32..2956413ee52e5 100644 --- a/pkgs/development/python-modules/pyscf/default.nix +++ b/pkgs/development/python-modules/pyscf/default.nix @@ -2,11 +2,13 @@ , buildPythonPackage , isPy27 , fetchFromGitHub +# C/build dependencies , cmake , openblas , libcint , libxc , xcfun +# Python dependencies , h5py , numpy , scipy @@ -40,8 +42,8 @@ buildPythonPackage rec { postPatch = '' mkdir -p ./pyscf/lib/deps/include ./pyscf/lib/deps/lib - ln -s ${lib.strings.makeSearchPath "include" [xcfun] }/xc.h ./pyscf/lib/deps/include/xcfun.h - ln -s ${lib.strings.makeLibraryPath [ xcfun ] }/libxc.so ./pyscf/lib/deps/lib/libxcfun.so + ln -s ${lib.getDev xcfun}/include/xc.h ./pyscf/lib/deps/include/xcfun.h + ln -s ${lib.getLib xcfun}/lib/libxc.so ./pyscf/lib/deps/lib/libxcfun.so substituteInPlace pyscf/rt/__init__.py --replace "from tdscf import *" "from pyscf.tdscf import *" ''; @@ -53,7 +55,7 @@ buildPythonPackage rec { "-DBUILD_XCFUN=0" "-DENABLE_XCFUN=1" ]; - # Configure CMake to build C files in pyscf/lib + # Configure CMake to build C files in pyscf/lib. Python build expects files in ./pyscf/lib/build preConfigure = '' pushd pyscf/lib ''; @@ -61,10 +63,9 @@ buildPythonPackage rec { popd ''; - # Build C dependencies + # Build C dependencies, then build python package. preBuild = '' pushd pyscf/lib/build - export LD_LIBRARY_PATH=$(pwd)/lib/deps/include:$LD_LIBRARY_PATH make popd ''; @@ -75,7 +76,12 @@ buildPythonPackage rec { scipy ]; - PYSCF_INC_DIR = lib.strings.makeLibraryPath [ libcint libxc ] + ":" + lib.strings.makeSearchPath "include" [ xcfun ]; + # add libcint, libxc, xcfun headers to include path. + PYSCF_INC_DIR = lib.makeSearchPath "include" (map lib.getDev [ + libcint + libxc + xcfun + ]); pythonImportsCheck = [ "pyscf" ]; @@ -143,8 +149,6 @@ buildPythonPackage rec { runHook postCheck ''; - # failed tests: test_rsh_df4c_get_jk - meta = with lib; { description = "Python-based Simulations of Chemistry Framework"; longDescription = ''