1{ buildPythonPackage
2, SDL2
3, cmake
4, fetchFromGitHub
5, git
6, gym
7, importlib-metadata
8, importlib-resources
9, lib
10, ninja
11, numpy
12, pybind11
13, pytestCheckHook
14, python
15, pythonOlder
16, setuptools
17, stdenv
18, typing-extensions
19, wheel
20, zlib
21}:
22
23buildPythonPackage rec {
24 pname = "ale-py";
25 version = "0.8.1";
26 format = "pyproject";
27
28 src = fetchFromGitHub {
29 owner = "mgbellemare";
30 repo = "Arcade-Learning-Environment";
31 rev = "refs/tags/v${version}";
32 hash = "sha256-B2AxhlzvBy1lJ3JttJjImgTjMtEUyZBv+xHU2IC7BVE=";
33 };
34
35 patches = [
36 # don't download pybind11, use local pybind11
37 ./cmake-pybind11.patch
38 ];
39
40 nativeBuildInputs = [
41 cmake
42 ninja
43 setuptools
44 wheel
45 pybind11
46 ];
47
48 buildInputs = [
49 zlib
50 SDL2
51 ];
52
53 propagatedBuildInputs = [
54 typing-extensions
55 importlib-resources
56 numpy
57 ] ++ lib.optionals (pythonOlder "3.10") [
58 importlib-metadata
59 ];
60
61 nativeCheckInputs = [
62 pytestCheckHook
63 gym
64 ];
65
66 postPatch = ''
67 substituteInPlace pyproject.toml \
68 --replace 'dynamic = ["version"]' 'version = "${version}"'
69 substituteInPlace setup.py \
70 --replace 'subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], cwd=here)' 'b"${src.rev}"'
71 '';
72
73 dontUseCmakeConfigure = true;
74
75 pythonImportsCheck = [ "ale_py" ];
76
77 meta = with lib; {
78 description = "a simple framework that allows researchers and hobbyists to develop AI agents for Atari 2600 games";
79 homepage = "https://github.com/mgbellemare/Arcade-Learning-Environment";
80 license = licenses.gpl2;
81 maintainers = with maintainers; [ billhuang ];
82 broken = stdenv.isDarwin; # fails to link with missing library
83 };
84}