Files
nixpkgs/pkgs/development/python-modules/gym/default.nix
T
Guilhem Saurel e82f2d283c python3Packages.gym: disable test that segfault
```
gym> tests/wrappers/test_record_video.py Fatal Python error: Segmentation fault
gym>
gym> Thread 0x00007ffea0f716c0 (most recent call first):
gym>   File "/nix/store/qlz1jypzdb320jp0ci0igxg2ghf0974d-python3-3.12.11/lib/python3.12/threading.py", line 359 in wait
gym>   File "/nix/store/qlz1jypzdb320jp0ci0igxg2ghf0974d-python3-3.12.11/lib/python3.12/threading.py", line 655 in wait
gym>   File "/nix/store/vadca0pz5kfvwxaldqzmjxnhm9zz3sb8-python3.12-tqdm-4.67.1/lib/python3.12/site-packages/tqdm/_monitor.py", line 60 in run
gym>   File "/nix/store/qlz1jypzdb320jp0ci0igxg2ghf0974d-python3-3.12.11/lib/python3.12/threading.py", line 1075 in _bootstrap_inner
gym>   File "/nix/store/qlz1jypzdb320jp0ci0igxg2ghf0974d-python3-3.12.11/lib/python3.12/threading.py", line 1032 in _bootstrap
gym>
gym> Current thread 0x00007ffff7f86740 (most recent call first):
gym>   File "/build/source/gym/envs/classic_control/cartpole.py", line 250 in render
gym>   File "/build/source/gym/wrappers/order_enforcing.py", line 51 in render
gym>   File "/build/source/gym/core.py", line 329 in render
gym>   File "/build/source/gym/wrappers/render_collection.py", line 33 in step
gym>   File "/build/source/gym/wrappers/record_video.py", line 142 in step
gym>   File "/build/source/tests/wrappers/test_record_video.py", line 16 in test_record_video_using_default_trigger
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/_pytest/python.py", line 157 in pytest_pyfunc_call
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_callers.py", line 121 in _multicall
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_hooks.py", line 512 in __call__
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/_pytest/python.py", line 1671 in runtest
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/_pytest/runner.py", line 178 in pytest_runtest_call
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_callers.py", line 121 in _multicall
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_hooks.py", line 512 in __call__
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/_pytest/runner.py", line 246 in <lambda>
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/_pytest/runner.py", line 344 in from_call
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/_pytest/runner.py", line 245 in call_and_report
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/_pytest/runner.py", line 136 in runtestprotocol
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/_pytest/runner.py", line 117 in pytest_runtest_protocol
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_callers.py", line 121 in _multicall
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_hooks.py", line 512 in __call__
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/_pytest/main.py", line 367 in pytest_runtestloop
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_callers.py", line 121 in _multicall
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_hooks.py", line 512 in __call__
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/_pytest/main.py", line 343 in _main
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/_pytest/main.py", line 289 in wrap_session
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/_pytest/main.py", line 336 in pytest_cmdline_main
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_callers.py", line 121 in _multicall
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
gym>   File "/nix/store/56r3an7jdvdk2086cdm8m4yifgp8wy2p-python3.12-pluggy-1.6.0/lib/python3.12/site-packages/pluggy/_hooks.py", line 512 in __call__
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/_pytest/config/__init__.py", line 175 in main
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/_pytest/config/__init__.py", line 201 in console_main
gym>   File "/nix/store/y35d39jdxlf8nfa6jvl6v084sa8kh73p-python3.12-pytest-8.4.2/lib/python3.12/site-packages/pytest/__main__.py", line 9 in <module>
gym>   File "<frozen runpy>", line 88 in _run_code
gym>   File "<frozen runpy>", line 198 in _run_module_as_main
```
2025-10-30 15:31:12 +01:00

137 lines
3.3 KiB
Nix

{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
# build-system
setuptools,
# dependencies
cloudpickle,
numpy,
gym-notices,
importlib-metadata,
pythonOlder,
# 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
]
++ lib.optionals (pythonOlder "3.10") [ importlib-metadata ];
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 ];
};
}