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

torch: Stop using _nt_quote_args from distutils #48618

Closed
wants to merge 2 commits into from

Conversation

seemethere
Copy link
Member

They removed the specific function in Python 3.9 so we should just
remake the function here and use our own instead of relying on hidden
functions from the stdlib

Signed-off-by: Eli Uriegas eliuriegas@fb.com

Fixes #48617

@seemethere seemethere added the module: cpp-extensions Related to torch.utils.cpp_extension label Nov 30, 2020
@seemethere seemethere added module: build Build system issues and removed cla signed labels Nov 30, 2020
@seemethere seemethere requested review from a team, yf225 and glaringlee November 30, 2020 22:02
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@seemethere has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@@ -400,7 +418,7 @@ def unix_cuda_flags(cflags):
# overriding the option if the user explicitly passed it.
_ccbin = os.getenv("CC")
if (
_ccbin is not None
_ccbin is not None
Copy link
Member Author

Choose a reason for hiding this comment

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

I guess there was an extra whitespace here. 🤷

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a Flake8 lint for trailing whitespace?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't believe we do, but we probably should

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@seemethere has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@dr-ci
Copy link

dr-ci bot commented Nov 30, 2020

💊 CI failures summary and remediations

As of commit b944c06 (more details on the Dr. CI page):



1 job timed out:

  • pytorch_ios_12_0_0_arm64_metal_build

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 22 times.

@peterjc123
Copy link
Collaborator

peterjc123 commented Dec 1, 2020

@seemethere distutils.spawn switched to a different implementation in Python 3.9 on Windows. So, escaping may not be needed anymore. But there's another thing that we should really care about. That is, it will behave weirdly if there is an empty string inside the args. See #47460 (comment) for more context.

Comment on lines 40 to 43
for i, arg in enumerate(args):
if ' ' in arg:
args[i] = '"%s"' % arg
return args
Copy link
Contributor

Choose a reason for hiding this comment

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

Since it's our own function that is expected to work only in python-3.6.2 or newer, why not use list comprehensions and f-strings?

Suggested change
for i, arg in enumerate(args):
if ' ' in arg:
args[i] = '"%s"' % arg
return args
return [f'"{arg}"' if ' ' in arg else arg for arg in args]

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a direct lift and shift of the original function, wanted to keep it as close to the original as possible to avoid any backwards compat issues

@seemethere
Copy link
Member Author

@seemethere distutils.spawn switched to a different implementation in Python 3.9 on Windows. So, escaping may not be needed anymore. But there's another thing that we should really care about. That is, it will behave weirdly if there is an empty string inside the args. See #47460 (comment) for more context.

True, I was trying to get the path of least resistance to make this work and lifting and shifting the function out of stdlib seemed like the most backwards compatible solution

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@seemethere has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

They removed the specific function in Python 3.9 so we should just
remake the function here and use our own instead of relying on hidden
functions from the stdlib

Signed-off-by: Eli Uriegas <eliuriegas@fb.com>
Signed-off-by: Eli Uriegas <eliuriegas@fb.com>
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@seemethere has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@seemethere merged this pull request in 780f2b9.

seemethere added a commit to seemethere/pytorch that referenced this pull request Dec 3, 2020
Summary:
They removed the specific function in Python 3.9 so we should just
remake the function here and use our own instead of relying on hidden
functions from the stdlib

Signed-off-by: Eli Uriegas <eliuriegas@fb.com>

Fixes pytorch#48617

Pull Request resolved: pytorch#48618

Reviewed By: samestep

Differential Revision: D25230281

Pulled By: seemethere

fbshipit-source-id: 57216af40a4ae4dc8bafcf40d2eb3ba793b9b6e2
(cherry picked from commit 780f2b9)
Signed-off-by: Eli Uriegas <eliuriegas@fb.com>
seemethere added a commit that referenced this pull request Dec 3, 2020
)

Summary:
They removed the specific function in Python 3.9 so we should just
remake the function here and use our own instead of relying on hidden
functions from the stdlib

Signed-off-by: Eli Uriegas <eliuriegas@fb.com>

Fixes #48617

Pull Request resolved: #48618

Reviewed By: samestep

Differential Revision: D25230281

Pulled By: seemethere

fbshipit-source-id: 57216af40a4ae4dc8bafcf40d2eb3ba793b9b6e2
(cherry picked from commit 780f2b9)
Signed-off-by: Eli Uriegas <eliuriegas@fb.com>
shaibagon pushed a commit to shaibagon/pytorch that referenced this pull request Dec 3, 2020
Summary:
They removed the specific function in Python 3.9 so we should just
remake the function here and use our own instead of relying on hidden
functions from the stdlib

Signed-off-by: Eli Uriegas <eliuriegas@fb.com>

Fixes pytorch#48617

Pull Request resolved: pytorch#48618

Reviewed By: samestep

Differential Revision: D25230281

Pulled By: seemethere

fbshipit-source-id: 57216af40a4ae4dc8bafcf40d2eb3ba793b9b6e2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merged module: build Build system issues module: cpp-extensions Related to torch.utils.cpp_extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CPP Extension building with windows fails for Python 3.9
6 participants