Search code examples
pythondllpy2exemaya

Building an exe for a python script that uses Maya modules (Py2exe)


I know this is a long shot but I'm hoping someone on here has any experience with this as I can't find anything mentioning it online. I have a python script that imports modules from Autodesk Maya. This python script is run through mayapy.exe instead of python.exe which is whats throwing me off. I would rather not have to include a bat file with my script and have the users set the location of mayapy.exe in order to use it. I would prefer to somehow package mayapy.exe with my script using something like py2exe. I'm a little lost on where to go from here honestly.

If I run py2exe normally on my script, its result gives me the error cannot find maya.cmds, as expected. Is there a way I can find the dll to include? I tried running Dependency walker on mayapy.exe but I'm venturing into new territory here. There were only 2 dll's used from the Maya install directory base.dll and python26.dll, the rest were all system dlls. If anyone has tried any of this please share or if anyone has any advice or path I can look down or a website I can go to I would be very grateful. Thanks so much!

P.s. In case it helps at all, this is the python script imports:

try:
    import maya.standalone
    maya.standalone.initialize()
except:
    pass
import maya.cmds as cmds
import maya.mel as mel
from time import time as tTime
from glob import iglob
from shutil import copy
from os.path import join
from PyQt4 import QtCore
from PyQt4 import QtGui

The point of the script is to create a maya file, do some things in it, then save it. Using the maya interpreter(mayapy.exe) it does this without ever opening maya, which is what I was wanting.


Solution

  • Pretty sure what I wanted to do was not possible. Instead I split my program into two parts, one requiring Maya one not, for the part requiring Maya I just had it do a registry lookup for the Maya install location and used that. If it were possibly to include the necessary files for my script, I'm sure Autodesk would not have approved in the first place anyways.