justinfx / MayaSublime

Send selected Python and MEL code snippets from SublimeText to Maya via commandPort
MIT License
149 stars 38 forks source link

maya2022 python updata to 3.7 problem. #36

Closed tuqubao closed 3 years ago

tuqubao commented 3 years ago

Hi, I using sublime write python send to maya executed.

Traceback (most recent call last):

File "", line 17, in

NameError: name 'execfile' is not defined

execfile() is remove in python 3.7. but your plugin is used it , can you updata the code to support python 3.7 for maya2022?

or using runpy modular in python 3.X to replace execfile. your code is too complex and I can't to read. sorry for can't modify by self.
thank you !
justinfx commented 3 years ago

I will try to take a look at this. Seems like we need to update the command template as well since we can't just change the xtype variable:

https://github.com/justinfx/MayaSublime/blob/7526198e0662ec768a1f0ebefe4770331e03c560/MayaSublime.py#L116 https://github.com/justinfx/MayaSublime/blob/7526198e0662ec768a1f0ebefe4770331e03c560/MayaSublime.py#L290

Probably need something like this, to replace execfile:

with open(path) as f:
    code = compile(f.read(), path, 'exec')
    exec(code, namespace, namespace)

I've never used the runpy module before so it would require some testing. I see the docs say that it will modify the sys.path and I don't know if we want that or not.

tuqubao commented 3 years ago

thank your for quickly feedback. for py2.7 execfile , i can get the file location by file, but exec will losing file location.

--------------原始邮件-------------- 发件人:"Justin Israel @.>; 发送时间:2021年9月23日(星期四) 凌晨3:26 收件人:"justinfx/MayaSublime" @.>; 抄送:"tuqubao @.>;"Author @.>; 主题:Re: [justinfx/MayaSublime] maya2022 python updata to 3.7 problem. (#36)

I will try to take a look at this. Seems like we need to update the command template as well since we can't just change the xtype variable:

https://github.com/justinfx/MayaSublime/blob/7526198e0662ec768a1f0ebefe4770331e03c560/MayaSublime.py#L116 https://github.com/justinfx/MayaSublime/blob/7526198e0662ec768a1f0ebefe4770331e03c560/MayaSublime.py#L290

Probably need something like this, to replace execfile: with open(path) as f: code = compile(f.read(), path, 'exec') exec(code, namespace, namespace)

I've never used the runpy module before so it would require some testing. I see the docs say that it will modify the sys.path and I don't know if we want that or not.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

tuqubao commented 3 years ago

when you renew the code for testing? I can test code for you.

justinfx commented 3 years ago

@tuqubao sorry I have just been a bit busy. I will try to work on a fix soon.

justinfx commented 3 years ago

@tuqubao can you please give #37 a test?

tuqubao commented 3 years ago

ok, i will make a test for a while, and telling you the answer.

--------------原始邮件-------------- 发件人:"Justin Israel @.>; 发送时间:2021年9月24日(星期五) 凌晨2:47 收件人:"justinfx/MayaSublime" @.>; 抄送:"tuqubao @.>;"Mention @.>; 主题:Re: [justinfx/MayaSublime] maya2022 python updata to 3.7 problem. (#36)

@tuqubao can you please give #37 a test?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

tuqubao commented 3 years ago

is it the same way to install plugin in sublime text do to reinstall you code?

--------------原始邮件-------------- 发件人:"Justin Israel @.>; 发送时间:2021年9月24日(星期五) 凌晨2:47 收件人:"justinfx/MayaSublime" @.>; 抄送:"tuqubao @.>;"Mention @.>; 主题:Re: [justinfx/MayaSublime] maya2022 python updata to 3.7 problem. (#36)

@tuqubao can you please give #37 a test?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

justinfx commented 3 years ago

In order to test this development branch, you need to clone the branch into your SublimeText Packages location, instead of using the Package Manager. It needs to be the 36_py39_support branch. If you aren't able to figure that out to test it, then the only thing I can do is release it. I have tested it in maya 2022 python3 so far.

tuqubao commented 3 years ago

ok, you realease the version, i am not beside my pc so can not test now. when i am beside pc will do test at once.

--------------原始邮件-------------- 发件人:"Justin Israel @.>; 发送时间:2021年9月24日(星期五) 凌晨4:57 收件人:"justinfx/MayaSublime" @.>; 抄送:"tuqubao @.>;"Mention @.>; 主题:Re: [justinfx/MayaSublime] maya2022 python updata to 3.7 problem. (#36)

In order to test this development branch, you need to clone the branch into your SublimeText Packages location, instead of using the Package Manager. It needs to be the 36_py39_support branch. If you aren't able to figure that out to test it, then the only thing I can do is release it. I have tested it in maya 2022 python3 so far.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

tuqubao commented 3 years ago

send file to maya for english version test is ok.

send file to maya for my chinese version test is problem.

Traceback (most recent call last):

   File "<string>", line 25, in <module>

UnicodeDecodeError: 'gbk' codec can't decode byte 0x97 in position 12: illegal multibyte sequence

send selected text for chinese version test is ok.

------------------ Original ------------------ From:  "Justin @.>; Date:  Fri, Sep 24, 2021 04:57 AM To: @.>; Cc: @.>; @.>; Subject:  Re: [justinfx/MayaSublime] maya2022 python updata to 3.7 problem. (#36)

 

In order to test this development branch, you need to clone the branch into your SublimeText Packages location, instead of using the Package Manager. It needs to be the 36_py39_support branch. If you aren't able to figure that out to test it, then the only thing I can do is release it. I have tested it in maya 2022 python3 so far.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

tuqubao commented 3 years ago

have you check my email for testing report?

justinfx commented 3 years ago

@tuqubao yes your email turns into a comment on this issue thread, so I see it both ways. I've just been busy and not had a chance to reply to you. It looks like some more python 3 work is needed to handle edge cases with unicode support.

justinfx commented 3 years ago

@tuqubao can you please open a new issue with a sample of the code that is causing you a problem? I have tried to reproduce this with some chinese python source code and it seems to work fine for me. I'm also testing this on linux.

tuqubao commented 3 years ago

ok, i will do it at once

--------------原始邮件-------------- 发件人:"Justin Israel @.>; 发送时间:2021年9月25日(星期六) 上午6:45 收件人:"justinfx/MayaSublime" @.>; 抄送:"tuqubao @.>;"Mention @.>; 主题:Re: [justinfx/MayaSublime] maya2022 python updata to 3.7 problem. (#36)

@tuqubao can you please open a new issue with a sample of the code that is causing you a problem? I have tried to reproduce this with some chinese python source code and it seems to work fine for me. I'm also testing this on linux.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

tuqubao commented 3 years ago

this is a test code. if you can't open the code in sublime in the right way , you can install plugin convertToUTF8 and will ok check. and you can send me a chinese version code.

    ------------------ Original ------------------ From:  "Justin @.>; Date:  Sat, Sep 25, 2021 06:45 AM To: @.>; Cc: @.>; @.>; Subject:  Re: [justinfx/MayaSublime] maya2022 python updata to 3.7 problem. (#36)

 

@tuqubao can you please open a new issue with a sample of the code that is causing you a problem? I have tried to reproduce this with some chinese python source code and it seems to work fine for me. I'm also testing this on linux.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.