Nuke 13 and Python 3

137 views
Skip to first unread message

Jens

unread,
Jan 28, 2021, 3:35:15 AM1/28/21
to Royal Render Knights Tavern
Nuke 13 beta is out and with that comes the final piece of our pipeline to move over to Python 3.
It's a lot of work to transform all our Nuke pipeline to Python 3 so I figured I get started right away.
The Nuke submitter is failing on some str / unicode things in regards to XML.
Looking at the code, a lot of it doesn't even makes sense... like this part in py2, which errors out in py3 because unicode doesn't exist in py3:
if (type(text) == unicode ):
    sub.text = text.encode('utf8')
else:
    sub.text = str(text).decode("utf8")


That basically translates to:
If text is unicode, convert to str
else, convert to str and then convert to unicode.

That doesn't makes sense at all. Since ElementTree want to work with unicode, it should be like this instead, right??
if type(text) is unicode:
    sub.text = text
else:
    sub.text = str(text).decode("utf8")


So what do you think is the right thing to do here. As I see it there are two options...
1. Change the Nuke submitter to work in both python2 and python3? Would require several if sys.version_info.major == 2: statements to get around the unicode dilemma.
2. Create a new modern and pure py3 rrSubmit_Nuke_13.py and use that going forward?

Personally I would opt for no 2. and start with a clean slate, but that is only if you guys have time to rewrite it.
In the meantime I will probably hack together a py3 submitter so we can get to testing asap, but it would be great if this was solved by you guys soon as well.

Or if you would like me to submit a PR on github, with either option 1 or 2 above, just let me know.

Cheers,
//Jens Lindgren

RR support, Acampora

unread,
Jan 28, 2021, 6:30:09 AM1/28/21
to Royal Render Knights Tavern
Hi Jens,

Thanks for your tips, I have just pushed an update based on your suggestion


I have not yet had the chance to try Nuke 13, but now the plugin should be able to run inside a Python 3 interpreter. At present we are not switching to a new plugin version if the only reason to do so is Python 3 compliancy, as so far we have managed to support both versions with a few changes.

Please let us know if the last changes help

Kind regards,
Paolo

Jens

unread,
Jan 28, 2021, 6:52:25 AM1/28/21
to Royal Render Knights Tavern
Hi Paolo,

Thanks for the fix, but that is just one of the issues...
Is it ok if I create an Github Issue to cover all this? I find it much more streamlined than email :)

//Jens

RR support, Acampora

unread,
Jan 28, 2021, 7:00:44 AM1/28/21
to Royal Render Knights Tavern
Hi Jens,

sure, that was one of the points of having a public repository in the first place, so please, let's continue this on the github issues section

Cheers,
Paolo

Jens

unread,
Jan 28, 2021, 9:24:40 AM1/28/21
to Royal Render Knights Tavern
Reply all
Reply to author
Forward
0 new messages