at master 1.5 kB view raw
1{ 2 lib, 3 lammps, 4 stdenv, 5 buildPythonPackage, 6}: 7 8let 9 LAMMPS_SHARED_LIB = "${lib.getLib lammps}/lib/liblammps${stdenv.hostPlatform.extensions.library}"; 10in 11buildPythonPackage { 12 format = "setuptools"; 13 inherit (lammps) pname version src; 14 15 env = { 16 # Needed for tests 17 inherit LAMMPS_SHARED_LIB; 18 }; 19 # Don't perform checks if GPU is enabled - because libcuda.so cannot be opened in the sandbox 20 doCheck = if lammps.passthru.packages ? GPU then !lammps.passthru.packages.GPU else true; 21 preConfigure = '' 22 cd python 23 # Upstream assumes that the shared library is located in the same directory 24 # as the core.py file. We want to separate the shared library (built by 25 # cmake) and the Python library, so we perform this substitution: 26 substituteInPlace lammps/core.py \ 27 --replace-fail \ 28 "from inspect import getsourcefile" \ 29 "getsourcefile = lambda f: \"${LAMMPS_SHARED_LIB}\"" 30 ''; 31 32 pythonImportsCheck = [ 33 "lammps" 34 "lammps.pylammps" 35 ]; 36 37 # We could potentially run other examples, but some of them are so old that 38 # they don't run with nowadays' LAMMPS. This one is simple enough and recent 39 # enough and it works. 40 checkPhase = '' 41 python examples/mc.py examples/in.mc 42 ''; 43 44 meta = { 45 description = "Python Bindings for LAMMPS"; 46 homepage = "https://docs.lammps.org/Python_head.html"; 47 inherit (lammps.meta) license; 48 maintainers = with lib.maintainers; [ doronbehar ]; 49 }; 50}