Bug 2247263 - pre-commit fails to build with Python 3.13: AttributeError: module 'importlib.resources' has no attribute 'read_text'
Summary: pre-commit fails to build with Python 3.13: AttributeError: module 'importlib...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: pre-commit
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Artem
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.13
TreeView+ depends on / blocked
 
Reported: 2023-10-31 15:00 UTC by Karolina Surma
Modified: 2023-11-03 14:34 UTC (History)
7 users (show)

Fixed In Version: pre-commit-3.5.0-2.fc40
Clone Of:
Environment:
Last Closed: 2023-11-03 14:34:12 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2023-10-31 15:00:01 UTC
pre-commit fails to build with Python 3.13.0a1.

____________________________ test_ruby_hook_default ____________________________
[gw3] linux -- Python 3.13.0 /usr/bin/python3

tmp_path = PosixPath('/tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_ruby_hook_default0')

    @xfailif_windows  # pragma: win32 no cover
    def test_ruby_hook_default(tmp_path):
        _setup_hello_world(tmp_path)
    
>       out, ret = run_language(tmp_path, ruby, 'rbenv --help', version='default')

tests/languages/ruby_test.py:104: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
testing/language_helpers.py:26: in run_language
    language.install_environment(prefix, version, deps)
pre_commit/languages/ruby.py:120: in install_environment
    _install_rbenv(prefix, version)
pre_commit/languages/ruby.py:93: in _install_rbenv
    _extract_resource('rbenv.tar.gz', prefix.path('.'))
pre_commit/languages/ruby.py:82: in _extract_resource
    with _resource_bytesio(filename) as bio:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

filename = 'rbenv.tar.gz'

    def _resource_bytesio(filename: str) -> IO[bytes]:
>       return importlib.resources.open_binary('pre_commit.resources', filename)
E       AttributeError: module 'importlib.resources' has no attribute 'open_binary'

pre_commit/languages/ruby.py:28: AttributeError
=========================== short test summary info ============================
FAILED tests/repository_test.py::test_default_language_version - AttributeErr...
FAILED tests/repository_test.py::test_default_stages - AttributeError: module...
FAILED tests/commands/install_uninstall_test.py::test_replace_old_commit_script
FAILED tests/commands/gc_test.py::test_gc_unused_local_repo_with_env - Attrib...
FAILED tests/commands/install_uninstall_test.py::test_installs_hooks_with_hooks_True
FAILED tests/commands/install_uninstall_test.py::test_install_hooks_command
FAILED tests/commands/install_uninstall_test.py::test_pre_push_integration_failing
FAILED tests/commands/install_uninstall_test.py::test_pre_push_integration_accepted
FAILED tests/commands/install_uninstall_test.py::test_install_pre_commit_and_run
FAILED tests/commands/install_uninstall_test.py::test_pre_push_force_push_without_fetch
FAILED tests/commands/install_uninstall_test.py::test_install_pre_commit_and_run_custom_path
FAILED tests/commands/init_templatedir_test.py::test_init_templatedir - Attri...
FAILED tests/commands/install_uninstall_test.py::test_pre_push_new_upstream
FAILED tests/commands/init_templatedir_test.py::test_init_templatedir_already_set
FAILED tests/commands/init_templatedir_test.py::test_init_templatedir_not_set
FAILED tests/commands/init_templatedir_test.py::test_init_templatedir_expanduser
FAILED tests/commands/install_uninstall_test.py::test_pre_push_environment_variables
FAILED tests/commands/install_uninstall_test.py::test_install_in_submodule_and_run
FAILED tests/commands/install_uninstall_test.py::test_pre_push_integration_empty_push
FAILED tests/commands/install_uninstall_test.py::test_install_in_worktree_and_run
FAILED tests/commands/install_uninstall_test.py::test_pre_push_legacy - Attri...
FAILED tests/commands/install_uninstall_test.py::test_commit_am - AttributeEr...
FAILED tests/commands/install_uninstall_test.py::test_commit_msg_integration_failing
FAILED tests/commands/install_uninstall_test.py::test_unicode_merge_commit_message
FAILED tests/commands/install_uninstall_test.py::test_commit_msg_integration_passing
FAILED tests/commands/install_uninstall_test.py::test_commit_msg_legacy - Att...
FAILED tests/commands/install_uninstall_test.py::test_install_idempotent - At...
FAILED tests/commands/init_templatedir_test.py::test_init_templatedir_hookspath_set
FAILED tests/commands/init_templatedir_test.py::test_init_templatedir_skip_on_missing_config[True-0-Skipping `pre-commit`.]
FAILED tests/commands/install_uninstall_test.py::test_post_commit_integration
FAILED tests/commands/init_templatedir_test.py::test_init_templatedir_skip_on_missing_config[False-1-No .pre-commit-config.yaml file was found]
FAILED tests/commands/install_uninstall_test.py::test_environment_not_sourced
FAILED tests/commands/install_uninstall_test.py::test_post_merge_integration
FAILED tests/commands/install_uninstall_test.py::test_install_pre_commit - At...
FAILED tests/commands/install_uninstall_test.py::test_failing_hooks_returns_nonzero
FAILED tests/commands/install_uninstall_test.py::test_pre_rebase_integration
FAILED tests/commands/install_uninstall_test.py::test_install_hooks_directory_not_present
FAILED tests/commands/install_uninstall_test.py::test_post_rewrite_integration
FAILED tests/commands/install_uninstall_test.py::test_install_multiple_hooks_at_once
FAILED tests/commands/install_uninstall_test.py::test_install_existing_hooks_no_overwrite
FAILED tests/commands/install_uninstall_test.py::test_install_hooks_dead_symlink
FAILED tests/commands/install_uninstall_test.py::test_post_checkout_integration
FAILED tests/commands/install_uninstall_test.py::test_legacy_overwriting_legacy_hook
FAILED tests/commands/install_uninstall_test.py::test_uninstall - AttributeEr...
FAILED tests/commands/install_uninstall_test.py::test_skips_post_checkout_unstaged_changes
FAILED tests/commands/install_uninstall_test.py::test_prepare_commit_msg_integration_failing
FAILED tests/commands/install_uninstall_test.py::test_install_existing_hook_no_overwrite_idempotent
FAILED tests/commands/install_uninstall_test.py::test_install_with_existing_non_utf8_script
FAILED tests/commands/install_uninstall_test.py::test_prepare_commit_msg_integration_passing
FAILED tests/commands/install_uninstall_test.py::test_prepare_commit_msg_legacy
FAILED tests/commands/install_uninstall_test.py::test_failing_existing_hook_returns_1
FAILED tests/commands/install_uninstall_test.py::test_pre_merge_commit_integration
FAILED tests/commands/install_uninstall_test.py::test_install_overwrite_no_existing_hooks
FAILED tests/commands/install_uninstall_test.py::test_install_disallow_missing_config
FAILED tests/commands/install_uninstall_test.py::test_install_overwrite - Att...
FAILED tests/commands/install_uninstall_test.py::test_uninstall_restores_legacy_hooks
FAILED tests/commands/install_uninstall_test.py::test_install_allow_missing_config
FAILED tests/commands/install_uninstall_test.py::test_install_temporarily_allow_mising_config
FAILED tests/commands/install_uninstall_test.py::test_install_uninstall_default_hook_types
FAILED tests/commands/run_test.py::test_skip_bypasses_installation - Attribut...
FAILED tests/commands/run_test.py::test_skip_alias_bypasses_installation - At...
FAILED tests/commands/run_test.py::test_stdout_write_bug_py26 - AttributeErro...
FAILED tests/commands/run_test.py::test_lots_of_files - AttributeError: modul...
FAILED tests/languages/ruby_test.py::test_archive_root_stat[rbenv.tar.gz] - A...
FAILED tests/languages/ruby_test.py::test_archive_root_stat[ruby-download.tar.gz]
FAILED tests/languages/ruby_test.py::test_archive_root_stat[ruby-build.tar.gz]
FAILED tests/languages/ruby_test.py::test_ruby_hook_default - AttributeError:...
====== 67 failed, 605 passed, 1 skipped, 3 xfailed, 17 warnings in 15.58s ======


The deprecated importlib.resources methods were removed from Python 3.13:
- contents()
- is_resource()
- open_binary()
- open_text()
- path()
- read_binary()
- read_text()
Use files() instead. Refer to importlib-resources: Migrating from Legacy for migration advice.
https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy


https://docs.python.org/3.13/whatsnew/3.13.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/06584919-pre-commit/

For all our attempts to build pre-commit with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/pre-commit/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.13:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/

Let us know here if you have any questions.

Python 3.13 is planned to be included in Fedora 41.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Fedora Update System 2023-11-03 14:33:50 UTC
FEDORA-2023-09e7800af6 has been submitted as an update to Fedora 40. https://bodhi.fedoraproject.org/updates/FEDORA-2023-09e7800af6

Comment 2 Fedora Update System 2023-11-03 14:34:12 UTC
FEDORA-2023-09e7800af6 has been pushed to the Fedora 40 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.