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 setuptools
43 wheel
44 pybind11
45 ];
46
47 buildInputs = [
48 zlib
49 SDL2
50 ];
51
52 propagatedBuildInputs = [
53 typing-extensions
54 importlib-resources
55 numpy
56 ] ++ lib.optionals (pythonOlder "3.10") [
57 importlib-metadata
58 ];
59
60 nativeCheckInputs = [
61 pytestCheckHook
62 gym
63 ];
64
65 postPatch = ''
66 substituteInPlace pyproject.toml \
67 --replace 'dynamic = ["version"]' 'version = "${version}"'
68 substituteInPlace setup.py \
69 --replace 'subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], cwd=here)' 'b"${src.rev}"'
70 '';
71
72 dontUseCmakeConfigure = true;
73
74 pythonImportsCheck = [ "ale_py" ];
75
76 meta = with lib; {
77 description = "a simple framework that allows researchers and hobbyists to develop AI agents for Atari 2600 games";
78 homepage = "https://github.com/mgbellemare/Arcade-Learning-Environment";
79 license = licenses.gpl2;
80 maintainers = with maintainers; [ billhuang ];
81 broken = stdenv.isDarwin; # fails to link with missing library
82 };
83}