I am writing some tools that need to run in python outside of Maya

TAs,

I am writing some tools for our studio and need to make use of Python. Normally, I would just make use of Maya to handle all of this but I need these tools to sit outside of Maya and at times when I need it to be Maya specific, I will invoke a specific version of Maya to target different projects. I was told that we can make use of Portable Python sitting in our tools that I can invoke and use for any tools that need to run outside of the Maya Env.

What have you used to solve this and are there any tips for us to consider setting this up?

thanks,

Morris Olmsted

Some years ago we used to require every PC using our tools to have a certain release of Python installed. We had a small bootstrapping tool that would install it, and set it up with our Python code libraries, etc. Later on we switched to making our own custom build of Python and distributing that via Perforce (like the rest of our tools). The custom build is primarily to help with debugging situations, however.

I’m not hip to Portable Python really, but it looks like it’s no longer being developed.

The closest substitute I’ve seen to portable python is https://winpython.github.io/

But awhile back they dropped support for Python 2.
So not all that useful unless you’re willing to make the jump to supporting multiple python versions.

Some other options would be converting the python tool into an exe, an then distributing that.
There are multiple tools that try to fill that void,
PyInstaller, cx_freeze, and Py2exe, being the 3 that I know about.

None of these options will work if you need to reference Maya specific libraries as part of the tool. Those would need to be run through mayapy.exe or in an instance of Maya it self.

Just create a python virtual environment. There is lots of info on python virtualenv’s online but the easiest way is to let PyCharm create and manage it. The entry point for your tool, a batch or shell script, can call your tools .py file with this virtual environment’s python executable.

Virtual environments are great for development, but not so much for deployment.
You still have to solve the problem of everyone else having a python instance to actually run the tools with.

Just push the virtualenv to your studios repo as part of your tools deployment. Hopefully you don’t to support multiple OS’s but you could still make that work too.

Part of the initial question, had to do with actually being able to run the tools.
Just pushing the code doesn’t solve the problem of the best way to execute it, which is why I’m assuming portable python was mentioned.

I’m not saying they shouldn’t use virtual environments, just that they aren’t really a deployment or execution tool.