Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions pkgs/development/libraries/libcint/default.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{ stdenv
, lib
, fetchFromGitHub
, fetchpatch
, cmake
, openblas
# Check Inputs
, python2
, python
}:

stdenv.mkDerivation rec {
Expand All @@ -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";
Expand Down
51 changes: 51 additions & 0 deletions pkgs/development/libraries/xcfun/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{ stdenv
, fetchFromGitHub
, cmake
, gfortran
, perl
, bzip2
}:

stdenv.mkDerivation rec {
pname = "xcfun";
version = "1.0.X";

src = fetchFromGitHub {
owner = "dftlibs";
repo = pname;
rev = "355f42497a9cd17d16ae91da1f1aaaf93756ae8b"; # rev recommended by pythonPackages.pyscf: https://sunqm.github.io/pyscf/install.html#installation-without-network
sha256 = "09hs8lxks2d98a5q2xky9dz5sfsrxaww3kyryksi9b6l1f1m3hxp";
};

nativeBuildInputs = [
cmake
];

buildInputs = [
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
export LD_LIBRARY_PATH=/build/source/build
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 ];
};
}
164 changes: 164 additions & 0 deletions pkgs/development/python-modules/pyscf/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
{ lib
, buildPythonPackage
, isPy27
, fetchFromGitHub
# C/build dependencies
, cmake
, openblas
, libcint
, libxc
, xcfun
# Python dependencies
, h5py
, numpy
, scipy
# Check Inputs
, nose
, nose-exclude
}:

buildPythonPackage rec {
pname = "pyscf";
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 = "0fciw9id8fr9396sz52ap5gys0i9hmrmrwm0i1k1k7aciqab3kls";
};

disabled = isPy27;

nativeBuildInputs = [ cmake ];

buildInputs = [
libcint
libxc
openblas
xcfun
];

postPatch = ''
mkdir -p ./pyscf/lib/deps/include ./pyscf/lib/deps/lib
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 *"
'';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change


cmakeFlags = [
# disable rebuilding/downloading the required libraries
"-DBUILD_LIBCINT=0"
"-DBUILD_LIBXC=0"
"-DBUILD_XCFUN=0"
"-DENABLE_XCFUN=1"
];
# Configure CMake to build C files in pyscf/lib. Python build expects files in ./pyscf/lib/build
preConfigure = ''
pushd pyscf/lib
'';
postConfigure = ''
popd
'';

# Build C dependencies, then build python package.
preBuild = ''
pushd pyscf/lib/build
make
popd
'';
Comment on lines +67 to +71
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should work as well

Suggested change
preBuild = ''
pushd pyscf/lib/build
make
popd
'';
makeFlags = [ "-C pyscf/lib/build" ];


propagatedBuildInputs = [
h5py
numpy
scipy
];

# add libcint, libxc, xcfun headers to include path.
PYSCF_INC_DIR = lib.makeSearchPath "include" (map lib.getDev [
libcint
libxc
xcfun
]);

pythonImportsCheck = [ "pyscf" ];

checkInputs = [ nose nose-exclude ];
# from source/.travis.yml, mostly
# 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/
Comment on lines +92 to +93
Copy link
Contributor

@jonringer jonringer Mar 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might not be needed anymore, the pythonImportsCheck hook was patched so it would not change PWD to $out


# 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 -v \
--where=pyscf \
--detailed-errors \
--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/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 \
--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
'';

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 ];
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 { };
Expand Down
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down