-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[windows] Avoid %r for quoting module-cache-path in Windows. #34176
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
[windows] Avoid %r for quoting module-cache-path in Windows. #34176
Conversation
@swift-ci please smoke test |
I might replace every usage of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The windows path makes me sad :-(. Thank you for cleaning this up. Removing the %r
usage sounds like a good idea to me.
Seems that |
7526b2d
to
26c436c
Compare
Sorry. I run it in several of the test directories, but not all of them. It should have been @swift-ci please smoke test |
@swift-ci please test Windows platform |
The problem now is that because the But then the I don't know, however, if the card castle of escaping and unescaping can ever be solved. PD: I still don't understand why it works in Windows VS2019. |
So I think I understand why it works in the VS 2019 nodes: they have Python 3.7.5 installed (comes from Visual Studio from reading the logs), while the VS 2017 nodes have 3.8.5 (installed with Chocolatey). For And then enter To put the cherry on top, if one uses Since this problem will start appearing when the VS 2019 nodes update to Python 3.8.5, I don't think the solution is going back to 3.7.5 in the VS 2017 nodes, but the solution is not going to be pretty. |
26c436c
to
bb9660d
Compare
@swift-ci please test Windows platform Edit: https://ci-external.swift.org/view/Pull%20Request/job/swift-PR-windows/7663/ but not in GitHub UI yet. |
@swift-ci please smoke test |
bb9660d
to
0326269
Compare
@swift-ci please test Windows platform Edit: https://ci-external.swift.org/view/Pull%20Request/job/swift-PR-windows/7664/ |
@swift-ci please smoke test |
|
Do not merge yet. The Windows CI failed badly. I have to look and figure out what's happening in that machine (it is quite hard to get things right because I have to copy code back and forth between machines).
|
@swift-ci please test Windows platform |
%r returns a representation of the object that is valid Python syntax. For numbers and strings this representation is very compatible with Unix shells, but for Windows, the quoting performed by Python will not be compatible. For example the Windows path separator `\` will be escaped as `\\`, which is not necessary for Windows and might make some tests that try to match path fail. Python 3.3 has `shlex.quote`, which was previously available as `pipes.quote` in earlier Python versions. `pipes.quote` was indeed used in several points of the `lit.cfg` file. For Windows, one need to do their own quoting. This change introduces `shell_quote` which uses `shlex.quote` or `pipes.quote` in Unix depending on the Python version, and provides an implementation of `shell_quote` for Windows. It replaces every usage of `pipes.quotes` for `shell_quote`, and modifies the value of `mcp_opt` to use `shell_quote` and not `%r`. This should fix the test `Driver\working-directory.swift` in the Windows Visual Studio 2017 builder.
0326269
to
8470a66
Compare
Removed the part that adds carets. Seems that Lit already does some massaging of the arguments, and the quoting I introduced was misbehaving with the one Lit implements. I tested having a space in my Python path, like it seems to happen in the build machine. @swift-ci please test Windows platform Edit: https://ci-external.swift.org/view/Pull%20Request/job/swift-PR-windows/7781/ |
@swift-ci please smoke test |
@swift-ci please smoke test Linux platform |
@swift-ci please test Linux platform |
Build failed |
@swift-ci please test Linux platform |
%r returns a representation of the object that is valid Python syntax.
For numbers and strings this representation is very compatible with
Unix shells, but for Windows, the quoting performed by Python will not
be compatible. For example the Windows path separator
\
will beescaped as
\\
, which is not necessary for Windows and might makesome tests that try to match path fail.
Python 3.3 has
shlex.quote
, which was previously available aspipes.quote
in earlier Python versions.pipes.quote
was indeedused in several points of the
lit.cfg
file. For Windows, one need todo their own quoting.
This change introduces
shell_quote
which usesshlex.quote
orpipes.quote
in Unix depending on the Python version, and provides animplementation of
shell_quote
for Windows. It replaces every usageof
pipes.quotes
forshell_quote
, and modifies the value ofmcp_opt
to useshell_quote
and not%r
.This should fix the test
Driver\working-directory.swift
in theWindows Visual Studio 2017 builder.