Bug 2265488 - python-mccabe fails to build with Python 3.13: NameError: name 'settings' is not defined
Summary: python-mccabe fails to build with Python 3.13: NameError: name 'settings' is ...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: python-mccabe
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Gwyn Ciesla
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 2264611
Blocks: PYTHON3.13
TreeView+ depends on / blocked
 
Reported: 2024-02-22 10:29 UTC by Karolina Surma
Modified: 2024-02-25 15:10 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-02-25 15:10:55 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2024-02-22 10:29:01 UTC
python-mccabe fails to build with Python 3.13.0a4.

+ /usr/bin/pytest -v
============================= test session starts ==============================
platform linux -- Python 3.13.0a4, pytest-7.4.3, pluggy-1.3.0 -- /usr/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/builddir/build/BUILD/mccabe-0.7.0/.hypothesis/examples'))
rootdir: /builddir/build/BUILD/mccabe-0.7.0
plugins: hypothesis-6.98.8
collecting ... collected 0 items / 1 error

==================================== ERRORS ====================================
_______________________ ERROR collecting test_mccabe.py ________________________
/usr/lib/python3.13/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
/usr/lib/python3.13/site-packages/_pytest/runner.py:372: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.13/site-packages/_pytest/python.py:531: in collect
    self._inject_setup_module_fixture()
/usr/lib/python3.13/site-packages/_pytest/python.py:545: in _inject_setup_module_fixture
    self.obj, ("setUpModule", "setup_module")
/usr/lib/python3.13/site-packages/_pytest/python.py:310: in obj
    self._obj = obj = self._getobj()
/usr/lib/python3.13/site-packages/_pytest/python.py:528: in _getobj
    return self._importtestmodule()
/usr/lib/python3.13/site-packages/_pytest/python.py:617: in _importtestmodule
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
/usr/lib/python3.13/site-packages/_pytest/pathlib.py:567: in import_path
    importlib.import_module(module_name)
/usr/lib64/python3.13/importlib/__init__.py:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1387: in _gcd_import
    ???
<frozen importlib._bootstrap>:1360: in _find_and_load
    ???
<frozen importlib._bootstrap>:1331: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:935: in _load_unlocked
    ???
/usr/lib/python3.13/site-packages/_pytest/assertion/rewrite.py:186: in exec_module
    exec(co, module.__dict__)
test_mccabe.py:244: in <module>
    @settings(
E   NameError: name 'settings' is not defined
=========================== short test summary info ============================
ERROR test_mccabe.py - NameError: name 'settings' is not defined
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.61s ===============================

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/07046862-python-mccabe/

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

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 Miro Hrončok 2024-02-22 11:00:34 UTC
The last time this happened in bz2261579, it was caused by a failure in: https://github.com/PyCQA/mccabe/blob/0.7.0/test_mccabe.py#L10

I said the try-except import is bogus because if it fails, @settings is undefined. Gwyn said upstream apparently knows and isn't concerned.

Running the import without the try-except guard will likely reveal the real issue.

Comment 2 Miro Hrončok 2024-02-22 11:02:36 UTC
$ mock -r fedora-rawhide-python313 --enablerepo=local install python3-hypothes{mith,is}
...
Installing:                                                                     
 python3-hypothesis                noarch 6.98.8-2.fc41     python313    4.1 MiB
 python3-hypothesmith              noarch 0.2.0-12.fc41     python313  115.4 KiB
...

$ mock -r fedora-rawhide-python313 shell --unpriv
<mock-chroot> sh-5.2$ python3
Python 3.13.0a4 (main, Feb 21 2024, 00:00:00) [GCC 14.0.1 20240217 (Red Hat 14.0.1-0)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hypothesmith
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    import hypothesmith
  File "/usr/lib/python3.13/site-packages/hypothesmith/__init__.py", line 3, in <module>
    from hypothesmith.cst import from_node
  File "/usr/lib/python3.13/site-packages/hypothesmith/cst.py", line 24, in <module>
    from hypothesmith.syntactic import identifiers
  File "/usr/lib/python3.13/site-packages/hypothesmith/syntactic.py", line 12, in <module>
    from hypothesis.internal.charmap import _union_intervals
ImportError: cannot import name '_union_intervals' from 'hypothesis.internal.charmap' (/usr/lib/python3.13/site-packages/hypothesis/internal/charmap.py)

Comment 3 Miro Hrončok 2024-02-22 11:05:51 UTC
This is actually a duplicate of bz2261579 + bz2261945.
Rawhide has a fixed version of hypothesmith 0.3.2:


$ mock -r fedora-rawhide-x86_64 --enablerepo=local install python3-hypothes{mith,is}
...
Installing:                                                                     
 python3-hypothesis                noarch 6.98.8-1.fc41     local        4.3 MiB
 python3-hypothesmith              noarch 0.3.2-1.fc40      fedora     113.4 KiB

...
$ mock -r fedora-rawhide-x86_64 shell --unpriv
<mock-chroot> sh-5.2$ python3
Python 3.12.2 (main, Feb  7 2024, 00:00:00) [GCC 14.0.1 20240127 (Red Hat 14.0.1-0)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hypothesmith
>>> 


But the Python 3.13 copr has 0.2.0.

Comment 4 Miro Hrončok 2024-02-22 11:06:38 UTC
I see 0.3.2 in https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/python-hypothesmith

Trying again.

Comment 5 Miro Hrončok 2024-02-22 11:10:03 UTC
OK, still failing, but differently. This is still a problem in hypothesmith:


$ mock -r fedora-rawhide-python313 --enablerepo=local --update python3-hypothesmith
Upgrading:                                                                 
 python3-hypothesmith             noarch 0.3.2-2.fc41  python313  113.4 KiB
   replacing python3-hypothesmith noarch 0.2.0-12.fc41 python313  115.4 KiB

<mock-chroot> sh-5.2$ python3
Python 3.13.0a4 (main, Feb 21 2024, 00:00:00) [GCC 14.0.1 20240217 (Red Hat 14.0.1-0)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hypothesmith
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    import hypothesmith
  File "/usr/lib/python3.13/site-packages/hypothesmith/__init__.py", line 3, in <module>
    from hypothesmith.cst import from_node
  File "/usr/lib/python3.13/site-packages/hypothesmith/cst.py", line 24, in <module>
    from .syntactic import ALLOWED_CHARS
  File "/usr/lib/python3.13/site-packages/hypothesmith/syntactic.py", line 7, in <module>
    from importlib.resources import read_text
ImportError: cannot import name 'read_text' from 'importlib.resources' (/usr/lib64/python3.13/importlib/resources/__init__.py)

Comment 6 Miro Hrončok 2024-02-22 11:12:46 UTC
For the record, this is the upstreams response for fixing the try-except bug -- https://github.com/PyCQA/mccabe/pull/92

Comment 8 Michel Lind 2024-02-25 03:03:03 UTC
I'm building hypothesmith 0.3.3 right now, the release note specifically listed Python 3.13 compatibility. Surprised we don't have a bug open against hypothesmith itself.

It built fine in Mock but luck of the draw, we got a PPC builder...

https://koji.fedoraproject.org/koji/buildinfo?buildID=2409833

Comment 9 Miro Hrončok 2024-02-25 15:06:52 UTC
> Surprised we don't have a bug open against hypothesmith itself.

Due to bootstrapping, we needed to build hypothesmith without tests first.


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