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

Moving from developing on MAC to Windows and hitting command:warning: LF will be replaced by CRLF in src/setup.cfg. #36

Closed
setuk opened this issue Aug 31, 2018 · 6 comments

Comments

@setuk
Copy link

setuk commented Aug 31, 2018

Throws this error.

Any ideas how to overcome?

2018-08-31 14:41:59,609 StackRunner     - ERROR exec_in_sub                              - ERROR from command:warning: LF will be replaced by CRLF in src/setup.cfg.
The file will have its original line endings in your working directory.
Traceback (most recent call last):
  File "c:\python27amd64\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27amd64\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27amd64\Scripts\bump2version.exe\__main__.py", line 9, in <module>
  File "c:\python27amd64\lib\site-packages\bumpversion\__init__.py", line 938, in main
    vcs.commit(message=commit_message)
  File "c:\python27amd64\lib\site-packages\bumpversion\__init__.py", line 71, in commit
    f = NamedTemporaryFile('wb', delete=False)
  File "c:\python27amd64\lib\tempfile.py", line 475, in NamedTemporaryFile
    (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
  File "c:\python27amd64\lib\tempfile.py", line 245, in _mkstemp_inner
    _set_cloexec(fd)
  File "c:\python27amd64\lib\tempfile.py", line 50, in _set_cloexec
    flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0)
AttributeError: 'module' object has no attribute 'F_GETFD'
@ekohl
Copy link
Collaborator

ekohl commented Aug 31, 2018

Which version are you using? There were very recently various improvements made on Windows but those haven't made it into a release yet. @c4urself is planning one soon though.

@setuk
Copy link
Author

setuk commented Aug 31, 2018

0.5.8

@c4urself
Copy link
Owner

This seems to be a general issue with windows v unix-style OSes' newline character. Could take a look at: https://stackoverflow.com/questions/5834014/lf-will-be-replaced-by-crlf-in-git-what-is-that-and-is-it-important

@Cito
Copy link

Cito commented Apr 30, 2019

This happens even when commit=false. I think bump2version should not change the kind of line endings. If a file uses LFs, it should still have LFs after being processed, even on Windows.

@Cito
Copy link

Cito commented Apr 30, 2019

You can use the following function to detect the newline representation of the file:

def get_newline(filename):
    with open(filename, "rb") as f:
        while True:
            c = f.read(1)
            if not c or c == b'\n':
                break
            if c == b'\r':
                if f.read(1) == b'\n':
                    return '\r\n'
                return '\r'
    return '\n'

Then you can pass the output of this function to the newline parameter of the open() function when writing the file back. (The newline parameter is only supported by Python 3, though.)

@florisla
Copy link
Collaborator

Bump2version no longer modifies line-ending style as of #59.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants