Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Fix Maya 2022 Python 3 compatibility #2445

Merged
merged 18 commits into from
Feb 25, 2022

Conversation

BigRoy
Copy link
Collaborator

@BigRoy BigRoy commented Dec 28, 2021

This PR fixes issues in Maya 2022 that are happening to the update to new Python 3 in Maya.

Avoid dict_keys TypeError in lib.imprint for Create Render Creator

Commit: cb99b0a

Create Render Creator fails in Maya 2022 with Python 3 due to a TypeError in lib.imprint.

Description

Fixed by forcing the .keys() into a list so it's not a Python3 dict_keys object.


Refactor types.BooleanType and types.ListType

Commit: d7b6582

Maya 2022 has Python 3 and Python 3 does not have types.BooleanType and types.ListType so I've replaced it with straight bool and list. Which happens to also be what respectively thoses variables were set to in Py2 in types thus it should be both backwards and forward compatible.

Description

This is a very simple fix to just resolve the actual issue that occurred - which is to make it work in Maya 2022/Py3. It's not trying to re-evaluate whether the code could be improved upon altogether and for example these maya_is_true methods could be removed.

To fix:

This resolves an issue where otherwise `lib.imprint` will fail on `self.data` for this Creator plug-in
@BigRoy BigRoy changed the title Fix Maya 2022 Python 3 compatibility: types.BooleanType and types.ListType don't exist in Py3+ Fix Maya 2022 Python 3 compatibility Dec 28, 2021
- Also refactor import maya.cmds as `mc` to `cmds` to match with other code in the OpenPype code base
@BigRoy
Copy link
Collaborator Author

BigRoy commented Dec 28, 2021

  • Fixed another Py3 issue with 74cfde5

  • Fixed the left-hand side Toolbox OpenPype icons in Maya 2022+ with d090655 (This wasn't necessarily a Python 3 compatibility issue, but more a Maya 2022 UI change issue)

icons

@BigRoy
Copy link
Collaborator Author

BigRoy commented Jan 4, 2022

Fixed an issue in Maya 2020.0 (without updates) with commit fa77a49 which made the toolbox icons fail to set up. Reported by @Sasbom and confirmed it's fixed.

@BigRoy
Copy link
Collaborator Author

BigRoy commented Jan 5, 2022

We are using this in production with Maya 2022 and are squashing anything that comes up as we go. It's hard to tell when we can consider it fully functional but it's come a long way and is now far from "(Testing Only)" so I've removed that in defaults with 3b63abf

Would be nice if some others could give this a go to test it out of course. :)

@BigRoy
Copy link
Collaborator Author

BigRoy commented Jan 5, 2022

Note that issue #2454 is yet to be solved which we might want to fix first.
And we might want to discuss whether refactoring the usage of pymel to maya.cmds is worth it to solve anyone hitting #2353

@antirotor antirotor linked an issue Jan 5, 2022 that may be closed by this pull request
@antirotor antirotor added the type: enhancement Enhancements to existing functionality label Jan 5, 2022
@antirotor antirotor linked an issue Jan 12, 2022 that may be closed by this pull request
@mkolar
Copy link
Member

mkolar commented Jan 14, 2022

Should we maybe flip this from Draft to reviewable? We could Do the remaining work in another PR, so prevent getting this stuck for too long.

@BigRoy
Copy link
Collaborator Author

BigRoy commented Jan 14, 2022

Should we maybe flip this from Draft to reviewable? We could Do the remaining work in another PR, so prevent getting this stuck for too long.

I'd like to - but the color space settings issue unfortunately seem relatively problematic since it does raise errors currently. My idea is to just have extra settings in Admin Settings for Maya 2022+ due to the new color management they introduced. And whenever Maya 2022 is set to "use legacy mode" it falls back to the old settings (since it then supports those just fine).

Unfortunately don't have the time on short notice to get that fixed. :(

@BigRoy
Copy link
Collaborator Author

BigRoy commented Jan 25, 2022

@antirotor @mkolar I implemented a first draft for the Color Management logic for Maya 2022 as discussed in this issue but I'm not too happy with the bloated code.

It also suffers with an issue that was there originally too, in particular that it doesn't work on Maya launch - only after first time New Scene - as described here. ignore this - was my own human error.

It would be great however if you could test this and play with it to check how it feels and whether it makes ANY sense - since I feel like it doesn't.

It's good to keep in mind that you'll need to at least save the project settings once otherwise the key colorManagementPreference_v2 does not exist in the database and a KeyError is raised in the code here - which is something to keep in mind for backwards compatibility too - I'm not sure if you'd need to save it for all your projects individually before it's fixed for that project.

@mkolar mkolar marked this pull request as ready for review February 25, 2022 13:00
@mkolar
Copy link
Member

mkolar commented Feb 25, 2022

We've tested this on clients side now, and it technically works as expected. It's now more of a missing features situation, rather than something not working strictly.

We think this should be merged to unblock Maya 2022 in general and we can continue dealing with th remaining issues, in further PRs

@mkolar mkolar merged commit 8b58c2c into ynput:develop Feb 25, 2022
@BigRoy BigRoy deleted the maya_py3_compatibility branch March 20, 2024 15:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
host: Maya type: enhancement Enhancements to existing functionality
Projects
None yet
4 participants