at master 3.1 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 7 # build-system 8 cmake, 9 ninja, 10 pybind11, 11 setuptools, 12 13 # buildInputs 14 SDL2, 15 opencv, 16 zlib, 17 18 # dependencies 19 importlib-resources, 20 numpy, 21 typing-extensions, 22 jax, 23 24 # tests 25 gymnasium, 26 opencv-python, 27 pytestCheckHook, 28 29 # Whether to enable recently added vector environments: 30 # https://github.com/Farama-Foundation/Arcade-Learning-Environment/blob/v0.11.0/docs/vector-environment.md 31 # FIXME: Disabled by default as it mysteriously causes stable-baselines3's tests to hang indefinitely. 32 withVectorEnv ? false, 33}: 34 35buildPythonPackage rec { 36 pname = "ale-py"; 37 version = "0.11.2"; 38 pyproject = true; 39 40 src = fetchFromGitHub { 41 owner = "Farama-Foundation"; 42 repo = "Arcade-Learning-Environment"; 43 tag = "v${version}"; 44 hash = "sha256-4IkjW8HX21uBEHFtb3qETxco6FfDMgLbG1BDHWwvn58="; 45 }; 46 47 build-system = [ 48 cmake 49 ninja 50 pybind11 51 setuptools 52 ]; 53 54 buildInputs = [ 55 SDL2 56 zlib 57 ] 58 ++ lib.optionals withVectorEnv [ 59 opencv 60 ]; 61 62 dependencies = [ 63 gymnasium 64 importlib-resources 65 numpy 66 typing-extensions 67 ] 68 ++ lib.optionals stdenv.hostPlatform.isLinux [ 69 jax 70 ]; 71 72 postPatch = 73 # Relax the pybind11 version 74 '' 75 substituteInPlace src/ale/python/CMakeLists.txt \ 76 --replace-fail \ 77 'find_package(pybind11 ''${PYBIND11_VER} QUIET)' \ 78 'find_package(pybind11 QUIET)' 79 '' 80 + lib.optionalString (!withVectorEnv) '' 81 substituteInPlace setup.py \ 82 --replace-fail \ 83 "-DBUILD_VECTOR_LIB=ON" \ 84 "-DBUILD_VECTOR_LIB=OFF" 85 ''; 86 87 dontUseCmakeConfigure = true; 88 89 pythonImportsCheck = [ "ale_py" ]; 90 91 doCheck = false; 92 93 nativeCheckInputs = [ 94 gymnasium 95 pytestCheckHook 96 ] 97 + lib.optionals withVectorEnv [ 98 opencv-python 99 ]; 100 101 disabledTests = [ 102 # Fatal Python error: Aborted 103 # line 414 in test_display_screen 104 "test_display_screen" 105 106 # test_atari_env.py tests fail on the majority of the environments because the ROM are missing. 107 # The user is expected to manually download the roms: 108 # https://github.com/Farama-Foundation/Arcade-Learning-Environment/blob/v0.9.0/docs/faq.md#i-downloaded-ale-and-i-installed-it-successfully-but-i-cannot-find-any-rom-file-at-roms-do-i-have-to-get-them-somewhere-else 109 "test_check_env" 110 "test_reset_step_shapes" 111 "test_rollout_consistency" 112 "test_sound_obs" 113 ]; 114 115 meta = { 116 description = "Simple framework that allows researchers and hobbyists to develop AI agents for Atari 2600 games"; 117 mainProgram = "ale-import-roms"; 118 homepage = "https://github.com/mgbellemare/Arcade-Learning-Environment"; 119 changelog = "https://github.com/Farama-Foundation/Arcade-Learning-Environment/releases/tag/v${version}"; 120 license = lib.licenses.gpl2; 121 maintainers = with lib.maintainers; [ billhuang ]; 122 badPlatforms = [ 123 # FAILED: src/ale/libale.a 124 # /bin/sh: CMAKE_CXX_COMPILER_AR-NOTFOUND: command not found 125 lib.systems.inspect.patterns.isDarwin 126 ]; 127 }; 128}