From 691ea007160708f3456a2729ea24eb4c028184ed Mon Sep 17 00:00:00 2001 From: Kevin Zakka Date: Sat, 26 Mar 2022 19:03:03 -0700 Subject: [PATCH 1/3] Add module level version dunder. --- python/mujoco/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/python/mujoco/__init__.py b/python/mujoco/__init__.py index 63e4e598..be11fe22 100644 --- a/python/mujoco/__init__.py +++ b/python/mujoco/__init__.py @@ -79,3 +79,14 @@ if _MUJOCO_GL not in _MUJOCO_GL_DISABLE: from mujoco.egl import GLContext else: from mujoco.glfw import GLContext + + +def _get_version() -> str: + with open(os.path.join(HEADERS_DIR, 'mujoco.h'), 'r') as f: + for line in f: + if line.startswith('#define mjVERSION_HEADER'): + version = line.split()[2] + break + return '.'.join([d for d in str(version)]) + +__version__ = _get_version() From 8dc08d3733461ebe0ea770d0af07fdd4cfa00b64 Mon Sep 17 00:00:00 2001 From: Kevin Zakka Date: Tue, 29 Mar 2022 09:57:17 -0700 Subject: [PATCH 2/3] Use mujoco function instead. --- python/mujoco/__init__.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/python/mujoco/__init__.py b/python/mujoco/__init__.py index be11fe22..1f5aaf6d 100644 --- a/python/mujoco/__init__.py +++ b/python/mujoco/__init__.py @@ -81,12 +81,4 @@ if _MUJOCO_GL not in _MUJOCO_GL_DISABLE: from mujoco.glfw import GLContext -def _get_version() -> str: - with open(os.path.join(HEADERS_DIR, 'mujoco.h'), 'r') as f: - for line in f: - if line.startswith('#define mjVERSION_HEADER'): - version = line.split()[2] - break - return '.'.join([d for d in str(version)]) - -__version__ = _get_version() +__version__ = mj_versionString() From 5639ee22fc50689a278e47833d27d6ed8afd9959 Mon Sep 17 00:00:00 2001 From: Kevin Zakka Date: Tue, 29 Mar 2022 10:11:41 -0700 Subject: [PATCH 3/3] Remove extraneous line. --- python/mujoco/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/mujoco/__init__.py b/python/mujoco/__init__.py index 1f5aaf6d..0a9ba591 100644 --- a/python/mujoco/__init__.py +++ b/python/mujoco/__init__.py @@ -80,5 +80,4 @@ if _MUJOCO_GL not in _MUJOCO_GL_DISABLE: else: from mujoco.glfw import GLContext - __version__ = mj_versionString()