Bug 2246092 - meson doesn't work with Python 3.13: AttributeError: module 'importlib.resources' has no attribute 'path'
Summary: meson doesn't work with Python 3.13: AttributeError: module 'importlib.resour...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: meson
Version: 40
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kalev Lember
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.13
TreeView+ depends on / blocked
 
Reported: 2023-10-25 12:00 UTC by Karolina Surma
Modified: 2024-06-04 14:41 UTC (History)
7 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-06-04 14:41:43 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2023-10-25 12:00:40 UTC
pitivi fails to build with Python 3.13.0a1.

+ /usr/bin/meson setup --buildtype=plain --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/libexec --bindir=/usr/bin --sbindir=/usr/sbin --includedir=/usr/include --datadir=/usr/share --mandir=/usr/share/man --infodir=/usr/share/info --localedir=/usr/share/locale --sysconfdir=/etc --localstatedir=/var --sharedstatedir=/var/lib --wrap-mode=nodownload --auto-features=enabled . redhat-linux-build
Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/mesonbuild/mesonmain.py", line 194, in run
    return options.run_func(options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/msetup.py", line 358, in run
    app.generate()
  File "/usr/lib/python3.13/site-packages/mesonbuild/msetup.py", line 183, in generate
    return self._generate(env, capture, vslite_ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/msetup.py", line 228, in _generate
    intr.run()
  File "/usr/lib/python3.13/site-packages/mesonbuild/interpreter/interpreter.py", line 3002, in run
    super().run()
  File "/usr/lib/python3.13/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 164, in run
    self.evaluate_codeblock(self.ast, start=1)
  File "/usr/lib/python3.13/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 190, in evaluate_codeblock
    raise e
  File "/usr/lib/python3.13/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 182, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/usr/lib/python3.13/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 198, in evaluate_statement
    self.assignment(cur)
  File "/usr/lib/python3.13/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 635, in assignment
    value = self.evaluate_statement(node.value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 200, in evaluate_statement
    return self.method_call(cur)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 550, in method_call
    res = obj.method_call(method_name, args, kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/interpreter/interpreterobjects.py", line 811, in method_call
    ret = method(state, args, kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/interpreterbase/decorators.py", line 109, in wrapped
    ret = f(*wrapped_args, **wrapped_kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/interpreterbase/decorators.py", line 277, in wrapper
    return f(*nargs, **wrapped_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/interpreterbase/decorators.py", line 596, in wrapper
    return f(*wrapped_args, **wrapped_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/modules/python.py", line 437, in find_installation
    python = self._find_installation_impl(state, display_name, name_or_path, required)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/modules/python.py", line 393, in _find_installation_impl
    if python.sanity(state):
       ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/modules/python.py", line 74, in sanity
    ret = super().sanity()
          ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/mesonbuild/dependencies/python.py", line 114, in sanity
    with importlib.resources.path('mesonbuild.scripts', 'python_info.py') as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'importlib.resources' has no attribute 'path'

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/06562697-pitivi/

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

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 Karolina Surma 2023-10-25 12:10:05 UTC
This is in fact meson's bug, let me redirect the bugzilla.

As meson doesn't run the test suite during the build, we've caught the issue only by using it to build dependent packages.
The aforementioned traceback is similar for all of them.

Comment 2 Kalev Lember 2023-10-25 12:26:00 UTC
See https://github.com/mesonbuild/meson/issues/12401 - I can backport this to the package as soon as https://github.com/mesonbuild/meson/pull/12402 lands upstream. Any chance you could look over the upstream fix from Python point of view and see if it looks correct? Thanks!

Comment 3 Karolina Surma 2023-10-25 13:55:18 UTC
I patched meson in our Copr and built another package on top of the patched version, it was successful.

The patch looks fine to me. It follows the migration guide in a straightforward way: https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy

Comment 4 Kalev Lember 2023-10-25 14:40:15 UTC
Excellent, thanks!

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

Comment 6 Kalev Lember 2024-06-04 14:41:43 UTC
https://github.com/python/cpython/issues/116608 added back the missing CPython API, so I think we can close this.


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