|
1 | 1 | { |
2 | 2 | lib, |
| 3 | + stdenv, |
3 | 4 | buildPythonPackage, |
4 | 5 | fetchFromGitHub, |
5 | | - numpy, |
| 6 | + |
| 7 | + # build-system |
| 8 | + setuptools, |
| 9 | + |
| 10 | + # dependencies |
6 | 11 | cloudpickle, |
| 12 | + numpy, |
7 | 13 | gym-notices, |
8 | 14 | importlib-metadata, |
9 | 15 | pythonOlder, |
| 16 | + |
| 17 | + # tests |
| 18 | + moviepy, |
| 19 | + pybox2d, |
| 20 | + pygame, |
| 21 | + pytestCheckHook, |
| 22 | + opencv-python, |
10 | 23 | }: |
11 | 24 |
|
12 | 25 | buildPythonPackage rec { |
13 | 26 | pname = "gym"; |
14 | 27 | version = "0.26.2"; |
15 | | - format = "setuptools"; |
| 28 | + pyproject = true; |
16 | 29 |
|
17 | 30 | src = fetchFromGitHub { |
18 | 31 | owner = "openai"; |
19 | | - repo = pname; |
| 32 | + repo = "gym"; |
20 | 33 | tag = version; |
21 | 34 | hash = "sha256-uJgm8l1SxIRC5PV6BIH/ht/1ucGT5UaUhkFMdusejgA="; |
22 | 35 | }; |
23 | 36 |
|
24 | | - propagatedBuildInputs = [ |
| 37 | + # Fix numpy2 compatibility |
| 38 | + postPatch = '' |
| 39 | + substituteInPlace gym/envs/classic_control/acrobot.py \ |
| 40 | + --replace-fail "np.float_" "np.float64" |
| 41 | +
|
| 42 | + substituteInPlace gym/utils/passive_env_checker.py \ |
| 43 | + --replace-fail "np.bool8" "np.bool" |
| 44 | +
|
| 45 | + substituteInPlace tests/envs/test_action_dim_check.py \ |
| 46 | + --replace-fail "np.cast[dtype](OOB_VALUE)" "np.asarray(OOB_VALUE, dtype=dtype)" \ |
| 47 | + --replace-fail "np.alltrue" "np.all" |
| 48 | +
|
| 49 | + substituteInPlace tests/spaces/test_box.py \ |
| 50 | + --replace-fail "np.bool8" "np.bool" \ |
| 51 | + --replace-fail "np.complex_" "np.complex128" |
| 52 | +
|
| 53 | + substituteInPlace tests/wrappers/test_record_episode_statistics.py \ |
| 54 | + --replace-fail "np.alltrue" "np.all" |
| 55 | + ''; |
| 56 | + |
| 57 | + build-system = [ |
| 58 | + setuptools |
| 59 | + ]; |
| 60 | + |
| 61 | + dependencies = [ |
25 | 62 | cloudpickle |
26 | 63 | numpy |
27 | 64 | gym-notices |
28 | 65 | ] ++ lib.optionals (pythonOlder "3.10") [ importlib-metadata ]; |
29 | 66 |
|
30 | | - # The test needs MuJoCo that is not free library. |
31 | | - doCheck = false; |
32 | | - |
33 | 67 | pythonImportsCheck = [ "gym" ]; |
34 | 68 |
|
35 | | - meta = with lib; { |
| 69 | + nativeCheckInputs = [ |
| 70 | + moviepy |
| 71 | + opencv-python |
| 72 | + pybox2d |
| 73 | + pygame |
| 74 | + pytestCheckHook |
| 75 | + ]; |
| 76 | + |
| 77 | + disabledTests = |
| 78 | + [ |
| 79 | + # TypeError: Converting from sequence to b2Vec2, expected int/float arguments index 0 |
| 80 | + "test_box_actions_out_of_bound" |
| 81 | + "test_env_determinism_rollout" |
| 82 | + "test_envs_pass_env_checker" |
| 83 | + "test_frame_stack" |
| 84 | + "test_make_autoreset_true" |
| 85 | + "test_passive_checker_wrapper_warnings" |
| 86 | + "test_pickle_env" |
| 87 | + "test_render_modes" |
| 88 | + |
| 89 | + # TypeError: in method 'b2RevoluteJoint___SetMotorSpeed', argument 2 of type 'float32' |
| 90 | + "test_box_actions_out_of_bound" |
| 91 | + |
| 92 | + # TypeError: exceptions must be derived from Warning, not <class 'NoneType'> |
| 93 | + "test_dict_init" |
| 94 | + |
| 95 | + # ValueError: setting an array element with a sequence. |
| 96 | + # The requested array has an inhomogeneous shape after 1 dimensions. |
| 97 | + # The detected shape was (2,) + inhomogeneous part |
| 98 | + "test_sample_contains" |
| 99 | + ] |
| 100 | + ++ lib.optionals stdenv.hostPlatform.isDarwin [ |
| 101 | + # Fatal Python error: Aborted |
| 102 | + # gym/envs/classic_control/cartpole.py", line 227 in render |
| 103 | + "test_autoclose" |
| 104 | + "test_call_async_vector_env" |
| 105 | + "test_call_sync_vector_env" |
| 106 | + "test_human_rendering" |
| 107 | + "test_make_render_mode" |
| 108 | + "test_order_enforcing" |
| 109 | + "test_record_simple" |
| 110 | + "test_record_video_reset" |
| 111 | + "test_record_video_step_trigger" |
| 112 | + "test_record_video_using_default_trigger" |
| 113 | + "test_record_video_within_vecto" |
| 114 | + "test_text_envs" |
| 115 | + ]; |
| 116 | + |
| 117 | + disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [ |
| 118 | + # Fatal Python error: Aborted |
| 119 | + # gym/utils/play.py", line 62 in __init__ |
| 120 | + "tests/utils/test_play.py" |
| 121 | + ]; |
| 122 | + |
| 123 | + meta = { |
36 | 124 | description = "Toolkit for developing and comparing your reinforcement learning agents"; |
37 | 125 | homepage = "https://www.gymlibrary.dev/"; |
38 | | - license = licenses.mit; |
39 | | - maintainers = with maintainers; [ hyphon81 ]; |
| 126 | + license = lib.licenses.mit; |
| 127 | + maintainers = with lib.maintainers; [ GaetanLepage ]; |
40 | 128 | }; |
41 | 129 | } |
0 commit comments