diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-06-29 13:47:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-06-29 13:47:16 +0400 |
commit | 20c83a9d7c8225bc83e4be639af01a35e4fc289b (patch) | |
tree | 68a5fc6e5a73f875578a62a8d2be39a5d4c5af6b | |
parent | aedd49989643578abdd15b57acf1bb5b5192411a (diff) |
fixes for same runtime
- for windows use case insensitive checks for DLL and EXE extensions.
- copying python libs now works if python is installed onto the system.
- renamed 'Save As Runtime' --> 'Save As Game Engine Runtime', since 'Runtime' is too much a generic term.
-rw-r--r-- | game_engine_save_as_runtime.py | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/game_engine_save_as_runtime.py b/game_engine_save_as_runtime.py index f55e2f6d..588b0904 100644 --- a/game_engine_save_as_runtime.py +++ b/game_engine_save_as_runtime.py @@ -17,7 +17,7 @@ # ##### END GPL LICENSE BLOCK ##### bl_info = { - 'name': 'Save As Runtime', + 'name': 'Save As Game Engine Runtime', 'author': 'Mitchell Stokes (Moguri)', 'version': (0, 3, 1), "blender": (2, 5, 8), @@ -37,6 +37,25 @@ import sys import shutil +def CopyPythonLibs(dst, overwrite_lib): + import sysconfig + src = sysconfig.get_paths()['platstdlib'] + # X.XX/python/lib --> X.XX/python/lib/pythonX.X + dst = os.path.join(dst, os.path.basename(src)) + if os.path.exists(src): + write = False + if os.path.exists(dst): + if overwrite_lib: + shutil.rmtree(dst) + write = True + else: + write = True + if write: + shutil.copytree(src, dst, ignore=lambda dir, contents: [i for i in contents if i == '__pycache__']) + else: + print("Python not found in %r, skipping pythn copy." % src) + + def WriteAppleRuntime(player_path, output_path, copy_python, overwrite_lib): # Enforce the extension if not output_path.endswith('.app'): @@ -52,16 +71,8 @@ def WriteAppleRuntime(player_path, output_path, copy_python, overwrite_lib): if copy_python: print("Copying Python files...", end=" ") - src = os.path.join(blender_dir, "%d.%d" % bpy.app.version[:2], "python", "lib") dst = os.path.join(output_path, "..") - - if os.path.exists(dst): - if overwrite_lib: - shutil.rmtree(dst) - shutil.copytree(src, dst, ignore=lambda dir, contents: [i for i in contents if i.endswith('.pyc')]) - else: - shutil.copytree(src, dst, ignore=lambda dir, contents: [i for i in contents if i.endswith('.pyc')]) - + CopyPythonLibs(dst, overwrite_lib) print("done") @@ -132,25 +143,14 @@ def WriteRuntime(player_path, output_path, copy_python, overwrite_lib, copy_dlls if copy_python: print("Copying Python files...", end=" ") py_folder = os.path.join(bpy.app.version_string.split()[0], "python", "lib") - src = os.path.join(blender_dir, py_folder) dst = os.path.join(runtime_dir, py_folder) - - if os.path.exists(src): - if os.path.exists(dst): - if overwrite_lib: - shutil.rmtree(dst) - shutil.copytree(src, dst, ignore=lambda dir, contents: [i for i in contents if i == '__pycache__']) - else: - shutil.copytree(src, dst, ignore=lambda dir, contents: [i for i in contents if i == '__pycache__']) - else: - print("Python not found in %r, skipping pythn copy." % src) - + CopyPythonLibs(dst, overwrite_lib) print("done") # And DLLs if copy_dlls: print("Copying DLLs...", end=" ") - for file in [i for i in os.listdir(blender_dir) if i.endswith('.dll')]: + for file in [i for i in os.listdir(blender_dir) if i.lower().endswith('.dll')]: src = os.path.join(blender_dir, file) dst = os.path.join(runtime_dir, file) shutil.copy2(src, dst) @@ -162,7 +162,7 @@ from bpy.props import * class SaveAsRuntime(bpy.types.Operator): bl_idname = "wm.save_as_runtime" - bl_label = "Save As Runtime" + bl_label = "Save As Game Engine Runtime" bl_options = {'REGISTER'} if sys.platform == 'darwin': @@ -171,7 +171,7 @@ class SaveAsRuntime(bpy.types.Operator): else: blender_bin_path = bpy.app.binary_path blender_bin_dir = os.path.dirname(blender_bin_path) - ext = os.path.splitext(blender_bin_path)[-1] + ext = os.path.splitext(blender_bin_path)[-1].lower() default_player_path = os.path.join(blender_bin_dir, 'blenderplayer' + ext) player_path = StringProperty(name="Player Path", description="The path to the player to use", default=default_player_path) |