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
Unwanted carriage returns in output file #165
Comments
so far as I can see https://pip.pypa.io/en/stable/reference/requirements-file-format/ is silent on what the line separator should be, which I take to mean that all the major variations should be valid everywhere. Certainly that doesn't say that carriage returns are unwanted. You haven't said why this matters to you - what's the problem you're trying to solve? eg if you have found some tool that does care about the line endings then perhaps it would be better to fix that tool. |
To have a consistent result regardless of whether I run |
I think that a platform default makes more sense/mirrors the behavior of existing tools (e.g. I see two options here: suggest using
Or introduce a flag e.g. I would like to point out that it's less idiomatic to manually (where manually here is "with CI validation") maintain a requirements.txt in-tree instead of generating it as-needed, but I suspect you have constraints/well-founded reasons to do so. If the only rationale for customizing the line-ending is to support a workflow like yours, where the output of |
for the specific problem of detecting change in a pipeline you can simply make the comparison with the appropriate flag to ignore line endings eg |
Perhaps... Although doesn't
Yeah, this is one of the better options. The main downsides are that it's extra configuration that needs to be added in each case, and it means that other local tools that might look at requirements.txt have to handle both crlf and lf cases, so it's just more opportunity for things to break.
I think it's so that you can checkout that git repository and install dependencies without having to have poetry installed if you are only intending to run the code rather than work on it.
Well ideally they actually would be the same 😛 Git happens to be the way these files are getting from system A -> B, but this idea of having files be represented differently on different systems only exists for legacy reasons, and in reality LF is well supported on all platforms (even notepad, which was the last hold-out...)
It still results in spurious diffs though with multiple people updating the files. |
if your position is that the standard for requirements.txt ought to be different than it is, then you should take that to pypa and try to get folk to agree to it. Maybe start a conversation at https://discuss.python.org/c/packaging/14. If the rules change, then I expect this plugin would follow. if your problem is developers running I'd definitely be opposed to forcing this plugin always to output unix-style line endings, that will surely cause more complaints than it solves. I'd be only mildly opposed to a command line option for the plugin, not enough to kick up a fuss. If you put together an MR then perhaps you'll find a maintainer who's willing to merge it. |
Line endings are output on stdout just like when writing to a file.
That's the state of the standard. Tools must be robust against differing line endings as the line ending is not specified anywhere. So either tools must change or the standard must change. I don't think Poetry suddenly growing strong opinions out of line with the rest of the ecosystem is productive. Given the state of standardization, and the fact that the problem seems to be "how do I ensure that there are always LF line endings in my Git repository," I think |
|
I expect this issue should be closed, it's become clear that there's no appetite among maintainers for changing the code and |
I agree since Since it has not been mentionend so far: I'd probably choose
This way, you get CRLF on Windows. In contrast if you set |
On windows
os.linesep
includes a carriage return, so when the output file is opened in text mode,\n
is translated to\r\n
. This can be disabled by passingnewline=''
when opening the file.Whether this should be the default is another question. Personally I would prefer it if poetry produced identical output files regardless of the system. 🤷♂️ If this cannot be the default, then a flag or configuration option would be sufficient.
The text was updated successfully, but these errors were encountered: