Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 absl-py, 3 buildPythonPackage, 4 cmake, 5 etils, 6 fetchPypi, 7 glfw, 8 lib, 9 mujoco, 10 numpy, 11 perl, 12 pybind11, 13 pyopengl, 14 python, 15 setuptools, 16 stdenv, 17}: 18 19buildPythonPackage rec { 20 pname = "mujoco"; 21 inherit (mujoco) version; 22 23 pyproject = true; 24 25 # We do not fetch from the repository because the PyPi tarball is 26 # impurely build via 27 # <https://github.com/google-deepmind/mujoco/blob/main/python/make_sdist.sh> 28 # in the project's CI. 29 src = fetchPypi { 30 inherit pname version; 31 hash = "sha256-fPiIdSbwcedBHcAs4c1mXjm0tgg/3/Sf4TSKgtIxRlE="; 32 }; 33 34 nativeBuildInputs = [ 35 cmake 36 setuptools 37 ]; 38 dontUseCmakeConfigure = true; 39 buildInputs = [ 40 mujoco 41 pybind11 42 ]; 43 propagatedBuildInputs = [ 44 absl-py 45 etils 46 glfw 47 numpy 48 pyopengl 49 ]; 50 51 pythonImportsCheck = [ "${pname}" ]; 52 53 env.MUJOCO_PATH = "${mujoco}"; 54 env.MUJOCO_PLUGIN_PATH = "${mujoco}/lib"; 55 env.MUJOCO_CMAKE_ARGS = lib.concatStringsSep " " [ 56 "-DMUJOCO_SIMULATE_USE_SYSTEM_GLFW=ON" 57 "-DMUJOCO_PYTHON_USE_SYSTEM_PYBIND11=ON" 58 ]; 59 60 preConfigure = 61 # Use non-system eigen3, lodepng, abseil: Remove mirror info and prefill 62 # dependency directory. $build from setuptools. 63 ( 64 let 65 # E.g. 3.11.2 -> "311" 66 pythonVersionMajorMinor = 67 with lib.versions; 68 "${major python.pythonVersion}${minor python.pythonVersion}"; 69 70 # E.g. "linux-aarch64" 71 platform = with stdenv.hostPlatform.parsed; "${kernel.name}-${cpu.name}"; 72 in 73 '' 74 ${perl}/bin/perl -0777 -i -pe "s/GIT_REPO\n.*\n.*GIT_TAG\n.*\n//gm" mujoco/CMakeLists.txt 75 ${perl}/bin/perl -0777 -i -pe "s/(FetchContent_Declare\(\n.*lodepng\n.*)(GIT_REPO.*\n.*GIT_TAG.*\n)(.*\))/\1\3/gm" mujoco/simulate/CMakeLists.txt 76 77 build="/build/${pname}-${version}/build/temp.${platform}-cpython-${pythonVersionMajorMinor}/" 78 mkdir -p $build/_deps 79 ln -s ${mujoco.pin.lodepng} $build/_deps/lodepng-src 80 ln -s ${mujoco.pin.eigen3} $build/_deps/eigen-src 81 ln -s ${mujoco.pin.abseil-cpp} $build/_deps/abseil-cpp-src 82 '' 83 ); 84 85 meta = { 86 description = "Python bindings for MuJoCo: a general purpose physics simulator"; 87 homepage = "https://mujoco.org/"; 88 changelog = "https://github.com/google-deepmind/mujoco/releases/tag/${version}"; 89 license = lib.licenses.asl20; 90 maintainers = with lib.maintainers; [ 91 GaetanLepage 92 tmplt 93 ]; 94 }; 95}