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