2024-01-25 14:12:00 +00:00
|
|
|
{ absl-py
|
|
|
|
, buildPythonPackage
|
2024-01-02 11:29:13 +00:00
|
|
|
, cmake
|
2024-01-25 14:12:00 +00:00
|
|
|
, etils
|
2024-01-02 11:29:13 +00:00
|
|
|
, fetchPypi
|
|
|
|
, glfw
|
|
|
|
, lib
|
|
|
|
, mujoco
|
|
|
|
, numpy
|
|
|
|
, perl
|
|
|
|
, pybind11
|
2024-01-25 14:12:00 +00:00
|
|
|
, pyopengl
|
2024-01-02 11:29:13 +00:00
|
|
|
, python
|
|
|
|
, setuptools
|
2024-01-25 14:12:00 +00:00
|
|
|
, stdenv
|
2024-01-02 11:29:13 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "mujoco";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "3.1.4";
|
2024-01-02 11:29:13 +00:00
|
|
|
|
|
|
|
pyproject = true;
|
|
|
|
|
|
|
|
# We do not fetch from the repository because the PyPi tarball is
|
|
|
|
# impurely build via
|
|
|
|
# <https://github.com/google-deepmind/mujoco/blob/main/python/make_sdist.sh>
|
|
|
|
# in the project's CI.
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2024-04-21 15:54:59 +00:00
|
|
|
hash = "sha256-GdeL1zMri/ArjXyjXTgan48WVPTHDA1/SZxtTYB8QFk=";
|
2024-01-02 11:29:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake setuptools ];
|
|
|
|
dontUseCmakeConfigure = true;
|
|
|
|
buildInputs = [ mujoco pybind11 ];
|
2024-01-25 14:12:00 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
absl-py
|
|
|
|
etils
|
|
|
|
glfw
|
|
|
|
numpy
|
|
|
|
pyopengl
|
|
|
|
];
|
2024-01-02 11:29:13 +00:00
|
|
|
|
|
|
|
pythonImportsCheck = [ "${pname}" ];
|
|
|
|
|
|
|
|
env.MUJOCO_PATH = "${mujoco}";
|
|
|
|
env.MUJOCO_PLUGIN_PATH = "${mujoco}/lib";
|
|
|
|
env.MUJOCO_CMAKE_ARGS = lib.concatStringsSep " " [
|
|
|
|
"-DMUJOCO_SIMULATE_USE_SYSTEM_GLFW=ON"
|
|
|
|
"-DMUJOCO_PYTHON_USE_SYSTEM_PYBIND11=ON"
|
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure =
|
|
|
|
# Use non-system eigen3, lodepng, abseil: Remove mirror info and prefill
|
|
|
|
# dependency directory. $build from setuptools.
|
|
|
|
(let
|
|
|
|
# E.g. 3.11.2 -> "311"
|
|
|
|
pythonVersionMajorMinor = with lib.versions;
|
|
|
|
"${major python.pythonVersion}${minor python.pythonVersion}";
|
2024-01-25 14:12:00 +00:00
|
|
|
|
|
|
|
# E.g. "linux-aarch64"
|
|
|
|
platform = with stdenv.hostPlatform.parsed;
|
|
|
|
"${kernel.name}-${cpu.name}";
|
2024-01-02 11:29:13 +00:00
|
|
|
in ''
|
|
|
|
${perl}/bin/perl -0777 -i -pe "s/GIT_REPO\n.*\n.*GIT_TAG\n.*\n//gm" mujoco/CMakeLists.txt
|
|
|
|
${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
|
|
|
|
|
2024-01-25 14:12:00 +00:00
|
|
|
build="/build/${pname}-${version}/build/temp.${platform}-cpython-${pythonVersionMajorMinor}/"
|
2024-01-02 11:29:13 +00:00
|
|
|
mkdir -p $build/_deps
|
|
|
|
ln -s ${mujoco.pin.lodepng} $build/_deps/lodepng-src
|
|
|
|
ln -s ${mujoco.pin.eigen3} $build/_deps/eigen-src
|
|
|
|
ln -s ${mujoco.pin.abseil-cpp} $build/_deps/abseil-cpp-src
|
|
|
|
'');
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description =
|
|
|
|
"Python bindings for MuJoCo: a general purpose physics simulator.";
|
|
|
|
homepage = "https://mujoco.org/";
|
2024-01-25 14:12:00 +00:00
|
|
|
changelog = "https://github.com/google-deepmind/mujoco/releases/tag/${version}";
|
2024-01-02 11:29:13 +00:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ tmplt ];
|
|
|
|
};
|
|
|
|
}
|