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

fix for copying python files when python is not found (prints a warning).

initialize the filepath in the invoke function rather then the menu.
parent 3b5ab077
No related branches found
No related tags found
No related merge requests found
...@@ -135,13 +135,16 @@ def WriteRuntime(player_path, output_path, copy_python, overwrite_lib, copy_dlls ...@@ -135,13 +135,16 @@ def WriteRuntime(player_path, output_path, copy_python, overwrite_lib, copy_dlls
src = os.path.join(blender_dir, py_folder) src = os.path.join(blender_dir, py_folder)
dst = os.path.join(runtime_dir, py_folder) dst = os.path.join(runtime_dir, py_folder)
if os.path.exists(dst): if os.path.exists(src):
if overwrite_lib: if os.path.exists(dst):
shutil.rmtree(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__']) shutil.copytree(src, dst, ignore=lambda dir, contents: [i for i in contents if i == '__pycache__'])
else: else:
shutil.copytree(src, dst, ignore=lambda dir, contents: [i for i in contents if i == '__pycache__']) print("Python not found in %r, skipping pythn copy." % src)
print("done") print("done")
# And DLLs # And DLLs
...@@ -193,17 +196,19 @@ class SaveAsRuntime(bpy.types.Operator): ...@@ -193,17 +196,19 @@ class SaveAsRuntime(bpy.types.Operator):
self.copy_dlls) self.copy_dlls)
print("Finished in %.4fs" % (time.clock()-start_time)) print("Finished in %.4fs" % (time.clock()-start_time))
return {'FINISHED'} return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
if not self.filepath:
ext = '.app' if sys.platform == 'darwin' else os.path.splitext(bpy.app.binary_path)[-1]
self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ext)
wm = context.window_manager wm = context.window_manager
wm.fileselect_add(self) wm.fileselect_add(self)
return {'RUNNING_MODAL'} return {'RUNNING_MODAL'}
def menu_func(self, context): def menu_func(self, context):
ext = '.app' if sys.platform == 'darwin' else os.path.splitext(bpy.app.binary_path)[-1] self.layout.operator(SaveAsRuntime.bl_idname)
default_blend_path = bpy.path.ensure_ext(bpy.data.filepath, ext)
self.layout.operator(SaveAsRuntime.bl_idname, text=SaveAsRuntime.bl_label).filepath = default_blend_path
def register(): def register():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment