1{
2 lib,
3 buildPythonPackage,
4 pythonOlder,
5 fetchFromGitHub,
6
7 # build-system
8 cmake,
9 ninja,
10 pybind11,
11 setuptools,
12 wheel,
13
14 # buildInputs
15 SDL2,
16 zlib,
17
18 # dependencies
19 importlib-resources,
20 numpy,
21 typing-extensions,
22 importlib-metadata,
23
24 # checks
25 gymnasium,
26 pytestCheckHook,
27
28 stdenv,
29}:
30
31buildPythonPackage rec {
32 pname = "ale-py";
33 version = "0.10.1";
34 pyproject = true;
35
36 src = fetchFromGitHub {
37 owner = "Farama-Foundation";
38 repo = "Arcade-Learning-Environment";
39 rev = "refs/tags/v${version}";
40 hash = "sha256-MDMCYnyLZYbQXwyr5VuPeVEop825nD++yQ7hhsW4BX8=";
41 };
42
43 build-system = [
44 cmake
45 ninja
46 pybind11
47 setuptools
48 wheel
49 ];
50
51 buildInputs = [
52 SDL2
53 zlib
54 ];
55
56 dependencies = [
57 importlib-resources
58 numpy
59 typing-extensions
60 ] ++ lib.optionals (pythonOlder "3.10") [ importlib-metadata ];
61
62 postPatch =
63 # Relax the pybind11 version
64 ''
65 substituteInPlace src/ale/python/CMakeLists.txt \
66 --replace-fail 'find_package(pybind11 ''${PYBIND11_VER} QUIET)' 'find_package(pybind11 QUIET)'
67 '';
68
69 dontUseCmakeConfigure = true;
70
71 pythonImportsCheck = [ "ale_py" ];
72
73 nativeCheckInputs = [
74 gymnasium
75 pytestCheckHook
76 ];
77
78 # test_atari_env.py::test_check_env fails on the majority of the environments because the ROM are missing.
79 # The user is expected to manually download the roms:
80 # 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
81 disabledTests = [ "test_check_env" ];
82
83 meta = {
84 description = "Simple framework that allows researchers and hobbyists to develop AI agents for Atari 2600 games";
85 mainProgram = "ale-import-roms";
86 homepage = "https://github.com/mgbellemare/Arcade-Learning-Environment";
87 changelog = "https://github.com/Farama-Foundation/Arcade-Learning-Environment/releases/tag/v${version}";
88 license = lib.licenses.gpl2;
89 maintainers = with lib.maintainers; [ billhuang ];
90 broken = stdenv.hostPlatform.isDarwin; # fails to link with missing library
91 };
92}