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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
# build-system
setuptools,
# dependencies
cloudpickle,
numpy,
gym-notices,
# tests
moviepy,
pybox2d,
pygame,
pytestCheckHook,
opencv-python,
}:
buildPythonPackage rec {
pname = "gym";
version = "0.26.2";
pyproject = true;
src = fetchFromGitHub {
owner = "openai";
repo = "gym";
tag = version;
hash = "sha256-uJgm8l1SxIRC5PV6BIH/ht/1ucGT5UaUhkFMdusejgA=";
};
# Fix numpy2 compatibility
postPatch = ''
substituteInPlace gym/envs/classic_control/acrobot.py \
--replace-fail "np.float_" "np.float64"
substituteInPlace gym/utils/passive_env_checker.py \
--replace-fail "np.bool8" "np.bool"
substituteInPlace tests/envs/test_action_dim_check.py \
--replace-fail "np.cast[dtype](OOB_VALUE)" "np.asarray(OOB_VALUE, dtype=dtype)" \
--replace-fail "np.alltrue" "np.all"
substituteInPlace tests/spaces/test_box.py \
--replace-fail "np.bool8" "np.bool" \
--replace-fail "np.complex_" "np.complex128"
substituteInPlace tests/wrappers/test_record_episode_statistics.py \
--replace-fail "np.alltrue" "np.all"
'';
build-system = [
setuptools
];
dependencies = [
cloudpickle
numpy
gym-notices
];
pythonImportsCheck = [ "gym" ];
nativeCheckInputs = [
moviepy
opencv-python
pybox2d
pygame
pytestCheckHook
];
preCheck = ''
export SDL_VIDEODRIVER=dummy
'';
disabledTests = [
# TypeError: Converting from sequence to b2Vec2, expected int/float arguments index 0
"test_box_actions_out_of_bound"
"test_env_determinism_rollout"
"test_envs_pass_env_checker"
"test_frame_stack"
"test_make_autoreset_true"
"test_passive_checker_wrapper_warnings"
"test_pickle_env"
"test_render_modes"
# TypeError: in method 'b2RevoluteJoint___SetMotorSpeed', argument 2 of type 'float32'
"test_box_actions_out_of_bound"
# TypeError: exceptions must be derived from Warning, not <class 'NoneType'>
"test_dict_init"
# ValueError: setting an array element with a sequence.
# The requested array has an inhomogeneous shape after 1 dimensions.
# The detected shape was (2,) + inhomogeneous part
"test_sample_contains"
# segfault
"test_record_video"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# Fatal Python error: Aborted
# gym/envs/classic_control/cartpole.py", line 227 in render
"test_autoclose"
"test_call_async_vector_env"
"test_call_sync_vector_env"
"test_human_rendering"
"test_make_render_mode"
"test_order_enforcing"
"test_record_simple"
"test_record_video_reset"
"test_record_video_step_trigger"
"test_record_video_using_default_trigger"
"test_record_video_within_vecto"
"test_text_envs"
];
disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [
# Fatal Python error: Aborted
# gym/utils/play.py", line 62 in __init__
"tests/utils/test_play.py"
];
meta = {
description = "Toolkit for developing and comparing your reinforcement learning agents";
homepage = "https://www.gymlibrary.dev/";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ GaetanLepage ];
};
}
|