Bug 2246059 - mercurial fails to build with Python 3.13: AttributeError: module 'importlib.resources' has no attribute 'contents'
Summary: mercurial fails to build with Python 3.13: AttributeError: module 'importlib....
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: mercurial
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Mads Kiilerich
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.13
TreeView+ depends on / blocked
 
Reported: 2023-10-25 08:03 UTC by Karolina Surma
Modified: 2024-08-21 20:40 UTC (History)
7 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-08-21 20:40:18 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2023-10-25 08:03:31 UTC
mercurial fails to build with Python 3.13.0a1.

mercurial/cext/util.h: In function '_dict_new_presized':
mercurial/cext/util.h:65:16: error: implicit declaration of function '_PyDict_NewPresized'; did you mean '_dict_new_presized'? [-Werror=implicit-function-declaration]
   65 |         return _PyDict_NewPresized(((1 + expected_size) / 2) * 3);
      |                ^~~~~~~~~~~~~~~~~~~
      |                _dict_new_presized

contrib/python-zstandard/zstd.c: In function 'cpu_count':
contrib/python-zstandard/zstd.c:288:17: error: implicit declaration of function 'sysconf'; did you mean 'sscanf'? [-Werror=implicit-function-declaration]
  288 |         count = sysconf(_SC_NPROCESSORS_ONLN);
      |                 ^~~~~~~
      |                 sscanf


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

Python.h no longer includes the <unistd.h> standard header file.
If needed, it should now be included explicitly.
For example, it provides the functions: read(), write(), close(), isatty(), lseek(), getpid(), getcwd(), sysconf() and getpagesize().
As a consequence, _POSIX_SEMAPHORES and _POSIX_THREADS macros are no longer defined by Python.h.
The HAVE_UNISTD_H and HAVE_PTHREAD_H macros defined by Python.h can be used to decide if <unistd.h> and <pthread.h> header files can be included.
(Contributed by Victor Stinner in gh-108765.)


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/06561249-mercurial/

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

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 2024-01-11 10:21:14 UTC
The previous errors have been apparently mitigated with the next alpha.

Currently mercurial fails to build with this error:

/usr/bin/python3 gendoc.py "hg-ssh.8" > hg-ssh.8.txt.tmp
Traceback (most recent call last):
  File "/builddir/build/BUILD/mercurial-6.6.1/doc/gendoc.py", line 336, in <module>
    ui = uimod.ui.load()
         ^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/mercurial-6.6.1/mercurial/ui.py", line 339, in load
    for t, f in rcutil.rccomponents():
                ^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/mercurial-6.6.1/mercurial/rcutil.py", line 98, in rccomponents
    _rccomponents = [(b'resource', r) for r in default_rc_resources()]
                                               ^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/mercurial-6.6.1/mercurial/rcutil.py", line 68, in default_rc_resources
    for r in sorted(rsrcs)
             ^^^^^^^^^^^^^
  File "/builddir/build/BUILD/mercurial-6.6.1/mercurial/utils/resourceutil.py", line 118, in contents
    for r in resources.contents(pycompat.sysstr(package)):
             ^^^^^^^^^^^^^^^^^^
AttributeError: module 'importlib.resources' has no attribute 'contents'

Comment 2 Mads Kiilerich 2024-01-13 14:20:04 UTC
Patch proposed upstream: https://lists.mercurial-scm.org/pipermail/mercurial-devel/2024-January/297839.html

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

Comment 4 Karolina Surma 2024-04-04 10:38:23 UTC
I attempted to apply the patch downstream to build mercurial in our Python 3.13 copr. It builds! There's a typo in the patch:

yield encoding.strtolocal(path.name) should be: yield encoding.strtolocal(resource.name) - otherwise it throws NameError.


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