-
Notifications
You must be signed in to change notification settings - Fork 238
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
Problems changing PATH in windows #765
Comments
The environment variables are expanded with bash syntax. In bash, single-quotes don't expand variables, so you probably want to remove the single-quote from that string. double-quotes, or no quotes should work for that option. |
A test to verify if pypa/cibuildwheel#765 can be worked around this way.
Hi @joerick That makes sense. I was confused because I thought that the single quotes were an escape mechanism to pass data from a single yaml string to whatever parses the environ. I've made a few tests, and I've seen that yes, the double quotes allow the
I will send a MR to add a similar example to the docs. |
There is an extra layer of complexity because quoted strings in yaml require backslash escaping, but the above is not a quoted yaml string, altough it contains a yaml string in quotes... |
On Windows you often find directories containing spaces. The relation between quotes and escaping is not intuitive, see pypa#765.
Eeek. Yes, good point. I think most users don't need quotes at all, but in your example you have spaces so it's required. By the way, I think it's the bash parsing that's collapsing the double-backslash to a single one, not YAML. bash-3.2$ echo "C:\\Program Files\\PostgreSQL\\13\\bin"
C:\Program Files\PostgreSQL\13\bin |
What I meant is that examples such as: What is worse is that yaml double quotes process backslashes, unlike literal, single quotes, multiline strings. So with I think that showing examples without the yaml double quotes makes them more readable and less puzzling about who consumes what quotes or backslash - see especially the last example, containing a multi-token string. I have added a changeset to #767: let me know if that's useful, no problem if it isn't :) |
|
I wondered about that too. In a belt-and-braces bash script I would use $ export DATE=$(date) FOO=bar
$ echo $DATE
Mon 19 Jul 16:57:50 CEST 2021
$ echo $FOO
bar so I went for a minimal example, but TBH I think Do we want to add the quotes? |
I have noticed that in the toml version you do have quotes around |
FYI, TOML always requires quotes. You can't leave a string unquoted. |
(Variables are optional, |
Is there any way we can suppress backslash evaluation? I have to paths that I need to set on Windows and in my pyproject.toml, I now have this, which looks kind of ridiculous:
One escape pass is required by TOML itself, the other by cibuildwheel, otherwise the path will end up as |
Use single quotes, that will remove one layer of backslashes (the TOML one). |
But then there is still the inconsistent backslash handling of cibuildwheel. In |
I rather expect we shouldn't be processing backslashes, sounds a bit like a bug (and TOML already supports them doing various escapes when using |
The backslash escaping requirement is a result of the bash expansion, which lets you do stuff like: [tool.cibuildwheel.macos.environment]
PATH = "$PATH:/your/dir/here" However, if you wanted to set a variable to literally [tool.cibuildwheel.windows.environment]
SOME_OPTION = "$reference" because it's interpreted as an environment variable. In this case, you could do [tool.cibuildwheel.windows.environment]
SOME_OPTION = '\$reference' to get what you want. That's why backslash is an escape character in this context. It would be nice if there was some way to set values as 'raw', though, that would disable the bash processing... maybe something in toml like [tool.cibuildwheel.windows.environment]
SOME_OPTION.raw = "$reference" or could be [tool.cibuildwheel.windows.environment-raw]
SOME_OPTION = "$reference" (...harder to make a environment variable version of this, though, since the string is already split by a bash lexer to separate the parts.) |
I think that is the case for the windows shell, yeah. But only windows, for mac/linux you do have to escape them, as they run in a posix shell. Cross-platform is tricky 😣 |
Can't you just use forward slashes? |
Hello, I am trying to use cibuildwheel to build psycopg >= 3 packages for windows.
The package requires a dll,
libpq.dll
to build. The location of the dll is given by a program calledpg_config
which, in the build environment, is installed in a directory not under path.I am using this configuration in order to try the build, containing:
However build fails in a way that suggests that the path is not prepended, but rather replaced:
Is there anything wrong in what I am doing?
The text was updated successfully, but these errors were encountered: