[Bf-extensions-cvs] [8f2c04c] master: io_blend_utils: explicitly reference BAM wheel file, rather than guessing

Sybren A. Stüvel noreply at git.blender.org
Wed Apr 12 11:15:00 CEST 2017


Commit: 8f2c04c033943fbaaaf744e84dd9ba37ef39ba0c
Author: Sybren A. Stüvel
Date:   Wed Apr 12 11:14:30 2017 +0200
Branches: master
https://developer.blender.org/rBA8f2c04c033943fbaaaf744e84dd9ba37ef39ba0c

io_blend_utils: explicitly reference BAM wheel file, rather than guessing

The glob + sort approach didn't work reliably enough. Now we're just
hard-coding the wheel's filename.

===================================================================

M	io_blend_utils/__init__.py

===================================================================

diff --git a/io_blend_utils/__init__.py b/io_blend_utils/__init__.py
index 1f3ed49..5e6f6fe 100644
--- a/io_blend_utils/__init__.py
+++ b/io_blend_utils/__init__.py
@@ -29,6 +29,8 @@ bl_info = {
     "category": "Import-Export",
 }
 
+BAM_WHEEL_FILE = 'blender_bam-1.1.4-py3-none-any.whl'
+
 import logging
 
 import bpy
@@ -109,23 +111,24 @@ def pythonpath() -> str:
     """Returns the value of a PYTHONPATH environment variable needed to run BAM from its wheel file.
     """
 
-    import os.path
-    import glob
+    import os
+    import pathlib
 
     log = logging.getLogger('%s.pythonpath' % __name__)
 
     # Find the wheel to run.
-    my_dir = os.path.abspath(os.path.dirname(__file__))
-    wheelpaths = glob.glob(os.path.join(my_dir, 'blender_bam-*.whl'))
-    wheelpath = sorted(wheelpaths)[-1]  # use the last version we find, should be only one.
+    wheelpath = pathlib.Path(__file__).with_name(BAM_WHEEL_FILE)
+    if not wheelpath.exists():
+        raise EnvironmentError('Wheel file %s does not exist!')
+
     log.info('Using wheel file %s to run BAM-Pack', wheelpath)
 
     # Update the PYTHONPATH to include that wheel.
     existing_pypath = os.environ.get('PYTHONPATH', '')
     if existing_pypath:
-        return os.pathsep.join((existing_pypath, wheelpath))
+        return os.pathsep.join((existing_pypath, str(wheelpath)))
 
-    return wheelpath
+    return str(wheelpath)
 
 
 def register():



More information about the Bf-extensions-cvs mailing list