Skip to content

Add Support for MSYS2 in Windows #1605

@danyeaw

Description

@danyeaw

Thanks @asottile and all the other contributors for the great tool! ❤️ 👍

I am one of the maintainers for Gaphor, and we make heavy use of pre-commit as part of our work flow. It is also built in GTK, and we have to use MSYS2 to build the app for Windows. I know it is a pretty niche environment to support, but it would be really great if we could make it happen.

Current Behavior

version information

pre-commit version: 2.7.1
sys.version:
    3.8.5 (default, Sep  7 2020, 18:26:56)  [GCC 10.2.0 64 bit (AMD64)]
sys.executable: c:/tools/msys64/home/dyeaw/gaphor/.venv/bin/python.exe
os.name: nt
sys.platform: win32

error information

An unexpected error has occurred: FileNotFoundError: [WinError 3] The system cannot find the path specified: '/home/dyeaw/gaphor'
Traceback (most recent call last):
  File "C:/tools/msys64/home/dyeaw/gaphor/.venv/lib/python3.8/site-packages/pre_commit/error_handler.py", line 63, in error_handler
    yield
  File "C:/tools/msys64/home/dyeaw/gaphor/.venv/lib/python3.8/site-packages/pre_commit/main.py", line 343, in main
    _adjust_args_and_chdir(args)
  File "C:/tools/msys64/home/dyeaw/gaphor/.venv/lib/python3.8/site-packages/pre_commit/main.py", line 163, in _adjust_args_and_chdir
    os.chdir(toplevel)
FileNotFoundError: [WinError 3] The system cannot find the path specified: '/home/dyeaw/gaphor'

Updates Needed

  • Update pre-commit to make use of the cygpath command to convert the path to the standard Windows path format after it gets the top-level path from git.
  • Remove cygwin warnings about incompatible Python+git versions if in the MSYS2 environment
  • Make upstream updates to setuptools_scm to patch additional path conversions for similar things as 1 above.

My plan, as long is everyone is good with adding support for this environment, is to submit a PR for the first two, and then I'll start to work with the setuptools_scm team to see if I can fix the third one as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions