1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 7 # build-system 8 setuptools, 9 10 # dependencies 11 cloudpickle, 12 farama-notifications, 13 numpy, 14 typing-extensions, 15 pythonOlder, 16 importlib-metadata, 17 18 # tests 19 dill, 20 flax, 21 jax, 22 jaxlib, 23 matplotlib, 24 mujoco, 25 moviepy, 26 opencv4, 27 pybox2d, 28 pygame, 29 pytestCheckHook, 30 scipy, 31}: 32 33buildPythonPackage rec { 34 pname = "gymnasium"; 35 version = "1.1.1"; 36 37 pyproject = true; 38 39 src = fetchFromGitHub { 40 owner = "Farama-Foundation"; 41 repo = "gymnasium"; 42 tag = "v${version}"; 43 hash = "sha256-5uE6ANOxVCeV5GMDGG+0j5JY2t++jw+mZFFHGl+sTfw="; 44 }; 45 46 build-system = [ setuptools ]; 47 48 dependencies = [ 49 cloudpickle 50 farama-notifications 51 numpy 52 typing-extensions 53 ] ++ lib.optionals (pythonOlder "3.10") [ importlib-metadata ]; 54 55 pythonImportsCheck = [ "gymnasium" ]; 56 57 nativeCheckInputs = [ 58 dill 59 flax 60 jax 61 jaxlib 62 matplotlib 63 moviepy 64 mujoco 65 opencv4 66 pybox2d 67 pygame 68 pytestCheckHook 69 scipy 70 ]; 71 72 # if `doCheck = true` on Darwin, `jaxlib` is evaluated, which is both 73 # marked as broken and throws an error during evaluation if the package is evaluated anyway. 74 # disabling checks on Darwin avoids this and allows the package to be built. 75 # if jaxlib is ever fixed on Darwin, remove this. 76 doCheck = !stdenv.hostPlatform.isDarwin; 77 78 disabledTestPaths = [ 79 # Unpackaged `mujoco-py` (Openai's mujoco) is required for these tests. 80 "tests/envs/mujoco/test_mujoco_custom_env.py" 81 "tests/envs/mujoco/test_mujoco_rendering.py" 82 "tests/envs/mujoco/test_mujoco_v5.py" 83 84 # Rendering tests failing in the sandbox 85 "tests/wrappers/vector/test_human_rendering.py" 86 87 # These tests need to write on the filesystem which cause them to fail. 88 "tests/utils/test_save_video.py" 89 "tests/wrappers/test_record_video.py" 90 ]; 91 92 disabledTests = [ 93 # Fails since jax 0.6.0 94 # Fixed on master https://github.com/Farama-Foundation/Gymnasium/commit/94019feee1a0f945b9569cddf62780f4e1a224a5 95 # TODO: un-skip at the next release 96 "test_all_env_api" 97 "test_env_determinism_rollout" 98 "test_jax_to_numpy_wrapper" 99 "test_pickle_env" 100 "test_roundtripping" 101 102 # Succeeds for most environments but `test_render_modes[Reacher-v4]` fails because it requires 103 # OpenGL access which is not possible inside the sandbox. 104 "test_render_mode" 105 ]; 106 107 meta = { 108 description = "Standard API for reinforcement learning and a diverse set of reference environments (formerly Gym)"; 109 homepage = "https://github.com/Farama-Foundation/Gymnasium"; 110 changelog = "https://github.com/Farama-Foundation/Gymnasium/releases/tag/v${version}"; 111 license = lib.licenses.mit; 112 maintainers = with lib.maintainers; [ GaetanLepage ]; 113 }; 114}