1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 setuptools,
6 wheel,
7 numpy,
8 pip,
9 termcolor,
10 pytestCheckHook,
11 torch,
12 fetchpatch2,
13}:
14
15buildPythonPackage rec {
16 pname = "rlcard";
17 version = "1.0.7";
18 pyproject = true;
19
20 src = fetchFromGitHub {
21 owner = "datamllab";
22 repo = "rlcard";
23 tag = version;
24 hash = "sha256-SWj6DBItQzSM+nioV54a350Li7tbBaVXsQxNAqVgB0k=";
25 };
26
27 patches = [
28 # Remove distutils to make it compatible with Python 3.12
29 # https://github.com/datamllab/rlcard/pull/323
30 (fetchpatch2 {
31 name = "remove-distutils.patch";
32 url = "https://github.com/datamllab/rlcard/commit/e44378157aaf229ffe2aaef9fafe500c2844045e.patch";
33 hash = "sha256-aQS4d9ETj6pDv26G77mC+0xHQMA2hjspAxtAyz0rA6Y=";
34 })
35 ];
36
37 build-system = [
38 setuptools
39 wheel
40 ];
41
42 dependencies = [
43 numpy
44 # pip is required at runtime (https://github.com/datamllab/rlcard/blob/1.0.7/rlcard/utils/utils.py#L10)
45 pip
46 termcolor
47 ];
48
49 pythonImportsCheck = [ "rlcard" ];
50
51 nativeCheckInputs = [
52 pytestCheckHook
53 torch
54 ];
55
56 disabledTests = [
57 # AttributeError: module 'numpy' has no attribute 'int'.
58 # https://github.com/datamllab/rlcard/issues/266
59 "test_decode_action"
60 "test_get_legal_actions"
61 "test_get_perfect_information"
62 "test_get_player_id"
63 "test_init_game"
64 "test_is_deterministic"
65 "test_proceed_game"
66 "test_reset_and_extract_state"
67 "test_run"
68 "test_step"
69 "test_step"
70 "test_step_back"
71 "test_step_back"
72
73 # ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 3 dimensions. The detected shape was (1, 1, 5) + inhomogeneous part.
74 "test_reorganize"
75 ];
76
77 meta = with lib; {
78 description = "Reinforcement Learning / AI Bots in Card (Poker) Games - Blackjack, Leduc, Texas, DouDizhu, Mahjong, UNO";
79 homepage = "https://github.com/datamllab/rlcard";
80 changelog = "https://github.com/datamllab/rlcard/releases/tag/${version}";
81 license = licenses.mit;
82 maintainers = with maintainers; [ GaetanLepage ];
83 };
84}