[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2076] trunk/py/scripts/addons/ game_engine_save_as_runtime.py: fixes for same runtime
Campbell Barton
ideasman42 at gmail.com
Wed Jun 29 11:47:17 CEST 2011
Revision: 2076
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2076
Author: campbellbarton
Date: 2011-06-29 09:47:16 +0000 (Wed, 29 Jun 2011)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/py/scripts/addons/game_engine_save_as_runtime.py
Modified: trunk/py/scripts/addons/game_engine_save_as_runtime.py
===================================================================
--- trunk/py/scripts/addons/game_engine_save_as_runtime.py 2011-06-29 08:03:46 UTC (rev 2075)
+++ trunk/py/scripts/addons/game_engine_save_as_runtime.py 2011-06-29 09:47:16 UTC (rev 2076)
@@ -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 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 @@
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 @@
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 @@
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 @@
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)
More information about the Bf-extensions-cvs
mailing list