Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2017-04-12 12:14:30 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2017-04-12 12:14:41 +0300
commit8f2c04c033943fbaaaf744e84dd9ba37ef39ba0c (patch)
tree5613f092d0f5ddba896b32ab207d78236037ce24 /io_blend_utils
parente50b06dde8eba0c7118c87aef4c4811d206f219a (diff)
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.
Diffstat (limited to 'io_blend_utils')
-rw-r--r--io_blend_utils/__init__.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/io_blend_utils/__init__.py b/io_blend_utils/__init__.py
index 1f3ed49e..5e6f6fe8 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():