Version 2.1.4: Switch to GLAD, minor improvements to simulate.
PiperOrigin-RevId: 439277749 Change-Id: I741d1c499ae88753338fcc6d141a65e92e13023e
This commit is contained in:
+24
-49
@@ -15,69 +15,44 @@
|
||||
"""Python bindings for MuJoCo."""
|
||||
|
||||
import ctypes
|
||||
import ctypes.util
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
HEADERS_DIR = os.path.join(os.path.dirname(__file__), 'include')
|
||||
|
||||
_MUJOCO_GL_ENABLE = ('enable', 'enabled', 'on', 'true', '1' , '')
|
||||
_MUJOCO_GL_DISABLE = ('disable', 'disabled', 'off', 'false', '0')
|
||||
_MUJOCO_GL = os.environ.get('MUJOCO_GL', '').lower().strip()
|
||||
_MUJOCO_GL_IS_VALID = True
|
||||
|
||||
_SYSTEM = platform.system()
|
||||
if _SYSTEM == 'Linux':
|
||||
libglew_name = None
|
||||
if _MUJOCO_GL in _MUJOCO_GL_ENABLE + ('glfw', 'glx'):
|
||||
libglew_name = 'libglew.so'
|
||||
elif _MUJOCO_GL == 'egl':
|
||||
libglew_name = 'libglewegl.so'
|
||||
elif _MUJOCO_GL == 'osmesa':
|
||||
libglew_name = 'libglewosmesa.so'
|
||||
elif _MUJOCO_GL not in _MUJOCO_GL_DISABLE:
|
||||
_MUJOCO_GL_IS_VALID = False
|
||||
if libglew_name is not None:
|
||||
ctypes.CDLL(os.path.join(os.path.dirname(__file__), libglew_name),
|
||||
ctypes.RTLD_GLOBAL)
|
||||
ctypes.CDLL(
|
||||
os.path.join(os.path.dirname(__file__), 'libmujoco.so.2.1.3'),
|
||||
ctypes.RTLD_GLOBAL)
|
||||
else:
|
||||
ctypes.CDLL(
|
||||
os.path.join(os.path.dirname(__file__), 'libmujoco_nogl.so.2.1.3'),
|
||||
ctypes.RTLD_GLOBAL)
|
||||
elif _SYSTEM == 'Windows':
|
||||
if _MUJOCO_GL in _MUJOCO_GL_ENABLE + ('glfw', 'wgl'):
|
||||
ctypes.WinDLL(os.path.join(os.path.dirname(__file__), 'mujoco.dll'))
|
||||
elif _MUJOCO_GL in _MUJOCO_GL_DISABLE:
|
||||
ctypes.WinDLL(os.path.join(os.path.dirname(__file__), 'mujoco_nogl.dll'))
|
||||
else:
|
||||
_MUJOCO_GL_IS_VALID = False
|
||||
|
||||
if not _MUJOCO_GL_IS_VALID:
|
||||
raise RuntimeError(
|
||||
f'invalid value for environment variable MUJOCO_GL: {_MUJOCO_GL}')
|
||||
if _SYSTEM == 'Windows':
|
||||
ctypes.WinDLL(os.path.join(os.path.dirname(__file__), 'mujoco.dll'))
|
||||
|
||||
from mujoco._callbacks import *
|
||||
from mujoco._constants import *
|
||||
from mujoco._enums import *
|
||||
from mujoco._errors import *
|
||||
from mujoco._functions import *
|
||||
from mujoco._render import *
|
||||
from mujoco._structs import *
|
||||
|
||||
# pylint: disable=g-import-not-at-top
|
||||
if _MUJOCO_GL not in _MUJOCO_GL_DISABLE:
|
||||
from mujoco._render import *
|
||||
if _SYSTEM != 'Linux':
|
||||
from mujoco.glfw import GLContext
|
||||
_MUJOCO_GL = os.environ.get('MUJOCO_GL', '').lower().strip()
|
||||
if _MUJOCO_GL not in ('disable', 'disabled', 'off', 'false', '0'):
|
||||
_VALID_MUJOCO_GL = ('enable', 'enabled', 'on', 'true', '1' , 'glfw', '')
|
||||
if _SYSTEM == 'Linux':
|
||||
_VALID_MUJOCO_GL += ('glx', 'egl', 'osmesa')
|
||||
elif _SYSTEM == 'Windows':
|
||||
_VALID_MUJOCO_GL += ('wgl',)
|
||||
elif _SYSTEM == 'Darwin':
|
||||
_VALID_MUJOCO_GL += ('cgl',)
|
||||
if _MUJOCO_GL not in _VALID_MUJOCO_GL:
|
||||
raise RuntimeError(
|
||||
f'invalid value for environment variable MUJOCO_GL: {_MUJOCO_GL}')
|
||||
|
||||
if _SYSTEM == 'Linux' and _MUJOCO_GL == 'osmesa':
|
||||
from mujoco.osmesa import GLContext
|
||||
elif _SYSTEM == 'Linux' and _MUJOCO_GL == 'egl':
|
||||
from mujoco.egl import GLContext
|
||||
else:
|
||||
_dl_handle = ctypes.CDLL(None)
|
||||
if hasattr(_dl_handle, 'OSMesaCreateContextExt'):
|
||||
from mujoco.osmesa import GLContext
|
||||
elif hasattr(_dl_handle, 'eglCreateContext'):
|
||||
from mujoco.egl import GLContext
|
||||
else:
|
||||
from mujoco.glfw import GLContext
|
||||
from mujoco.glfw import GLContext
|
||||
|
||||
HEADERS_DIR = os.path.join(os.path.dirname(__file__), 'include')
|
||||
|
||||
__version__ = mj_versionString() # pylint: disable=undefined-variable
|
||||
|
||||
Reference in New Issue
Block a user