nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ buildPythonPackage
2, lib
3, fetchFromGitHub
4, cmake
5, blas
6, libcint
7, libxc
8, xcfun
9, cppe
10, h5py
11, numpy
12, scipy
13, nose
14, nose-exclude
15}:
16
17buildPythonPackage rec {
18 pname = "pyscf";
19 version = "2.0.1";
20
21 src = fetchFromGitHub {
22 owner = "pyscf";
23 repo = pname;
24 rev = "v${version}";
25 sha256 = "sha256-nwnhaqSn/9WHBjUPaEabK4x23fJ83WwEYvz6aCcvsDw=";
26 };
27
28 # setup.py calls Cmake and passes the arguments in CMAKE_CONFIGURE_ARGS to cmake.
29 nativeBuildInputs = [ cmake ];
30 dontUseCmakeConfigure = true;
31 preConfigure = ''
32 export CMAKE_CONFIGURE_ARGS="-DBUILD_LIBCINT=0 -DBUILD_LIBXC=0 -DBUILD_XCFUN=0"
33 PYSCF_INC_DIR="${libcint}:${libxc}:${xcfun}";
34 '';
35
36 buildInputs = [
37 blas
38 libcint
39 libxc
40 xcfun
41 ];
42
43 propagatedBuildInputs = [
44 cppe
45 h5py
46 numpy
47 scipy
48 ];
49
50 checkInputs = [ nose nose-exclude ];
51
52 pythonImportsCheck = [ "pyscf" ];
53 preCheck = ''
54 # Set config used by tests to ensure reproducibility
55 echo 'pbc_tools_pbc_fft_engine = "NUMPY"' > pyscf/pyscf_config.py
56 export OMP_NUM_THREADS=1
57 ulimit -s 20000
58 export PYSCF_CONFIG_FILE=$(pwd)/pyscf/pyscf_config.py
59 '';
60 # As defined for the PySCF CI at https://github.com/pyscf/pyscf/blob/master/.github/workflows/run_tests.sh
61 # minus some additionally numerically instable tests, that are sensitive to BLAS, FFTW, etc.
62 checkPhase = ''
63 runHook preCheck
64
65 nosetests pyscf/ -v \
66 --exclude-dir=examples --exclude-dir=pyscf/pbc/grad \
67 --exclude-dir=pyscf/x2c \
68 --exclude-dir=pyscf/adc \
69 --exclude-dir=pyscf/pbc/tdscf \
70 -e test_bz \
71 -e h2o_vdz \
72 -e test_mc2step_4o4e \
73 -e test_ks_noimport \
74 -e test_jk_hermi0 \
75 -e test_j_kpts \
76 -e test_k_kpts \
77 -e high_cost \
78 -e skip \
79 -e call_in_background \
80 -e libxc_cam_beta_bug \
81 -e test_finite_diff_rks_eph \
82 -e test_finite_diff_uks_eph \
83 -e test_pipek \
84 -e test_n3_cis_ewald \
85 -I test_kuccsd_supercell_vs_kpts\.py \
86 -I test_kccsd_ghf\.py \
87 -I test_h_.*\.py \
88 --exclude-test=pyscf/pbc/gw/test/test_kgw_slow_supercell.DiamondTestSupercell3 \
89 --exclude-test=pyscf/pbc/gw/test/test_kgw_slow_supercell.DiamondKSTestSupercell3 \
90 --exclude-test=pyscf/pbc/gw/test/test_kgw_slow.DiamondTestSupercell3 \
91 --exclude-test=pyscf/pbc/gw/test/test_kgw_slow.DiamondKSTestSupercell3 \
92 --exclude-test=pyscf/pbc/tdscf/test/test_krhf_slow_supercell.DiamondTestSupercell3 \
93 --exclude-test=pyscf/pbc/tdscf/test/test_kproxy_hf.DiamondTestSupercell3 \
94 --exclude-test=pyscf/pbc/tdscf/test/test_kproxy_ks.DiamondTestSupercell3 \
95 --exclude-test=pyscf/pbc/tdscf/test/test_kproxy_supercell_hf.DiamondTestSupercell3 \
96 --exclude-test=pyscf/pbc/tdscf/test/test_kproxy_supercell_ks.DiamondTestSupercell3 \
97 -I .*_slow.*py -I .*_kproxy_.*py -I test_proxy.py tdscf/*_slow.py gw/*_slow.py
98
99 runHook postCheck
100 '';
101
102 meta = with lib; {
103 description = "Python-based simulations of chemistry framework";
104 homepage = "https://github.com/pyscf/pyscf";
105 license = licenses.asl20;
106 platforms = [ "x86_64-linux" "x86_64-darwin" ];
107 maintainers = [ maintainers.sheepforce ];
108 };
109}