--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAHJS-05A%3DxJCD9qSj6EciaghQXvO%3DOAuJJjMkz_CEQ3KdusuqA%40mail.gmail.com.
This topic is so common it really needs to be highlighted somewhere. Maybe as a new Maya splash screen? xD
The problem though is that many packages are compatible, it’s only the compiled packages that are not. So it’s understandable that it keeps getting confused. Can only imagine the number of hours lost trying to shoehorn PyPI into Maya, and the subsequent number of hours struggling with random crashes due to suceeding to shoehorn it in; when it seems to work - like NumPy sometime does - but really shouldn’t.
I even tried to compile it although failing countless times at that .
The trick is compiling it with Maya’s Python, it’s the only way. In most cases it really needs to be mayapy
, since it itself was built with a different compiler than the one on python.org. The same compiler as Maya was built with, and the same compiler your library needs to be built with. Which is why you most often also need a separate build for each major version of Maya, see the development docs for which compiler version they use and when they switch. Some versions of Maya use the same.
I was looking for an example of how PyQt is compiled for Maya that isn’t too convoluted. The process would be similar here. The closest one I can find that contains each step is this.
Replacing any mention of python
with mayapy
and (optionally, but safest) explicitly passing Maya’s Python headers to configure.py
or setup.py
etc.
Maybe someone else has a guide on compiling anything for Maya specifically? It can be really hard, like NumPy, because of all the dependencies involved. But sometimes the light shines on you and it’ll be over before you know it.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMS3%2BiH5XQb%2BdoBt8t3CBXxvjo1xkQhbzxa2uJAi_xeOQQ%40mail.gmail.com.
Could you post some of those error messages? Maybe someone here recognises and could help resolve those.
I don’t think there’s a silver bullet, each library build has its quirks and challenges despite the community trying to adhere to standards there are like massive disparities on how easy it is to build something versus how confusing and annoying it is to build another
I think we’ve got C and C++ to thank for this haha. Or rather, thank Python for shielding us from the horrors of compiled software out there, it’s hard to understate how much more accessible it makes programming for this benefit alone. I bet anyone dabbling with C++ can attest to the pain and recurrence of dependencies in everyday life. For a modern example, just look at USD!
That said, it’s certainly possible. One clue might be looking at how the native Python packages are built for matplotlib.
The curveball Maya throws at you is that most build scripts out there assume a system-wide install of Python, and makes hardcoded assumptions about where to find libraries and headers. In a CI environment like that, it wouldn’t be unreasonable to mount Maya’s files over the native ones, to trick such build scripts into using the proper ones.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/db2915d7-8692-4821-9f26-d1ad35654e14n%40googlegroups.com.
Here we go, lots of clues.
c:\users\pf02\appdata\local\temp\pip-req-build-jo5j0f>call “C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.Cmd” /Release /x64 /xp
The system cannot find the path specified.
Problem number 1, you’ll need Visual Studio. Not only that, you need the version of Visual Studio Maya was built with. For example, for Maya 2020, that version is Visual Studio 2017.
c:\users\pf02\appdata\local\temp\pip-req-build-jo5j0f>call “C:\Users\PF02\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat” x64
Setting environment for using Microsoft Visual Studio 2008 x64 tools.
Problem number 2, this is another one of the the hardcoded assumptions I mentioned above, whereby you didn’t actually tell it to use Visual Studio 2008 and yet that’s what it’s trying to use. That’s what Python coming off of python.org used, so it’s assumed true here. You can’t rely on that.
The remaining issues in that log is because of these two primary ones.
So why is this happening?
mayapy -m pip install
Because of this. This calls on pip
to pull out whatever rabbits out of whatever hats are necessary to build something on whatever platform you are on. In most cases, it does a good job. Because pip
is related to PyPI
which is related to python.org
. So the hard-coded assumtions are often true.
The main thing you need to rectify is that version of Visual Studio it’s trying to use. I set this up recently but more-or-less copy pasted whatever I found online about it.
These two lines presumably overrides this particular assumption. I got that from here:
With that, it’ll use whichever cl.exe
is on your PATH
rather than look for it. Which means you need to call vcvarsall64.bat
ahead of time.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b67f54b5-d546-4a24-8517-750708674f12n%40googlegroups.com.
here's the best I managed https://gist.github.com/yetigit/c2f55bdb8b1798b2936687567f9c6c1e
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b67f54b5-d546-4a24-8517-750708674f12n%40googlegroups.com.