I need a little help creating an executable python OS command for Blender (Windows and Mac). I am setting up a stand-alone blender package for a client to use. I have a python script that imports some data and I want to create an executable python script that runs OS commands to run Blender, run the python script and define the data directories.
This is a generic version of the Windows command I normally run to import the data, using the stand-alone version of Blender:
"C:\Users\username\Desktop\Package\system\blender\blender.exe" "C:\Users\username\Desktop\Package\system\version_data\CurrentVersion.blend" -P "C:\Users\username\Desktop\Package\system\version_data\BlenderScript.py" "C:\Users\username\Desktop\Package\input_data\\" -y
From my research I have worked out that I need to:
- import os
- make the directories in the command relative
- create an executable python file
My python experience is limited, but I believe it may be something like this:
import os pythonDirectory = os.path.dirname(os.path.abspath(RunThisApp.exe)) # get the current dir of this file (which would be: C:\Users\username\Desktop\Package\) os.path.join(pathDirectory, "//system\blender\blender.exe" "//system\version_data\CurrentVersion.blend" -P "//system\version_data\BlenderScript.py" "//input_data\\" -y)
However I had a look at this post and was a little fuzzy as to the best way to do this:
Then I could possibly use PyInstaller to create the python executable files. Which seems to be the simplest method suggested here:
Am I close to the correct result here? I am guessing my syntax is off. I need to make sure it works for both Windows and Mac.
It should also be noted that the separate python script I run to import data into blender (which I have been using and updating for a couple of years), refers to OS arguments to get the desired path of data to import, so I need to make sure that I maintain that connection. Here is an example:
IMPORT_DATA_FILENAME = sys.argv+'data.txt'
Any advice or input would be greatly appreciated. Chris Lee