Repository: mikedh/trimesh
Pull request #1978 (2023-07-17 20:12:48)

Release: Path Fix
Hotfix and test to release #1977, where trimesh failed to import if the `PATH` environment variable was unset. 


Patch:
diff --git a/trimesh/interfaces/blender.py b/trimesh/interfaces/blender.py
index a7b24741..b0448554 100644
--- a/trimesh/interfaces/blender.py
+++ b/trimesh/interfaces/blender.py
@@ -7,7 +7,7 @@ from ..constants import log
 import os
 import platform
 
-_search_path = os.environ['PATH']
+_search_path = os.environ.get('PATH', '')
 if platform.system() == 'Windows':
     # try to find Blender install on Windows
     # split existing path by delimiter
diff --git a/trimesh/interfaces/scad.py b/trimesh/interfaces/scad.py
index a1f06e28..372f9b8f 100644
--- a/trimesh/interfaces/scad.py
+++ b/trimesh/interfaces/scad.py
@@ -7,7 +7,7 @@ from .generic import MeshScript
 from ..constants import log
 
 # start the search with the user's PATH
-_search_path = os.environ['PATH']
+_search_path = os.environ.get('PATH', '')
 # add additional search locations on windows
 if platform.system() == 'Windows':
     # split existing path by delimiter
diff --git a/trimesh/interfaces/vhacd.py b/trimesh/interfaces/vhacd.py
index 957e251e..2cbdb21c 100644
--- a/trimesh/interfaces/vhacd.py
+++ b/trimesh/interfaces/vhacd.py
@@ -5,7 +5,7 @@ from .generic import MeshScript
 from ..constants import log
 from ..util import which
 
-_search_path = os.environ["PATH"]
+_search_path = os.environ.get("PATH", "")
 
 if platform.system() == 'Windows':
     # split existing path by delimiter
diff --git a/trimesh/version.py b/trimesh/version.py
index 64548f97..e57f8d55 100644
--- a/trimesh/version.py
+++ b/trimesh/version.py
@@ -1,4 +1,4 @@
-__version__ = '3.22.4'
+__version__ = '3.22.5'
 
 if __name__ == '__main__':
     # print version if run directly i.e. in a CI script
diff --git a/trimesh/viewer/windowed.py b/trimesh/viewer/windowed.py
index 4ce6d2be..7a7731ab 100644
--- a/trimesh/viewer/windowed.py
+++ b/trimesh/viewer/windowed.py
@@ -391,9 +391,6 @@ class SceneViewer(pyglet.window.Window):
         Enable depth test in OpenGL using distances
         from `scene.camera`.
         """
-        # set the culling depth from our camera object
-        gl.glDepthRange(camera.z_near, camera.z_far)
-
         gl.glClearDepth(1.0)
         gl.glEnable(gl.GL_DEPTH_TEST)
         gl.glDepthFunc(gl.GL_LEQUAL)


Test patch:
diff --git a/tests/test_import.py b/tests/test_import.py
new file mode 100644
index 00000000..74e2f593
--- /dev/null
+++ b/tests/test_import.py
@@ -0,0 +1,31 @@
+"""
+test_import.py
+-------------------
+
+Make sure trimesh is importing right.
+"""
+import unittest
+
+
+class ImportTests(unittest.TestCase):
+
+    def test_path(self):
+        import os
+        # make sure trimesh imports without any environment variables
+        # this was failing on `PATH` at some point
+        keys = list(os.environ.keys())
+        path = {k: os.environ.pop(k) for k in keys}
+
+        # this should succeed with nothing in PATH
+        import trimesh
+
+        # not sure if this is necessary but put back removed values
+        for key, value in path.items():
+            os.environ[key] = value
+
+        # do a very basic operation
+        assert trimesh.creation.icosphere().is_volume
+
+
+if __name__ == '__main__':
+    unittest.main()