Skip to content
Snippets Groups Projects
Commit 20c83a9d authored by Campbell Barton's avatar Campbell Barton
Browse files

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.
parent aedd4998
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
# ##### END GPL LICENSE BLOCK ##### # ##### END GPL LICENSE BLOCK #####
bl_info = { bl_info = {
'name': 'Save As Runtime', 'name': 'Save As Game Engine Runtime',
'author': 'Mitchell Stokes (Moguri)', 'author': 'Mitchell Stokes (Moguri)',
'version': (0, 3, 1), 'version': (0, 3, 1),
"blender": (2, 5, 8), "blender": (2, 5, 8),
...@@ -37,6 +37,25 @@ import sys ...@@ -37,6 +37,25 @@ import sys
import shutil 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): def WriteAppleRuntime(player_path, output_path, copy_python, overwrite_lib):
# Enforce the extension # Enforce the extension
if not output_path.endswith('.app'): if not output_path.endswith('.app'):
...@@ -52,16 +71,8 @@ def WriteAppleRuntime(player_path, output_path, copy_python, overwrite_lib): ...@@ -52,16 +71,8 @@ def WriteAppleRuntime(player_path, output_path, copy_python, overwrite_lib):
if copy_python: if copy_python:
print("Copying Python files...", end=" ") 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, "..") dst = os.path.join(output_path, "..")
CopyPythonLibs(dst, overwrite_lib)
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')])
print("done") print("done")
...@@ -132,25 +143,14 @@ def WriteRuntime(player_path, output_path, copy_python, overwrite_lib, copy_dlls ...@@ -132,25 +143,14 @@ def WriteRuntime(player_path, output_path, copy_python, overwrite_lib, copy_dlls
if copy_python: if copy_python:
print("Copying Python files...", end=" ") print("Copying Python files...", end=" ")
py_folder = os.path.join(bpy.app.version_string.split()[0], "python", "lib") 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) dst = os.path.join(runtime_dir, py_folder)
CopyPythonLibs(dst, overwrite_lib)
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)
print("done") print("done")
# And DLLs # And DLLs
if copy_dlls: if copy_dlls:
print("Copying DLLs...", end=" ") 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) src = os.path.join(blender_dir, file)
dst = os.path.join(runtime_dir, file) dst = os.path.join(runtime_dir, file)
shutil.copy2(src, dst) shutil.copy2(src, dst)
...@@ -162,7 +162,7 @@ from bpy.props import * ...@@ -162,7 +162,7 @@ from bpy.props import *
class SaveAsRuntime(bpy.types.Operator): class SaveAsRuntime(bpy.types.Operator):
bl_idname = "wm.save_as_runtime" bl_idname = "wm.save_as_runtime"
bl_label = "Save As Runtime" bl_label = "Save As Game Engine Runtime"
bl_options = {'REGISTER'} bl_options = {'REGISTER'}
if sys.platform == 'darwin': if sys.platform == 'darwin':
...@@ -171,7 +171,7 @@ class SaveAsRuntime(bpy.types.Operator): ...@@ -171,7 +171,7 @@ class SaveAsRuntime(bpy.types.Operator):
else: else:
blender_bin_path = bpy.app.binary_path blender_bin_path = bpy.app.binary_path
blender_bin_dir = os.path.dirname(blender_bin_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) 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) player_path = StringProperty(name="Player Path", description="The path to the player to use", default=default_player_path)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment