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