about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/ale-py/default.nix
blob: 0b5d9649f476fd90d0792d7760861e0e393e55c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{ buildPythonPackage
, SDL2
, cmake
, fetchFromGitHub
, git
, gym
, importlib-metadata
, importlib-resources
, lib
, ninja
, numpy
, pybind11
, pytestCheckHook
, python
, pythonOlder
, setuptools
, stdenv
, typing-extensions
, wheel
, zlib
}:

buildPythonPackage rec {
  pname = "ale-py";
  version = "0.8.1";
  format = "pyproject";

  src = fetchFromGitHub {
    owner = "mgbellemare";
    repo = "Arcade-Learning-Environment";
    rev = "refs/tags/v${version}";
    hash = "sha256-B2AxhlzvBy1lJ3JttJjImgTjMtEUyZBv+xHU2IC7BVE=";
  };

  patches = [
    # don't download pybind11, use local pybind11
    ./cmake-pybind11.patch
  ];

  nativeBuildInputs = [
    cmake
    setuptools
    wheel
    pybind11
  ];

  buildInputs = [
    zlib
    SDL2
  ];

  propagatedBuildInputs = [
    typing-extensions
    importlib-resources
    numpy
  ] ++ lib.optionals (pythonOlder "3.10") [
    importlib-metadata
  ];

  nativeCheckInputs = [
    pytestCheckHook
    gym
  ];

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace 'dynamic = ["version"]' 'version = "${version}"'
    substituteInPlace setup.py \
      --replace 'subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], cwd=here)' 'b"${src.rev}"'
  '';

  dontUseCmakeConfigure = true;

  pythonImportsCheck = [ "ale_py" ];

  meta = with lib; {
    description = "a simple framework that allows researchers and hobbyists to develop AI agents for Atari 2600 games";
    homepage = "https://github.com/mgbellemare/Arcade-Learning-Environment";
    license = licenses.gpl2;
    maintainers = with maintainers; [ billhuang ];
    broken = stdenv.isDarwin; # fails to link with missing library
  };
}