I'm writing a Python script for Maya. I would like to compile and distribute it to make the code a little more confidential and to make it a little faster.
What I'm wondering is that Maya has different Python versions for each version, so I don't know if I have to compile in different environments.
When distributing MELs, I don't have to worry too much about Maya version differences, but for plugins created by compiling Python, I have to worry about Maya versions, right?
Should I use anacondaPrompt etc. to create a Python 2.7 .pyc file?
Or is there a way to compile Python scripts using only Maya without using an external environment such as anaconda? If anyone is familiar with it, please let me know.
Solved! Go to Solution.
Solved by negow. Go to Solution.
.pyc files are generated on first import of your Python .py file, just import it from Maya or mayapy and it'll be created in a way that's compatible with Maya; you won't need Anaconda or an external Python, in fact you should probably avoid it as it may differ from the version shipped with Maya.
As for which versions the .pyc runs with, the thing to keep in mind is which major and possibly minor version of Python Maya ships with; which as Maya 2015-2020 is Python 2.7. For Maya 2021 you'll likely need a separate .pyc.
Regarding performance and confidentiality, the only time savings you could hope for is time-to-import, and any .pyc can be turned back into a .py file using something like Decompyle so best not to store your deepest secrets in there.
Thank you very much. This answer was helpful. I usually develop with MEL, but I'm worried that the source code can be read by anyone. C ++ is difficult for beginners like me. I've heard that 3dsMax has a simple scripting method for obfuscation, but I hope Autodesk can offer some new solutions in Maya as well.
Can't find what you're looking for? Ask the community or share your knowledge.