-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Space in filename in PIP_CONSTRAINTS is interpreted as a new file #10114
Comments
I don’t think there is a good solution to this, unfortunately. The space is used as the delimiter from basically pip’s inception, and it’s way too late to change that. We could introduce some quoting logic to fix this in theory, but it’s going to cause incompatibility elsewhere that’s going to confuse other people. I think the only sensible “solution” is to document this well so users know what’s going wrong and puts the file elsewhere. |
I would recommend treating "path" variables differently, and not allow spaces there, or at the very least, allow quoted values. Is anyone really using FYI, fish has special handling for PATH variables, so there's precedent. Sometimes you can't avoid putting a path with a space. If you have a username with a space in it, you might not have permission to put it anywhere else. Spaces are valid in path on all operating systems (all meaning at least the big three). @pypa/build-team is likely the most heavily affected, as there's no other way to pass constraints through |
The "worst" possible solution but backward compatible would be to try the first path, if it doesn't exist, keep adding the next space-separated path on to it and try that, etc, only erroring out if all joined paths also do not exist. 🤦 |
I don’t use constraints much myself, but it’s very common to supply multiple paths to
This immediately breaks having the quote character in path, so you’ll need a way to support that, which is what I meant by complex quoting. Having quotes in a path is of course significantly less common, so maybe it’s reasonable to break that if we go through a proper deprecation phase. That’s no longer trivial work, but I’ll be happy to review changes if someone is willing to work it though. We can use
From the top of my head, |
Well, a GitHub search for I would expect almost no one sets I would expect
IMHO, it seems PIP_CONSTRAINT and PIP_REQUIREMENT could be changed to be treated as a colon or semicolon separated list of paths with spaces, which would allow both lists and paths with spaces to work, whereas now, paths with spaces are not supported at all. Even with URIs on Windows. Unless there are other clearly "PATH" lists. |
I agree with @uranusjr here. There are major backward compatibility questions here, which will need to be taken seriously in any change made in this area. And while github searches may give some indication, there's a lot of usage of pip that's not visible because it's in closed-source environments, and we can't break that either. I'd be fine if someone wants to do the work on this, but don't expect it to be simple. Also, please be aware that consistency in how we handle environment variables is important - we don't document environment variable processing for each variable individually, but rely on general rules (things like "options that take a list of values are read as space separated lists from environment variables"). Special-casing particular variables will need extra documentation, and will be less discoverable than you'd think because people are used to referring to the general rules. Also, what do you propose to do about config files? I'm pretty sure they use the same rules so would you have the rules differ, or would you change how config files are interpreted too? Both have downsides. |
The obvious solution is to use os.pathsep as a delimiter. Since that is invalid as a filename character, its presence would toggle the new parsing mode on. Whether that’s actually something worth pursuing I do not know.
Sent with [ProtonMail](https://protonmail.com/) Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
…On Wednesday, June 30th, 2021 at 10:52, Paul Moore ***@***.***> wrote:
I agree with ***@***.***(https://github.com/uranusjr) here. There are major backward compatibility questions here, which will need to be taken seriously in any change made in this area. And while github searches may give some indication, there's a lot of usage of pip that's not visible because it's in closed-source environments, and we can't break that either.
I'd be fine if someone wants to do the work on this, but don't expect it to be simple.
Also, please be aware that consistency in how we handle environment variables is important - we don't document environment variable processing for each variable individually, but rely on general rules (things like "options that take a list of values are read as space separated lists from environment variables"). Special-casing particular variables will need extra documentation, and will be less discoverable than you'd think because people are used to referring to the general rules.
Also, what do you propose to do about config files? I'm pretty sure they use the same rules so would you have the rules differ, or would you change how config files are interpreted too? Both have downsides.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, [view it on GitHub](#10114 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AHNRFWCA3RKXJCPLFBYTBH3TVLEKDANCNFSM47Q55LQQ).
|
Sure, it's not normally used in lists that are separated by |
I stand corrected, I'm too used to macOS where special rules apply to ":" because of its history as a directory separator. |
Ah, I didn't know MacOS did that. Cross-platform rules are weird 🙂 |
I believe since 10.0 the But there are two major downsides here. First, this means the accepted values on POSIX and Windows will be different ( |
Description
The
PIP_CONSTRAINTS
variable (and likely any other path related variables?) can't handle a path with a space in it. Something likePIP_CONSTRAINTS="C:\Program Files\..."
causesCould not open requirements file: [Errno 2] No such file or directory: 'C:\\Program'
. These path variables should probably interpret spaces as part of paths, and use a separator for multiple values (like:
or;
).Also, quotes around the path causes this to fail, too,
PIP_CONSTRAINTS="'C:\Program Files\...'"
breaks.See pypa/cibuildwheel#740
Expected behavior
Spaces in paths should not break.
pip version
21.1.3
Python version
All
OS
Windows and macOS, at least, probably all.
How to Reproduce
my constraints.txt
PIP_CONSTRAINTS="my constraints.txt" pip install <package>
Output
Could not open requirements file: [Errno 2] No such file or directory: 'C:\\Program'`
Code of Conduct
The text was updated successfully, but these errors were encountered: