Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions python/py_package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# limitations under the License.
#
from warnings import warn
import pkg_resources
import os
import sys
from pathlib import Path
import platform
from .version import __version__
Expand Down Expand Up @@ -47,12 +47,17 @@
from .wrapper.articulation_builder import ArticulationBuilder
from .wrapper.pinocchio_model import PinocchioModel

import pkg_resources
if sys.version_info >= (3, 9):
import importlib.resources as resources
else:
import importlib_resources as resources

try:
render.set_imgui_ini_filename(str(Path.home() / ".sapien" / "imgui.ini"))
pysapien.render._internal_set_shader_search_path(
pkg_resources.resource_filename("sapien", "vulkan_shader")
str(
resources.files("sapien") / "vulkan_shader"
)
)
render.set_viewer_shader_dir("default")
render.set_camera_shader_dir("default")
Expand Down
4 changes: 1 addition & 3 deletions python/py_package/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ from __future__ import annotations
from _warnings import warn
import os as os
from pathlib._local import Path
import pkg_resources as pkg_resources
import platform as platform
from sapien.pysapien import Component
from sapien.pysapien import CudaArray
Expand Down Expand Up @@ -33,6 +32,5 @@ from . import render
from . import utils
from . import version
from . import wrapper
__all__ = ['ActorBuilder', 'ArticulationBuilder', 'Component', 'CudaArray', 'Device', 'Engine', 'Entity', 'Path', 'PinocchioModel', 'Pose', 'SapienRenderer', 'Scene', 'SceneConfig', 'System', 'Widget', 'asset', 'internal_renderer', 'math', 'os', 'physx', 'pkg_resources', 'platform', 'profile', 'pysapien', 'pysapien_pinocchio', 'render', 'set_log_level', 'simsense', 'utils', 'version', 'warn', 'wrapper']
__all__ = ['ActorBuilder', 'ArticulationBuilder', 'Component', 'CudaArray', 'Device', 'Engine', 'Entity', 'Path', 'PinocchioModel', 'Pose', 'SapienRenderer', 'Scene', 'SceneConfig', 'System', 'Widget', 'asset', 'internal_renderer', 'math', 'os', 'physx', 'platform', 'profile', 'pysapien', 'pysapien_pinocchio', 'render', 'set_log_level', 'simsense', 'utils', 'version', 'warn', 'wrapper']
__version__: str = '3.0.0.dev20251208+67ae2a67'
__warningregistry__: dict = {'version': 0, ('pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.', UserWarning, 18): True}
27 changes: 16 additions & 11 deletions python/py_package/_vulkan_tricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import pkg_resources
from warnings import warn
import platform
import os
import platform
import sys
from warnings import warn

if sys.version_info >= (3, 9):
import importlib.resources as resources
else:
import importlib_resources as resources


def _ensure_libvulkan_linux():
Expand All @@ -30,8 +35,8 @@ def _ensure_libvulkan_linux():
return

# add our vulkan to LD_LIBRARY_PATH
vulkan_library_path = pkg_resources.resource_filename(
"sapien", "vulkan_library/libvulkan.so.1.3.224"
vulkan_library_path = str(
resources.files("sapien") / "vulkan_library/libvulkan.so.1.3.224"
)

warn("Failed to find system libvulkan. Fallback to SAPIEN builtin libvulkan.")
Expand All @@ -51,8 +56,8 @@ def _ensure_libvulkan_mac():
if os.path.isfile(libPath):
os.environ["SAPIEN_VULKAN_LIBRARY_PATH"] = libPath
return
vulkan_library_path = pkg_resources.resource_filename(
"sapien", "vulkan_library/libvulkan.1.3.290.dylib"
vulkan_library_path = str(
resources.files("sapien") / "vulkan_library/libvulkan.1.3.290.dylib"
)

warn("Failed to find system libvulkan. Fallback to SAPIEN builtin libvulkan.")
Expand All @@ -73,8 +78,8 @@ def _ensure_vulkan_icd():
warn(
"Failed to find Vulkan ICD file. This is probably due to an incorrect or partial installation of the NVIDIA driver. SAPIEN will attempt to provide an ICD file anyway but it may not work."
)
os.environ["VK_ICD_FILENAMES"] = pkg_resources.resource_filename(
"sapien", "vulkan_library/nvidia_icd.json"
os.environ["VK_ICD_FILENAMES"] = str(
resources.files("sapien") / "vulkan_library/nvidia_icd.json"
)


Expand All @@ -96,8 +101,8 @@ def _ensure_egl_icd():
"Failed to find glvnd ICD file. This is probably due to an incorrect or partial installation of the NVIDIA driver. SAPIEN will attempt to provide an ICD file anyway but it may not work."
)

os.environ["__EGL_VENDOR_LIBRARY_FILENAMES"] = pkg_resources.resource_filename(
"sapien", "vulkan_library/10_nvidia.json"
os.environ["__EGL_VENDOR_LIBRARY_FILENAMES"] = str(
resources.files("sapien") / "vulkan_library/10_nvidia.json"
)


Expand Down
5 changes: 1 addition & 4 deletions python/py_package/utils/viewer/control_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@
# limitations under the License.
#
import os
from pathlib import Path
from typing import List

import numpy as np
import pkg_resources
import sapien
from sapien import internal_renderer as R
from transforms3d.quaternions import mat2quat
from transforms3d.euler import quat2euler
from transforms3d.quaternions import mat2quat

from .camera_control import ArcRotateCameraController, FPSCameraController
from .plugin import Plugin, copy_to_clipboard
Expand Down
11 changes: 6 additions & 5 deletions python/py_package/utils/viewer/render_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import sys
from pathlib import Path

import numpy as np
import pkg_resources
import sapien
from sapien import internal_renderer as R

from .plugin import Plugin

if sys.version_info >= (3, 9):
import importlib.resources as resources
else:
import importlib_resources as resources

class RenderOptionsWindow(Plugin):
def __init__(self):
Expand Down Expand Up @@ -156,10 +160,7 @@ def _setup_shader_dir(self):
self.shader_types = []

try:
all_shader_dir = Path(
pkg_resources.resource_filename("sapien", "vulkan_shader")
)

all_shader_dir = Path(str(resources.files("sapien") / "vulkan_shader"))
for f in all_shader_dir.iterdir():
if f.is_dir():
if any("gbuffer.frag" in x.name for x in f.iterdir()):
Expand Down
1 change: 1 addition & 0 deletions python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ networkx
pyperclip
opencv-python>=4.0
setuptools
importlib_resources