editorconfig-checker / editorconfig-checker.python

A tool to verify that your files are in harmony with your .editorconfig
Other
38 stars 6 forks source link

Potentially incompatible with Python 3.12? #28

Closed Mikaela closed 1 year ago

Mikaela commented 1 year ago

I am trying to use editorconfig-checker.python with pre-commit on Fedora 39 (beta) and I keep getting the error log (/home/aminda/.cache/pre-commit/pre-commit.log) below.

Workaround: when I override pre-commit to use Python3.10 or pypy3 as below, everything works. Using Python 3.11 resulted to the same issue. edit about an hour later: 3.11 seems to work now, maybe I misspelled it earlier in .pre-commit-config.yaml or something.

# .pre-commit-config.yaml
default_language_version:
  python: python3.10

version information

pre-commit version: 3.4.0
git --version: git version 2.41.0
sys.version:
    3.12.0rc3 (main, Sep 19 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)]
sys.executable: /usr/bin/python3
os.name: posix
sys.platform: linux

error information

An unexpected error has occurred: CalledProcessError: command: ('/home/aminda/.cache/pre-commit/repo95lw_aku/py_env-python3/bin/python', '-mpip', 'install', '.')
return code: 1
stdout:
    Processing /home/aminda/.cache/pre-commit/repo95lw_aku
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'done'
    Building wheels for collected packages: editorconfig-checker
      Building wheel for editorconfig-checker (pyproject.toml): started
      Building wheel for editorconfig-checker (pyproject.toml): finished with status 'error'
    Failed to build editorconfig-checker
stderr:
      error: subprocess-exited-with-error

      × Building wheel for editorconfig-checker (pyproject.toml) did not run successfully.
      │ exit code: 1
      ╰─> [4 lines of output]
          running bdist_wheel
          running build
          running fetch_binaries
          error: [Errno 17] File exists: 'build/temp.linux-x86_64-cpython-312'
          [end of output]

      note: This error originates from a subprocess, and is likely not a problem with pip.
      ERROR: Failed building wheel for editorconfig-checker
    ERROR: Could not build wheels for editorconfig-checker, which is required to install pyproject.toml-based projects
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/pre_commit/error_handler.py", line 73, in error_handler
    yield
  File "/usr/lib/python3.12/site-packages/pre_commit/main.py", line 414, in main
    return run(args.config, store, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pre_commit/commands/run.py", line 442, in run
    install_hook_envs(to_install, store)
  File "/usr/lib/python3.12/site-packages/pre_commit/repository.py", line 248, in install_hook_envs
    _hook_install(hook)
  File "/usr/lib/python3.12/site-packages/pre_commit/repository.py", line 95, in _hook_install
    lang.install_environment(
  File "/usr/lib/python3.12/site-packages/pre_commit/languages/python.py", line 214, in install_environment
    lang_base.setup_cmd(prefix, install_cmd)
  File "/usr/lib/python3.12/site-packages/pre_commit/lang_base.py", line 86, in setup_cmd
    cmd_output_b(*cmd, cwd=prefix.prefix_dir, **kwargs)
  File "/usr/lib/python3.12/site-packages/pre_commit/util.py", line 110, in cmd_output_b
    raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/home/aminda/.cache/pre-commit/repo95lw_aku/py_env-python3/bin/python', '-mpip', 'install', '.')
return code: 1
stdout:
    Processing /home/aminda/.cache/pre-commit/repo95lw_aku
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'done'
    Building wheels for collected packages: editorconfig-checker
      Building wheel for editorconfig-checker (pyproject.toml): started
      Building wheel for editorconfig-checker (pyproject.toml): finished with status 'error'
    Failed to build editorconfig-checker
stderr:
      error: subprocess-exited-with-error

      × Building wheel for editorconfig-checker (pyproject.toml) did not run successfully.
      │ exit code: 1
      ╰─> [4 lines of output]
          running bdist_wheel
          running build
          running fetch_binaries
          error: [Errno 17] File exists: 'build/temp.linux-x86_64-cpython-312'
          [end of output]

      note: This error originates from a subprocess, and is likely not a problem with pip.
      ERROR: Failed building wheel for editorconfig-checker
    ERROR: Could not build wheels for editorconfig-checker, which is required to install pyproject.toml-based projects
marktsuchida commented 1 year ago

I see very similar errors (full logs below) with Python 3.11 on macOS, and #25 (Python 3.11, Linux) also seems to be related. Some details of the errors differ but the main [Errno 17] File exists error is equivalent.

In my hands, the installation always succeeds immediately after clearing the pre-commit cache (rm -rf ~/.cache/pre-commit).

However, after a successful install triggered by git commit, running pre-commit run triggers the error. Conversely, after a successful install triggered by pre-commit run, running git commit triggers the error.

But after running pre-commit uninstall followed by pre-commit install and pre-commit run, git commit would no longer trigger a rebuild and would succeed. This is a better workaround/fix than clearing the pre-commit cache (if it works; I did not try this without also clearing the cache).

So it's possible my git hook was installed by an older version of pre-commit (or at least one that somehow causes cache invalidation). At least in my case, it seems that the issue was caused by the version of pre-commit used to install the git hook and the version used to (directly) run being mismatched.

I use several different hooks across several projects and have only encountered this issue with editorconfig-checker.python, so it does seem specific to how this hook builds. Presumably other hooks do not have an issue being rebuilt within the same pre-commit cache repo.


pre-commit.log from failed 'git commit' following successful 'pre-commit run' after clearing pre-commit cache ### version information ``` pre-commit version: 3.4.0 git --version: git version 2.42.0 sys.version: 3.11.5 (main, Aug 24 2023, 15:09:45) [Clang 14.0.3 (clang-1403.0.22.14.1)] sys.executable: /opt/homebrew/Cellar/pre-commit/3.4.0/libexec/bin/python3 os.name: posix sys.platform: darwin ``` ### error information ``` An unexpected error has occurred: CalledProcessError: command: ('/Users/mark/.cache/pre-commit/repo1wi4m3re/py_env-python3/bin/python', '-mpip', 'install', '.') return code: 1 stdout: Processing /Users/mark/.cache/pre-commit/repo1wi4m3re Preparing metadata (setup.py): started Preparing metadata (setup.py): finished with status 'done' Building wheels for collected packages: editorconfig-checker Building wheel for editorconfig-checker (setup.py): started Building wheel for editorconfig-checker (setup.py): finished with status 'error' Running setup.py clean for editorconfig-checker Failed to build editorconfig-checker stderr: error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [4 lines of output] running bdist_wheel running build running fetch_binaries error: [Errno 17] File exists: 'build/temp.macosx-13-arm64-cpython-311' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for editorconfig-checker ERROR: Could not build wheels for editorconfig-checker, which is required to install pyproject.toml-based projects ``` ``` Traceback (most recent call last): File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/error_handler.py", line 73, in error_handler yield File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/main.py", line 386, in main return hook_impl( ^^^^^^^^^^ File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/commands/hook_impl.py", line 271, in hook_impl return retv | run(config, store, ns) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/commands/run.py", line 442, in run install_hook_envs(to_install, store) File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/repository.py", line 248, in install_hook_envs _hook_install(hook) File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/repository.py", line 95, in _hook_install lang.install_environment( File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/languages/python.py", line 214, in install_environment lang_base.setup_cmd(prefix, install_cmd) File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/lang_base.py", line 86, in setup_cmd cmd_output_b(*cmd, cwd=prefix.prefix_dir, **kwargs) File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/util.py", line 110, in cmd_output_b raise CalledProcessError(returncode, cmd, stdout_b, stderr_b) pre_commit.util.CalledProcessError: command: ('/Users/mark/.cache/pre-commit/repo1wi4m3re/py_env-python3/bin/python', '-mpip', 'install', '.') return code: 1 stdout: Processing /Users/mark/.cache/pre-commit/repo1wi4m3re Preparing metadata (setup.py): started Preparing metadata (setup.py): finished with status 'done' Building wheels for collected packages: editorconfig-checker Building wheel for editorconfig-checker (setup.py): started Building wheel for editorconfig-checker (setup.py): finished with status 'error' Running setup.py clean for editorconfig-checker Failed to build editorconfig-checker stderr: error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [4 lines of output] running bdist_wheel running build running fetch_binaries error: [Errno 17] File exists: 'build/temp.macosx-13-arm64-cpython-311' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for editorconfig-checker ERROR: Could not build wheels for editorconfig-checker, which is required to install pyproject.toml-based projects ```
pre-commit.log from failed 'pre-commit run' following successful 'git commit' after clearing pre-commit cache ### version information ``` pre-commit version: 3.4.0 git --version: git version 2.42.0 sys.version: 3.11.5 (main, Aug 24 2023, 15:09:45) [Clang 14.0.3 (clang-1403.0.22.14.1)] sys.executable: /opt/homebrew/Cellar/pre-commit/3.4.0/libexec/bin/python os.name: posix sys.platform: darwin ``` ### error information ``` An unexpected error has occurred: CalledProcessError: command: ('/Users/mark/.cache/pre-commit/repo_abmjkpo/py_env-python3.11/bin/python', '-mpip', 'install', '.') return code: 1 stdout: Processing /Users/mark/.cache/pre-commit/repo_abmjkpo Preparing metadata (setup.py): started Preparing metadata (setup.py): finished with status 'done' Building wheels for collected packages: editorconfig-checker Building wheel for editorconfig-checker (setup.py): started Building wheel for editorconfig-checker (setup.py): finished with status 'error' Running setup.py clean for editorconfig-checker Failed to build editorconfig-checker stderr: error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [4 lines of output] running bdist_wheel running build running fetch_binaries error: [Errno 17] File exists: 'build/temp.macosx-13-arm64-cpython-311' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for editorconfig-checker ERROR: Could not build wheels for editorconfig-checker, which is required to install pyproject.toml-based projects ``` ``` Traceback (most recent call last): File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/error_handler.py", line 73, in error_handler yield File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/main.py", line 414, in main return run(args.config, store, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/commands/run.py", line 442, in run install_hook_envs(to_install, store) File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/repository.py", line 248, in install_hook_envs _hook_install(hook) File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/repository.py", line 95, in _hook_install lang.install_environment( File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/languages/python.py", line 214, in install_environment lang_base.setup_cmd(prefix, install_cmd) File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/lang_base.py", line 86, in setup_cmd cmd_output_b(*cmd, cwd=prefix.prefix_dir, **kwargs) File "/opt/homebrew/Cellar/pre-commit/3.4.0/libexec/lib/python3.11/site-packages/pre_commit/util.py", line 110, in cmd_output_b raise CalledProcessError(returncode, cmd, stdout_b, stderr_b) pre_commit.util.CalledProcessError: command: ('/Users/mark/.cache/pre-commit/repo_abmjkpo/py_env-python3.11/bin/python', '-mpip', 'install', '.') return code: 1 stdout: Processing /Users/mark/.cache/pre-commit/repo_abmjkpo Preparing metadata (setup.py): started Preparing metadata (setup.py): finished with status 'done' Building wheels for collected packages: editorconfig-checker Building wheel for editorconfig-checker (setup.py): started Building wheel for editorconfig-checker (setup.py): finished with status 'error' Running setup.py clean for editorconfig-checker Failed to build editorconfig-checker stderr: error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [4 lines of output] running bdist_wheel running build running fetch_binaries error: [Errno 17] File exists: 'build/temp.macosx-13-arm64-cpython-311' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for editorconfig-checker ERROR: Could not build wheels for editorconfig-checker, which is required to install pyproject.toml-based projects ```
asottile commented 1 year ago

this is a derivative work of shellcheck-py and is currently violating the license by not including a copy of it

it's also missing the fix for this problem -- https://github.com/shellcheck-py/shellcheck-py/pull/91

mmicu commented 1 year ago

this is a derivative work of shellcheck-py and is currently violating the license by not including a copy of it

it's also missing the fix for this problem -- shellcheck-py/shellcheck-py#91

Hi @asottile, thanks for the feedbacks.

I will provide the fixes in a temporary branch soon.

mmicu commented 1 year ago

Hi @Mikaela, thanks for reporting the issue. I was able to replicate it locally and the fix suggested by @asottile worked fine.

I'd like to wait for editorconfig-checker/pull/292 before creating an official release.

mstruebing commented 1 year ago

@mmicu it's finally there 🎉 : https://github.com/editorconfig-checker/editorconfig-checker/releases/tag/2.7.2

mmicu commented 1 year ago

Thank you, @mstruebing.

The new version 2.7.3 is available now.