Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build script with python 3 where each line starting with 'b and ends with \n' making it hard to read the log. #768

Merged
merged 1 commit into from
Sep 11, 2020

Conversation

HamedSabri-adsk
Copy link
Contributor

When running build.py with python3, each line starts with 'b and ends with \n' making it hard to read the log.

Using codec module fixes the problem: https://docs.python.org/3/library/codecs.html

It appears the same fix was also introduced in USD's build_usd.py few months ago:

Commit 4f0a1640
by sunyab, 25/03/2020 04:43 PM
committed by pixar-oss
parent 7f64522e
child a9c9786e

…nds with \n' making it hard to read the log.
@@ -124,7 +125,7 @@ def Run(context, cmd):
"""Run the specified command in a subprocess."""
PrintInfo('Running "{cmd}"'.format(cmd=cmd))

with open(context.logFileLocation, "a") as logfile:
with codecs.open(context.logFileLocation, "a", "utf-8") as logfile:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a fix locally for it as well...but I didn't have to change anything else than line 150, i.e. remove encode and write simply content of l.

How can I see the issue which forced you to use codecs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a fix locally for it as well...but I didn't have to change anything else than line 150, i.e. remove encode and write simply content of l.

If I recall correctly, I had the code originally that way and it was working on some platforms but not others.

How can I see the issue which forced you to use codecs?
Use python 3 to run the build script.

e.g
C:\Python37\python.exe build.py .....

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is exactly what I'm doing...and all I needed is a change to switch from logfile.write(str(l.encode("utf8"))) to logfile.write(l).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I see but we had random failures with that approach. I think the codecs approach should be fine. I did a few tests and seems to be working.

Please give it a try and see if it solves things for you as well.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From offline discussion - this looks to be platform-specific and this is why I only required a smaller fix on MacOS.

@kxl-adsk kxl-adsk added the build Related to building maya-usd repository label Sep 9, 2020
@HamedSabri-adsk HamedSabri-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Sep 10, 2020
@kxl-adsk kxl-adsk merged commit 5925ef3 into dev Sep 11, 2020
@kxl-adsk kxl-adsk deleted the sabrih/fix_build_script_python_3 branch September 11, 2020 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Related to building maya-usd repository ready-for-merge Development process is finished, PR is ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants