Bug 2326226 - python-flit fails to build with Python 3.14: AttributeError: module 'ast' has no attribute 'Str'
Summary: python-flit fails to build with Python 3.14: AttributeError: module 'ast' has...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-flit
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Michel Lind
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 2323329
Blocks: PYTHON3.14
TreeView+ depends on / blocked
 
Reported: 2024-11-14 12:56 UTC by Karolina Surma
Modified: 2024-11-26 11:14 UTC (History)
6 users (show)

Fixed In Version: python-flit-3.10.1-1.fc42
Clone Of:
Environment:
Last Closed: 2024-11-26 11:14:35 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2024-11-14 12:56:46 UTC
python-flit fails to build with Python 3.14.0a1.

74 tests fail similar way:

_______________________ test_wheel_module_local_version ________________________

copy_sample = <function copy_sample.<locals>.copy at 0x7ff2e13cc880>

    def test_wheel_module_local_version(copy_sample):
        """Test if a local version specifier is preserved in wheel filename and dist-info dir name"""
        td = copy_sample('modulewithlocalversion')
>       make_wheel_in(td / 'pyproject.toml', td)

tests/test_wheel.py:220: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
flit/wheel.py:8: in make_wheel_in
    return core_wheel.make_wheel_in(ini_path, wheel_directory, editable)
flit_core/flit_core/wheel.py:223: in make_wheel_in
    wb = WheelBuilder.from_ini_path(ini_path, fp)
flit_core/flit_core/wheel.py:87: in from_ini_path
    metadata = common.make_metadata(module, ini_info)
flit_core/flit_core/common.py:425: in make_metadata
    md_dict.update(get_info_from_module(module, ini_info.dynamic_metadata))
flit_core/flit_core/common.py:220: in get_info_from_module
    docstring, version = get_docstring_and_version_via_ast(target)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

target = <flit_core.common.Module object at 0x7ff2e106fed0>

    def get_docstring_and_version_via_ast(target):
        """
        Return a tuple like (docstring, version) for the given module,
        extracted by parsing its AST.
        """
        version = None
        for target_path in target.version_files:
            # read as bytes to enable custom encodings
            with target_path.open('rb') as f:
                node = ast.parse(f.read())
            for child in node.body:
                # Only use the version from the given module if it's a simple
                # string assignment to __version__
                is_version_str = (
                        isinstance(child, ast.Assign)
                        and any(
                            isinstance(target, ast.Name)
                            and target.id == "__version__"
                            for target in child.targets
                        )
>                       and isinstance(child.value, ast.Str)
                )
E               AttributeError: module 'ast' has no attribute 'Str'

According to: https://docs.python.org/dev/whatsnew/3.14.html#id2

Remove the following classes. They were all deprecated since Python 3.8, and have emitted deprecation warnings since Python 3.12:
ast.Bytes
ast.Ellipsis
ast.NameConstant
ast.Num
ast.Str

Use ast.Constant instead. As a consequence of these removals, user-defined visit_Num, visit_Str, visit_Bytes, visit_NameConstant and visit_Ellipsis methods on custom ast.NodeVisitor subclasses will no longer be called when the NodeVisitor subclass is visiting an AST. Define a visit_Constant method instead.

Also, remove the following deprecated properties on ast.Constant, which were present for compatibility with the now-removed AST classes:
ast.Constant.n
ast.Constant.s

Use ast.Constant.value instead.
(Contributed by Alex Waygood in gh-119562.)


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

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.14/fedora-rawhide-x86_64/08258747-python-flit/

For all our attempts to build python-flit with Python 3.14, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/package/python-flit/

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.14:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/

Let us know here if you have any questions.

Python 3.14 is planned to be included in Fedora 43.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.14.
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 Michel Lind 2024-11-22 20:58:18 UTC
This is fixed in flit 3.10

https://github.com/pypa/flit/commit/6ab62c91d0db451b5e9ab000f0dba5471550b442

Comment 2 Fedora Update System 2024-11-26 11:11:10 UTC
FEDORA-2024-5014580a08 (python-flit-3.10.1-1.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-5014580a08

Comment 3 Fedora Update System 2024-11-26 11:14:35 UTC
FEDORA-2024-5014580a08 (python-flit-3.10.1-1.fc42) has been pushed to the Fedora 42 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.