Bug 2246135

Summary: python-autopep8 fails to build with Python 3.13: ModuleNotFoundError: No module named 'lib2to3'
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-autopep8Assignee: Christiano Anderson <chris>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 40CC: chris, ksurma, mhroncok, neuro-sig
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-autopep8-2.1.0-1.fc41 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-05-04 12:32:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2244836    

Description Karolina Surma 2023-10-25 14:33:47 UTC
python-autopep8 fails to build with Python 3.13.0a1.

_________ ConfigurationFileTests.test_setupcfg_with_pycodestyle_config _________

self = <test.test_autopep8.ConfigurationFileTests testMethod=test_setupcfg_with_pycodestyle_config>

    def test_setupcfg_with_pycodestyle_config(self):
        line = "a =  1\n"
        fixed = "a = 1\n"
        setupcfg_flake8 = """[pycodestyle]\ndiff=True\nignore="E,W"\n"""
        with temporary_project_directory() as dirname:
            with open(os.path.join(dirname, "setup.cfg"), "w") as fp:
                fp.write(setupcfg_flake8)
            target_filename = os.path.join(dirname, "foo.py")
            with open(target_filename, "w") as fp:
                fp.write(line)
            p = Popen(list(AUTOPEP8_CMD_TUPLE) +
                      [target_filename, "-v"], stdout=PIPE)
            output = p.communicate()[0].decode("utf-8")
>           self.assertTrue(fixed in output)
E           AssertionError: False is not true

test/test_autopep8.py:6050: AssertionError
----------------------------- Captured stderr call -----------------------------
[file:/tmp/autopep8testpu5hd_b_/foo.py]
Traceback (most recent call last):
  File "/builddir/build/BUILD/autopep8-2.0.4/autopep8.py", line 4578, in <module>
    sys.exit(main())
             ^^^^^^
  File "/builddir/build/BUILD/autopep8-2.0.4/autopep8.py", line 4536, in main
    results = fix_multiple_files(args.files, args, sys.stdout)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/autopep8-2.0.4/autopep8.py", line 4431, in fix_multiple_files
    ret = _fix_file((name, options, output))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/autopep8-2.0.4/autopep8.py", line 4401, in _fix_file
    return fix_file(*parameters)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/autopep8-2.0.4/autopep8.py", line 3585, in fix_file
    original_source = readlines_from_file(filename)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/autopep8-2.0.4/autopep8.py", line 195, in readlines_from_file
    with open_with_encoding(filename) as input_file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/autopep8-2.0.4/autopep8.py", line 172, in open_with_encoding
    encoding = detect_encoding(filename, limit_byte_check=limit_byte_check)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/autopep8-2.0.4/autopep8.py", line 182, in detect_encoding
    from lib2to3.pgen2 import tokenize as lib2to3_tokenize
ModuleNotFoundError: No module named 'lib2to3'
=========================== short test summary info ============================
FAILED test/test_autopep8.py::UnitTests::test_detect_encoding - ModuleNotFoun...
FAILED test/test_autopep8.py::UnitTests::test_detect_encoding_with_cookie - M...
FAILED test/test_autopep8.py::UnitTests::test_fix_2to3 - ModuleNotFoundError:...
FAILED test/test_autopep8.py::UnitTests::test_fix_2to3_subset - ModuleNotFoun...
FAILED test/test_autopep8.py::UnitTests::test_fix_file - ModuleNotFoundError:...
FAILED test/test_autopep8.py::UnitTests::test_fix_file_with_diff - ModuleNotF...
FAILED test/test_autopep8.py::UnitTests::test_format_block_comments - ModuleN...
FAILED test/test_autopep8.py::UnitTests::test_format_block_comments_should_leave_outline_alone
FAILED test/test_autopep8.py::UnitTests::test_format_block_comments_should_not_corrupt_special_comments
FAILED test/test_autopep8.py::UnitTests::test_format_block_comments_should_only_touch_real_comments
FAILED test/test_autopep8.py::UnitTests::test_format_block_comments_with_multiple_lines
FAILED test/test_autopep8.py::UnitTests::test_is_python_file - ModuleNotFound...
FAILED test/test_autopep8.py::UnitTests::test_match_file - ModuleNotFoundErro...
FAILED test/test_autopep8.py::UnitTests::test_readlines_from_file_with_bad_encoding
FAILED test/test_autopep8.py::UnitTests::test_readlines_from_file_with_bad_encoding2
FAILED test/test_autopep8.py::ConfigurationFileTests::test_pyproject_toml_with_flake8_config
FAILED test/test_autopep8.py::ConfigurationFileTests::test_pyproject_toml_with_iterable_value
FAILED test/test_autopep8.py::ConfigurationFileTests::test_pyproject_toml_with_verbose_option
FAILED test/test_autopep8.py::ConfigurationFileTests::test_setupcfg_with_flake8_config
FAILED test/test_autopep8.py::ConfigurationFileTests::test_setupcfg_with_pycodestyle_config
================ 20 failed, 74 passed, 462 deselected in 3.97s =================

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

- lib2to3 will be removed from Python 3.13

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

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

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 Christiano Anderson 2023-10-28 08:10:25 UTC
Thanks for opening this ticket, I'm working on this

Comment 2 Fedora Admin user for bugzilla script actions 2024-02-10 12:24:38 UTC
This package has changed maintainer in Fedora. Reassigning to the new maintainer of this component.

Comment 3 Aoife Moloney 2024-02-15 23:01:55 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 40 development cycle.
Changing version to 40.

Comment 4 Christiano Anderson 2024-05-03 18:24:20 UTC
Version 2.1.0 on rawhide fixes the issues with Python 3.13.x

Comment 5 Fedora Update System 2024-05-04 12:29:07 UTC
FEDORA-2024-bfd4b6f8e6 (python-autopep8-2.1.0-1.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-bfd4b6f8e6

Comment 6 Fedora Update System 2024-05-04 12:32:52 UTC
FEDORA-2024-bfd4b6f8e6 (python-autopep8-2.1.0-1.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.