Bug 2279982

Summary: python-bioframe fails to build with Python 3.13: AttributeError: 'FrameLocalsProxy' object has no attribute 'copy'
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-bioframeAssignee: Sandro <gui1ty>
Status: CLOSED WORKSFORME QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: code, gui1ty, ksurma, mhroncok, neuro-sig
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-06-15 09:12:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2244836    

Description Karolina Surma 2024-05-10 11:45:58 UTC
python-bioframe fails to build with Python 3.13.0b1.
=================================== FAILURES ===================================
______________________________ test_assembly_info ______________________________

    def test_assembly_info():
>       hg38 = assembly_info("hg38")

tests/test_assembly_info.py:15: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../BUILDROOT/python-bioframe-0.6.4-1.fc41.x86_64/usr/lib/python3.13/site-packages/bioframe/io/assembly.py:144: in assembly_info
    result = assemblies.query(q)
/usr/lib64/python3.13/site-packages/pandas/core/frame.py:4811: in query
    res = self.eval(expr, **kwargs)
/usr/lib64/python3.13/site-packages/pandas/core/frame.py:4937: in eval
    return _eval(expr, inplace=inplace, **kwargs)
/usr/lib64/python3.13/site-packages/pandas/core/computation/eval.py:328: in eval
    env = ensure_scope(
/usr/lib64/python3.13/site-packages/pandas/core/computation/scope.py:58: in ensure_scope
    return Scope(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'Scope' object has no attribute 'resolvers'") raised in repr()] Scope object at 0x7f31fd7bcf90>
level = 4, global_dict = None, local_dict = None
resolvers = ({'cytobands': 0     hg19.cytoband.tsv
1     hg19.cytoband.tsv
2     hg38.cytoband.tsv
3     hg38.cytoband.tsv
4      ...    7
8      8
9      9
10    10
11    11
12    12
13    13
14    14
15    15
16    16
17    17
18    18
dtype: int64})
target = None

    def __init__(
        self, level: int, global_dict=None, local_dict=None, resolvers=(), target=None
    ) -> None:
        self.level = level + 1
    
        # shallow copy because we don't want to keep filling this up with what
        # was there before if there are multiple calls to Scope/_ensure_scope
        self.scope = DeepChainMap(DEFAULT_GLOBALS.copy())
        self.target = target
    
        if isinstance(local_dict, Scope):
            self.scope.update(local_dict.scope)
            if local_dict.target is not None:
                self.target = local_dict.target
            self._update(local_dict.level)
    
        frame = sys._getframe(self.level)
    
        try:
            # shallow copy here because we don't want to replace what's in
            # scope when we align terms (alignment accesses the underlying
            # numpy array of pandas objects)
            scope_global = self.scope.new_child(
                (global_dict if global_dict is not None else frame.f_globals).copy()
            )
            self.scope = DeepChainMap(scope_global)
            if not isinstance(local_dict, Scope):
                scope_local = self.scope.new_child(
>                   (local_dict if local_dict is not None else frame.f_locals).copy()
                )
E               AttributeError: 'FrameLocalsProxy' object has no attribute 'copy'

/usr/lib64/python3.13/site-packages/pandas/core/computation/scope.py:176: AttributeError
=========================== short test summary info ============================
FAILED tests/test_assembly_info.py::test_assembly_info - AttributeError: 'Fra...
============ 1 failed, 52 passed, 3 skipped, 3 deselected in 3.26s =============

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/07434035-python-bioframe/

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

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 Sandro 2024-05-10 21:11:49 UTC
Reported upstream for now. Though, I'm not entirely sure if this is an issue in bioframe or in pandas.

Comment 2 Ben Beasley 2024-05-11 01:43:46 UTC
https://github.com/open2c/bioframe/issues/209#issuecomment-2105438326

> The attempt to call `copy() on `frame.f_locals` (which is, in Python 3.13, a `FrameLocalsProxy`), is in Pandas code, so this is some sense a Pandas bug.
> 
> However, based on https://github.com/python/cpython/issues/118921 and the associated (merged) PR https://github.com/python/cpython/pull/118933, it looks like the fix will be in CPython itself.

Comment 3 Miro HronĨok 2024-05-11 17:43:51 UTC
We can probably backport https://github.com/python/cpython/pull/118933 to copr.

Comment 4 Sandro 2024-05-12 17:33:17 UTC
Either that or wait for the second beta release, which will probably include the fix.