Bug 2365820 - mercurial fails to build with Python 3.14: AttributeError: partially initialized module 'threading' from '/usr/lib64/python3.14/threading.py' has no attribute 'RLock' (most likely due to a circular import)
Summary: mercurial fails to build with Python 3.14: AttributeError: partially initiali...
Keywords:
Status: POST
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.14
TreeView+ depends on / blocked
 
Reported: 2025-05-13 08:45 UTC by Karolina Surma
Modified: 2025-05-13 10:13 UTC (History)
7 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Fedora Package Sources mercurial pull-request 23 0 None None None 2025-05-13 10:13:01 UTC

Description Karolina Surma 2025-05-13 08:45:11 UTC
mercurial fails to build with Python 3.14.0b1.

+ make install-doc DESTDIR=/builddir/build/BUILD/mercurial-7.0.2-build/BUILDROOT MANDIR=/usr/share/man
make -C doc  PREFIX="/usr/local"  install
make[1]: Entering directory '/builddir/build/BUILD/mercurial-7.0.2-build/mercurial-7.0.2/doc'
python3 gendoc.py  commandlist > commandlist.txt.tmp
Traceback (most recent call last):
  File "/builddir/build/BUILD/mercurial-7.0.2-build/mercurial-7.0.2/doc/gendoc.py", line 30, in <module>
  File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1342, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 938, in _load_unlocked
  File "/builddir/build/BUILD/mercurial-7.0.2-build/mercurial-7.0.2/hgdemandimport/demandimportpy3.py", line 54, in exec_module
  File "<frozen importlib.util>", line 260, in exec_module
  File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1342, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 938, in _load_unlocked
  File "/builddir/build/BUILD/mercurial-7.0.2-build/mercurial-7.0.2/hgdemandimport/demandimportpy3.py", line 52, in exec_module
  File "/usr/lib64/python3.14/threading.py", line 6, in <module>
  File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1342, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 938, in _load_unlocked
  File "/builddir/build/BUILD/mercurial-7.0.2-build/mercurial-7.0.2/hgdemandimport/demandimportpy3.py", line 54, in exec_module
  File "<frozen importlib.util>", line 270, in exec_module
AttributeError: partially initialized module 'threading' from '/usr/lib64/python3.14/threading.py' has no attribute 'RLock' (most likely due to a circular import)
python3 gendoc.py  "hg-ssh.8" > hg-ssh.8.txt.tmp
Traceback (most recent call last):
  File "/builddir/build/BUILD/mercurial-7.0.2-build/mercurial-7.0.2/doc/gendoc.py", line 30, in <module>
  File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1342, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 938, in _load_unlocked
  File "/builddir/build/BUILD/mercurial-7.0.2-build/mercurial-7.0.2/hgdemandimport/demandimportpy3.py", line 54, in exec_module
  File "<frozen importlib.util>", line 260, in exec_module
  File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1342, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 938, in _load_unlocked
  File "/builddir/build/BUILD/mercurial-7.0.2-build/mercurial-7.0.2/hgdemandimport/demandimportpy3.py", line 52, in exec_module
  File "/usr/lib64/python3.14/threading.py", line 6, in <module>
  File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1342, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 938, in _load_unlocked
  File "/builddir/build/BUILD/mercurial-7.0.2-build/mercurial-7.0.2/hgdemandimport/demandimportpy3.py", line 54, in exec_module
  File "<frozen importlib.util>", line 270, in exec_module
AttributeError: partially initialized module 'threading' from '/usr/lib64/python3.14/threading.py' has no attribute 'RLock' (most likely due to a circular import)
make[1]: *** [Makefile:174: hg-ssh.8.txt] Error 1

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-b1/fedora-rawhide-x86_64/09024567-mercurial/

For all our attempts to build mercurial with Python 3.14, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14-b1/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.14:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14-b1/

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 Miro Hrončok 2025-05-13 09:30:09 UTC
This very much reminds me of a problem that we saw earlier (bz2299346). Back then, it was fixed by a patch added in https://src.fedoraproject.org/rpms/mercurial/c/f1186a25db41b5bde9bdd37eb2fee05466bf1b0e?branch=389eb5b7d2e8459fe6f91a12fc133c310822f0f4 and later removed in https://src.fedoraproject.org/rpms/mercurial/c/9ee6346e8f42002676d4c943a0775ed4040189ff?branch=rawhide as upstreamed.

Comment 2 Miro Hrončok 2025-05-13 09:35:50 UTC
Indeed, that patch was upstreamed, and the code after fedpkg prep is:

IGNORES = {
    ...
    # threading is locally imported by importlib.util.LazyLoader.exec_module
    '_weakrefset',
    'warnings',
    'threading',
    'collections.abc',
}

https://github.com/python/cpython/commit/d687900f98114bb5910daad9553ae381d7daf94b added a new import to threading, called _contextvars. Perhpas adding that one will fix this?

Comment 3 Miro Hrončok 2025-05-13 09:55:02 UTC
This patch works:

--- a/hgdemandimport/__init__.py
+++ b/hgdemandimport/__init__.py
@@ -60,6 +60,7 @@ IGNORES = {
     'setuptools',
     '_distutils_hack.override',
     # threading is locally imported by importlib.util.LazyLoader.exec_module
+    '_contextvars',
     '_weakrefset',
     'warnings',
     'threading',


I will try to figure out a way to send an upstream merge request.


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