| """ |
| Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. |
| |
| NVIDIA CORPORATION and its licensors retain all intellectual property |
| and proprietary rights in and to this software, related documentation |
| and any modifications thereto. Any use, reproduction, disclosure or |
| distribution of this software and related documentation without an express |
| license agreement from NVIDIA CORPORATION is strictly prohibited. |
| |
| |
| Gym bindings wrapper module |
| """ |
|
|
| from __future__ import print_function, division, absolute_import |
|
|
| import importlib |
| import json |
| import sys |
| import os |
|
|
| from . import gymdeps |
|
|
|
|
| def _format_path(pathstr): |
| if os.name == "nt": |
| |
| return pathstr.replace("\\", "/").lower() |
| else: |
| return pathstr |
|
|
|
|
| def _import_active_version(): |
| major = sys.version_info[0] |
| minor = sys.version_info[1] |
|
|
| |
|
|
| |
| lib_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), "_bindings")) |
|
|
| if os.name == "nt": |
| platform = "windows-x86_64" |
| ext = "pyd" |
| else: |
| platform = "linux-x86_64" |
| ext = "so" |
|
|
| module_name = "gym_%d%d" % (major, minor) |
| module_dir = os.path.join(lib_dir, platform) |
| module_path = os.path.join(module_dir, "%s.%s" % (module_name, ext)) |
| package_path = "isaacgym._bindings.%s.%s" % (platform, module_name) |
|
|
| |
| |
| |
| |
|
|
| if os.path.isfile(module_path): |
| |
| os.environ["CARB_APP_PATH"] = _format_path(module_dir) |
|
|
| print("Importing module '%s' (%s)" % (module_name, module_path)) |
| print(">>>", os.getenv("LD_LIBRARY_PATH")) |
| module = importlib.import_module(package_path) |
| |
| |
| |
| |
| if hasattr(module, "__all__"): |
| attrs = {key: getattr(module, key) for key in module.__all__} |
| else: |
| attrs = { |
| key: value for key, value in module.__dict__.items() if key[0] != "_" |
| } |
| globals().update(attrs) |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| carb_init() |
|
|
| |
| usd_plug_info_path = os.path.join(lib_dir, platform, "usd", "plugInfo.json") |
| if os.path.isfile(usd_plug_info_path): |
| os.environ["GYM_USD_PLUG_INFO_PATH"] = usd_plug_info_path |
| print("Setting GYM_USD_PLUG_INFO_PATH to %s" % usd_plug_info_path) |
| else: |
| print("Warning: Failed to find USD plugInfo file (%s)" % usd_plug_info_path) |
|
|
| |
| if major == 3 and minor == 6: |
| sys.path.append(os.path.join(lib_dir, platform, "py36")) |
|
|
| else: |
| raise RuntimeError( |
| "No gym module found for the active version of Python (%d.%d)" |
| % (major, minor) |
| ) |
|
|
|
|
| _import_active_version() |
|
|