pybind / pybind11

Seamless operability between C++11 and Python

Home Page:https://pybind11.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG]: `ninja check` regression on PyPy3.10, due to cmake failing in `test_installed_function`

mgorny opened this issue · comments

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

2.12.0, also tested on f33f6af

Problem description

When running ninja check on PyPy3.10, I'm getting a failure due to a sub-cmake invocation failing:

[2/6] cd /tmp/pybind11/build/tests/test_cmake_build && /usr/bin/ctest --build-and-test /tmp/pybind11/tests/test_cmake_build/installed_function /tmp/pybind11/build/tests/test_cmake_build/installed_function --build-config Release --build-noclean --build-generator Ninja  --build-makeprogram /usr/bin/ninja --build-target check_installed_function --build-options -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DPYBIND11_FINDPYTHON=ON -DPython_EXECUTABLE=/tmp/pybind11/.venv/bin/python3.10 -DCMAKE_PREFIX_PATH=/tmp/pybind11/build/mock_install
FAILED: tests/test_cmake_build/CMakeFiles/test_build_installed_function /tmp/pybind11/build/tests/test_cmake_build/CMakeFiles/test_build_installed_function 
cd /tmp/pybind11/build/tests/test_cmake_build && /usr/bin/ctest --build-and-test /tmp/pybind11/tests/test_cmake_build/installed_function /tmp/pybind11/build/tests/test_cmake_build/installed_function --build-config Release --build-noclean --build-generator Ninja  --build-makeprogram /usr/bin/ninja --build-target check_installed_function --build-options -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DPYBIND11_FINDPYTHON=ON -DPython_EXECUTABLE=/tmp/pybind11/.venv/bin/python3.10 -DCMAKE_PREFIX_PATH=/tmp/pybind11/build/mock_install
Internal cmake changing into directory: /tmp/pybind11/build/tests/test_cmake_build/installed_function
Error: cmake execution failed
The CXX compiler identification is GNU 13.2.1
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working CXX compiler: /usr/bin/c++ - skipped
Detecting CXX compile features
Detecting CXX compile features - done
Found Python: /tmp/pybind11/.venv/bin/python3.10 (found suitable version "3.10.13", minimum required is "3.6") found components: Interpreter Development.Module missing components: Development.Embed
Performing Test HAS_FLTO
Performing Test HAS_FLTO - Success
Found pybind11: /tmp/pybind11/build/mock_install/include (found version "2.13.0dev1")
Found pybind11 v2.13.0 dev1: /tmp/pybind11/build/mock_install/include;/usr/include/pypy3.10
CMake Error at /usr/share/cmake/Modules/FindPython/Support.cmake:4074 (message):
  Python_ADD_LIBRARY: dependent target 'Python::Python' is not defined.

     Did you miss to request COMPONENT 'Development.Embed'?
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPython.cmake:635 (__Python_add_library)
  /tmp/pybind11/build/mock_install/share/cmake/pybind11/pybind11NewTools.cmake:237 (python_add_library)
  CMakeLists.txt:19 (pybind11_add_module)


CMake Error at /tmp/pybind11/build/mock_install/share/cmake/pybind11/pybind11NewTools.cmake:244 (target_link_libraries):
  Cannot specify link libraries for target "test_installed_function" which is
  not built by this project.
Call Stack (most recent call first):
  CMakeLists.txt:19 (pybind11_add_module)


Configuring incomplete, errors occurred!
Full output
$ ninja check
[0/2] Re-checking globbed directories...
[0/6] cd /tmp/pybind11/build/tests && /tmp/pybind11/.venv/bin/pyth...unique_ptr_member.py /tmp/pybind11/tests/test_virtual_functions.py
========================================================= test session starts =========================================================
platform linux -- Python 3.10.13[pypy-7.3.15-final], pytest-8.1.1, pluggy-1.4.0
C++ Info: 13.2.1 20240210 C++17 __pybind11_internals_v4_gcc_libstdcpp_cxxabi1018__ PYBIND11_SIMPLE_GIL_MANAGEMENT=True PYBIND11_NUMPY_1_ONLY=False
rootdir: /tmp/pybind11/tests
configfile: pytest.ini
collected 617 items / 6 skipped                                                                                                       

../../tests/test_async.py ..                                                                                                    [  0%]
../../tests/test_builtin_casters.py ........s.......s...                                                                        [  3%]
../../tests/test_call_policies.py X.x.....                                                                                      [  4%]
../../tests/test_callbacks.py ........s....s.                                                                                   [  7%]
../../tests/test_chrono.py ...........................................                                                          [ 14%]
../../tests/test_class.py .........................x...xx.....                                                                  [ 20%]
../../tests/test_const_name.py ......................                                                                           [ 23%]
../../tests/test_constants_and_functions.py ......                                                                              [ 24%]
../../tests/test_copy_move.py ........                                                                                          [ 25%]
../../tests/test_custom_type_casters.py ...                                                                                     [ 26%]
../../tests/test_custom_type_setup.py ss                                                                                        [ 26%]
../../tests/test_docstring_options.py .                                                                                         [ 26%]
../../tests/test_enum.py ..........                                                                                             [ 28%]
../../tests/test_eval.py .x..                                                                                                   [ 29%]
../../tests/test_exceptions.py .......x...........s......                                                                       [ 33%]
../../tests/test_factory_constructors.py ...............                                                                        [ 35%]
../../tests/test_gil_scoped.py ..........................................................................................       [ 50%]
../../tests/test_iostream.py ......................                                                                             [ 53%]
../../tests/test_kwargs_and_defaults.py ........                                                                                [ 55%]
../../tests/test_local_bindings.py ..........                                                                                   [ 56%]
../../tests/test_methods_and_attributes.py ............xx.........                                                              [ 60%]
../../tests/test_modules.py ......s                                                                                             [ 61%]
../../tests/test_multiple_inheritance.py .x.x..............                                                                     [ 64%]
../../tests/test_opaque_types.py ...                                                                                            [ 65%]
../../tests/test_operator_overloading.py .....                                                                                  [ 65%]
../../tests/test_pickling.py ...xx...                                                                                           [ 67%]
../../tests/test_python_multiple_inheritance.py ..                                                                              [ 67%]
../../tests/test_pytypes.py .............................s..............xx.................................................     [ 82%]
../../tests/test_sequences_and_iterators.py ................                                                                    [ 85%]
../../tests/test_smart_ptr.py .............                                                                                     [ 87%]
../../tests/test_stl.py .........s.............                                                                                 [ 91%]
../../tests/test_stl_binders.py ..s...........                                                                                  [ 93%]
../../tests/test_tagbased_polymorphic.py .                                                                                      [ 93%]
../../tests/test_thread.py ..                                                                                                   [ 94%]
../../tests/test_type_caster_pyobject_ptr.py ................                                                                   [ 96%]
../../tests/test_union.py .                                                                                                     [ 96%]
../../tests/test_unnamed_namespace_a.py ....                                                                                    [ 97%]
../../tests/test_unnamed_namespace_b.py .                                                                                       [ 97%]
../../tests/test_vector_unique_ptr_member.py ....                                                                               [ 98%]
../../tests/test_virtual_functions.py ...x......                                                                                [100%]

============================================================== XFAILURES ==============================================================
____________________________________________________________ test_alive_gc ____________________________________________________________

capture = <conftest.Capture object at 0x00005636edd01590>

    @pytest.mark.xfail("env.PYPY", reason="_PyObject_GetDictPtr is unimplemented")
    def test_alive_gc(capture):
        n_inst = ConstructorStats.detail_reg_inst()
>       p = m.ParentGC()
E       AttributeError: module 'pybind11_tests.call_policies' has no attribute 'ParentGC'

capture    = <conftest.Capture object at 0x00005636edd01590>
n_inst     = 59

../../tests/test_call_policies.py:121: AttributeError
_________________________________________________________ test_class_refcount _________________________________________________________

    @pytest.mark.xfail("env.PYPY")
    def test_class_refcount():
        """Instances must correctly increase/decrease the reference count of their types (#1029)"""
>       from sys import getrefcount
E       ImportError: cannot import name 'getrefcount' from 'sys' (unknown location)


../../tests/test_class.py:365: ImportError
_____________________________________________________________ test_final ______________________________________________________________

    @pytest.mark.xfail("env.PYPY")
    def test_final():
        with pytest.raises(TypeError) as exc_info:
    
            class PyFinalChild(m.IsFinal):
                pass
    
>       assert str(exc_info.value).endswith("is not an acceptable base type")
E       assert False
E        +  where False = <bound method str.endswith of 'metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind1...lChild\', (<class \'pybind11_tests.class_.IsFinal\'>,), ...) raised "type \'IsFinal\' is not an acceptable base type"'>('is not an acceptable base type')
E        +    where <bound method str.endswith of 'metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind1...lChild\', (<class \'pybind11_tests.class_.IsFinal\'>,), ...) raised "type \'IsFinal\' is not an acceptable base type"'> = 'metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind11_type\'> with args (\'PyFinalChild\', (<class \'pybind11_tests.class_.IsFinal\'>,), ...) raised "type \'IsFinal\' is not an acceptable base type"'.endswith
E        +      where 'metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind11_type\'> with args (\'PyFinalChild\', (<class \'pybind11_tests.class_.IsFinal\'>,), ...) raised "type \'IsFinal\' is not an acceptable base type"' = str(TypeError('metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind11_type\'> with args ...lChild\', (<class \'pybind11_tests.class_.IsFinal\'>,), ...) raised "type \'IsFinal\' is not an acceptable base type"'))
E        +        where TypeError('metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind11_type\'> with args ...lChild\', (<class \'pybind11_tests.class_.IsFinal\'>,), ...) raised "type \'IsFinal\' is not an acceptable base type"') = <ExceptionInfo TypeError('metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind11_typ... (<class \'pybind11_tests.class_.IsFinal\'>,), ...) raised "type \'IsFinal\' is not an acceptable base type"') tblen=1>.value

exc_info   = <ExceptionInfo TypeError('metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind11_typ... (<class \'pybind11_tests.class_.IsFinal\'>,), ...) raised "type \'IsFinal\' is not an acceptable base type"') tblen=1>

../../tests/test_class.py:420: AssertionError
________________________________________________________ test_non_final_final _________________________________________________________

    @pytest.mark.xfail("env.PYPY")
    def test_non_final_final():
        with pytest.raises(TypeError) as exc_info:
    
            class PyNonFinalFinalChild(m.IsNonFinalFinal):
                pass
    
>       assert str(exc_info.value).endswith("is not an acceptable base type")
E       assert False
E        +  where False = <bound method str.endswith of 'metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind1...s \'pybind11_tests.class_.IsNonFinalFinal\'>,), ...) raised "type \'IsNonFinalFinal\' is not an acceptable base type"'>('is not an acceptable base type')
E        +    where <bound method str.endswith of 'metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind1...s \'pybind11_tests.class_.IsNonFinalFinal\'>,), ...) raised "type \'IsNonFinalFinal\' is not an acceptable base type"'> = 'metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind11_type\'> with args (\'PyNonFi...ss \'pybind11_tests.class_.IsNonFinalFinal\'>,), ...) raised "type \'IsNonFinalFinal\' is not an acceptable base type"'.endswith
E        +      where 'metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind11_type\'> with args (\'PyNonFi...ss \'pybind11_tests.class_.IsNonFinalFinal\'>,), ...) raised "type \'IsNonFinalFinal\' is not an acceptable base type"' = str(TypeError('metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind11_type\'> with args ...s \'pybind11_tests.class_.IsNonFinalFinal\'>,), ...) raised "type \'IsNonFinalFinal\' is not an acceptable base type"'))
E        +        where TypeError('metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind11_type\'> with args ...s \'pybind11_tests.class_.IsNonFinalFinal\'>,), ...) raised "type \'IsNonFinalFinal\' is not an acceptable base type"') = <ExceptionInfo TypeError('metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind11_typ...d11_tests.class_.IsNonFinalFinal\'>,), ...) raised "type \'IsNonFinalFinal\' is not an acceptable base type"') tblen=1>.value

exc_info   = <ExceptionInfo TypeError('metaclass found to be \'pybind11_type\', but calling <class \'pybind11_builtins.pybind11_typ...d11_tests.class_.IsNonFinalFinal\'>,), ...) raised "type \'IsNonFinalFinal\' is not an acceptable base type"') tblen=1>

../../tests/test_class.py:431: AssertionError
___________________________________________________________ test_eval_file ____________________________________________________________

    @pytest.mark.xfail("env.PYPY", raises=RuntimeError)
    def test_eval_file():
        filename = os.path.join(os.path.dirname(__file__), "test_eval_call.py")
>       assert m.test_eval_file(filename)
E       RuntimeError: eval_file not supported in PyPy3. Use eval

filename   = '/tmp/pybind11/tests/test_eval_call.py'

../../tests/test_eval.py:23: RuntimeError
________________________________________________ test_python_alreadyset_in_destructor _________________________________________________

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x00005636eb21a058>
capsys = <_pytest.capture.CaptureFixture object at 0x00005636eb21a090>

    @pytest.mark.xfail(env.PYPY, reason="Failure on PyPy 3.8 (7.3.7)", strict=False)
    @ignore_pytest_unraisable_warning
    def test_python_alreadyset_in_destructor(monkeypatch, capsys):
        hooked = False
        triggered = False
    
        if hasattr(sys, "unraisablehook"):  # Python 3.8+
            hooked = True
            # Don't take `sys.unraisablehook`, as that's overwritten by pytest
            default_hook = sys.__unraisablehook__
    
            def hook(unraisable_hook_args):
                exc_type, exc_value, exc_tb, err_msg, obj = unraisable_hook_args
                if obj == "already_set demo":
                    nonlocal triggered
                    triggered = True
                default_hook(unraisable_hook_args)
                return
    
            # Use monkeypatch so pytest can apply and remove the patch as appropriate
            monkeypatch.setattr(sys, "unraisablehook", hook)
    
        assert m.python_alreadyset_in_destructor("already_set demo") is True
        if hooked:
>           assert triggered is True
E           assert False is True

capsys     = <_pytest.capture.CaptureFixture object at 0x00005636eb21a090>
default_hook = <built-in function unraisablehook>
hook       = <function test_python_alreadyset_in_destructor.<locals>.hook at 0x00005636ec620d40>
hooked     = True
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x00005636eb21a058>
triggered  = False

../../tests/test_exceptions.py:125: AssertionError
-------------------------------------------------------- Captured stderr call ---------------------------------------------------------
Exception ignored in: 'already_set demo'
KeyError: 'bar'
_______________________________________________________ test_dynamic_attributes _______________________________________________________

    @pytest.mark.xfail("env.PYPY")
    def test_dynamic_attributes():
>       instance = m.DynamicClass()
E       AttributeError: module 'pybind11_tests.methods_and_attributes' has no attribute 'DynamicClass'


../../tests/test_methods_and_attributes.py:297: AttributeError
___________________________________________________________ test_cyclic_gc ____________________________________________________________

    @pytest.mark.xfail("env.PYPY")
    def test_cyclic_gc():
        # One object references itself
>       instance = m.DynamicClass()
E       AttributeError: module 'pybind11_tests.methods_and_attributes' has no attribute 'DynamicClass'


../../tests/test_methods_and_attributes.py:340: AttributeError
___________________________________________________ test_multiple_inheritance_mix1 ____________________________________________________

    @pytest.mark.xfail("env.PYPY")
    def test_multiple_inheritance_mix1():
        class Base1:
            def __init__(self, i):
                self.i = i
    
            def foo(self):
                return self.i
    
        class MITypePy(Base1, m.Base2):
            def __init__(self, i, j):
                Base1.__init__(self, i)
                m.Base2.__init__(self, j)
    
>       mt = MITypePy(3, 4)
E       TypeError: object.__new__() takes exactly one argument (the type to instantiate)

Base1      = <class 'test_multiple_inheritance.test_multiple_inheritance_mix1.<locals>.Base1'>
MITypePy   = <class 'test_multiple_inheritance.test_multiple_inheritance_mix1.<locals>.MITypePy'>

../../tests/test_multiple_inheritance.py:29: TypeError
__________________________________________________ test_multiple_inheritance_python ___________________________________________________

    @pytest.mark.xfail("env.PYPY")
    def test_multiple_inheritance_python():
        class MI1(m.Base1, m.Base2):
            def __init__(self, i, j):
                m.Base1.__init__(self, i)
                m.Base2.__init__(self, j)
    
        class B1:
            def v(self):
                return 1
    
        class MI2(B1, m.Base1, m.Base2):
            def __init__(self, i, j):
                B1.__init__(self)
                m.Base1.__init__(self, i)
                m.Base2.__init__(self, j)
    
        class MI3(MI2):
            def __init__(self, i, j):
                MI2.__init__(self, i, j)
    
        class MI4(MI3, m.Base2):
            def __init__(self, i, j):
                MI3.__init__(self, i, j)
                # This should be ignored (Base2 is already initialized via MI2):
                m.Base2.__init__(self, i + 100)
    
        class MI5(m.Base2, B1, m.Base1):
            def __init__(self, i, j):
                B1.__init__(self)
                m.Base1.__init__(self, i)
                m.Base2.__init__(self, j)
    
        class MI6(m.Base2, B1):
            def __init__(self, i):
                m.Base2.__init__(self, i)
                B1.__init__(self)
    
        class B2(B1):
            def v(self):
                return 2
    
        class B3:
            def v(self):
                return 3
    
        class B4(B3, B2):
            def v(self):
                return 4
    
        class MI7(B4, MI6):
            def __init__(self, i):
                B4.__init__(self)
                MI6.__init__(self, i)
    
        class MI8(MI6, B3):
            def __init__(self, i):
                MI6.__init__(self, i)
                B3.__init__(self)
    
        class MI8b(B3, MI6):
            def __init__(self, i):
                B3.__init__(self)
                MI6.__init__(self, i)
    
        mi1 = MI1(1, 2)
        assert mi1.foo() == 1
        assert mi1.bar() == 2
    
>       mi2 = MI2(3, 4)
E       TypeError: object.__new__() takes exactly one argument (the type to instantiate)

B1         = <class 'test_multiple_inheritance.test_multiple_inheritance_python.<locals>.B1'>
B2         = <class 'test_multiple_inheritance.test_multiple_inheritance_python.<locals>.B2'>
B3         = <class 'test_multiple_inheritance.test_multiple_inheritance_python.<locals>.B3'>
B4         = <class 'test_multiple_inheritance.test_multiple_inheritance_python.<locals>.B4'>
MI1        = <class 'test_multiple_inheritance.test_multiple_inheritance_python.<locals>.MI1'>
MI2        = <class 'test_multiple_inheritance.test_multiple_inheritance_python.<locals>.MI2'>
MI3        = <class 'test_multiple_inheritance.test_multiple_inheritance_python.<locals>.MI3'>
MI4        = <class 'test_multiple_inheritance.test_multiple_inheritance_python.<locals>.MI4'>
MI5        = <class 'test_multiple_inheritance.test_multiple_inheritance_python.<locals>.MI5'>
MI6        = <class 'test_multiple_inheritance.test_multiple_inheritance_python.<locals>.MI6'>
MI7        = <class 'test_multiple_inheritance.test_multiple_inheritance_python.<locals>.MI7'>
MI8        = <class 'test_multiple_inheritance.test_multiple_inheritance_python.<locals>.MI8'>
MI8b       = <class 'test_multiple_inheritance.test_multiple_inheritance_python.<locals>.MI8b'>
mi1        = <test_multiple_inheritance.test_multiple_inheritance_python.<locals>.MI1 object at 0x00005636eaf45440>

../../tests/test_multiple_inheritance.py:123: TypeError
____________________________________________ test_roundtrip_with_dict[PickleableWithDict] _____________________________________________

cls_name = 'PickleableWithDict'

    @pytest.mark.xfail("env.PYPY")
    @pytest.mark.parametrize("cls_name", ["PickleableWithDict", "PickleableWithDictNew"])
    def test_roundtrip_with_dict(cls_name):
>       cls = getattr(m, cls_name)
E       AttributeError: module 'pybind11_tests.pickling' has no attribute 'PickleableWithDict'

cls_name   = 'PickleableWithDict'

../../tests/test_pickling.py:41: AttributeError
___________________________________________ test_roundtrip_with_dict[PickleableWithDictNew] ___________________________________________

cls_name = 'PickleableWithDictNew'

    @pytest.mark.xfail("env.PYPY")
    @pytest.mark.parametrize("cls_name", ["PickleableWithDict", "PickleableWithDictNew"])
    def test_roundtrip_with_dict(cls_name):
>       cls = getattr(m, cls_name)
E       AttributeError: module 'pybind11_tests.pickling' has no attribute 'PickleableWithDictNew'

cls_name   = 'PickleableWithDictNew'

../../tests/test_pickling.py:41: AttributeError
__________________________________________ test_memoryview_refcount[test_memoryview_object] ___________________________________________

method = <builtin_function_or_method object at 0x00007fc1c557dd60>

    @pytest.mark.xfail("env.PYPY", reason="getrefcount is not available")
    @pytest.mark.parametrize(
        "method",
        [
            m.test_memoryview_object,
            m.test_memoryview_buffer_info,
        ],
    )
    def test_memoryview_refcount(method):
        buf = b"\x0a\x0b\x0c\x0d"
>       ref_before = sys.getrefcount(buf)
E       AttributeError: module 'sys' has no attribute 'getrefcount'

buf        = b'\n\x0b\x0c\r'
method     = <builtin_function_or_method object at 0x00007fc1c557dd60>

../../tests/test_pytypes.py:635: AttributeError
________________________________________ test_memoryview_refcount[test_memoryview_buffer_info] ________________________________________

method = <builtin_function_or_method object at 0x00007fc1c557dda0>

    @pytest.mark.xfail("env.PYPY", reason="getrefcount is not available")
    @pytest.mark.parametrize(
        "method",
        [
            m.test_memoryview_object,
            m.test_memoryview_buffer_info,
        ],
    )
    def test_memoryview_refcount(method):
        buf = b"\x0a\x0b\x0c\x0d"
>       ref_before = sys.getrefcount(buf)
E       AttributeError: module 'sys' has no attribute 'getrefcount'

buf        = b'\n\x0b\x0c\r'
method     = <builtin_function_or_method object at 0x00007fc1c557dda0>

../../tests/test_pytypes.py:635: AttributeError
__________________________________________________________ test_move_support __________________________________________________________

    @pytest.mark.xfail("env.PYPY")
    @pytest.mark.skipif(
        not hasattr(m, "NCVirt"), reason="NCVirt does not work on Intel/PGI/NVCC compilers"
    )
    def test_move_support():
        class NCVirtExt(m.NCVirt):
            def get_noncopyable(self, a, b):
                # Constructs and returns a new instance:
                return m.NonCopyable(a * a, b * b)
    
            def get_movable(self, a, b):
                # Return a referenced copy
                self.movable = m.Movable(a, b)
                return self.movable
    
        class NCVirtExt2(m.NCVirt):
            def get_noncopyable(self, a, b):
                # Keep a reference: this is going to throw an exception
                self.nc = m.NonCopyable(a, b)
                return self.nc
    
            def get_movable(self, a, b):
                # Return a new instance without storing it
                return m.Movable(a, b)
    
        ncv1 = NCVirtExt()
        assert ncv1.print_nc(2, 3) == "36"
        assert ncv1.print_movable(4, 5) == "9"
        ncv2 = NCVirtExt2()
        assert ncv2.print_movable(7, 7) == "14"
        # Don't check the exception message here because it differs under debug/non-debug mode
>       with pytest.raises(RuntimeError):
E       Failed: DID NOT RAISE <class 'RuntimeError'>

NCVirtExt  = <class 'test_virtual_functions.test_move_support.<locals>.NCVirtExt'>
NCVirtExt2 = <class 'test_virtual_functions.test_move_support.<locals>.NCVirtExt2'>
ncv1       = <test_virtual_functions.test_move_support.<locals>.NCVirtExt object at 0x00005636ec0ce8e0>
ncv2       = <test_virtual_functions.test_move_support.<locals>.NCVirtExt2 object at 0x00005636ec0ce880>

../../tests/test_virtual_functions.py:218: Failed
-------------------------------------------------------- Captured stdout call ---------------------------------------------------------
### NonCopyable @ 0x5636eb4cdfa0 created 4 9
### NonCopyable @ 0x7ffcd2abcc60 created via move constructor
### NonCopyable @ 0x7ffcd2abcc60 destroyed
### NonCopyable @ 0x5636eb4cdfa0 destroyed
### Movable @ 0x5636eabea360 created 4 5
### Movable @ 0x7ffcd2abcc64 created via move constructor
### Movable @ 0x7ffcd2abcc64 destroyed
### Movable @ 0x5636ea9bebe0 created 7 7
### Movable @ 0x7ffcd2abcc64 created via move constructor
### Movable @ 0x7ffcd2abcc64 destroyed
### Movable @ 0x5636ea9bebe0 destroyed
### NonCopyable @ 0x5636ebce0c30 created 9 9
### NonCopyable @ 0x7ffcd2abcc70 created via move constructor
### NonCopyable @ 0x7ffcd2abcc70 destroyed
=============================================================== XPASSES ===============================================================
______________________________________________________ test_keep_alive_argument _______________________________________________________
-------------------------------------------------------- Captured stdout call ---------------------------------------------------------
Allocating parent.
Allocating child.
Releasing parent.
Releasing child.
======================================================= short test summary info =======================================================
SKIPPED [1] ../../tests/test_buffers.py:11: could not import 'numpy': No module named 'numpy'
SKIPPED [1] ../../tests/test_eigen_matrix.py:5: could not import 'numpy': No module named 'numpy'
SKIPPED [1] ../../tests/test_eigen_tensor.py:5: could not import 'numpy': No module named 'numpy'
SKIPPED [1] ../../tests/test_numpy_array.py:6: could not import 'numpy': No module named 'numpy'
SKIPPED [1] ../../tests/test_numpy_dtypes.py:9: could not import 'numpy': No module named 'numpy'
SKIPPED [1] ../../tests/test_numpy_vectorize.py:5: could not import 'numpy': No module named 'numpy'
SKIPPED [1] ../../tests/test_builtin_casters.py:320: could not import 'numpy': No module named 'numpy'
SKIPPED [1] ../../tests/test_builtin_casters.py:488: could not import 'numpy': No module named 'numpy'
SKIPPED [1] ../../tests/test_callbacks.py:144: PyPy segfaults on here. See discussion on #1413.
SKIPPED [1] ../../tests/test_callbacks.py:213: Current PYBIND11_INTERNALS_VERSION too low
SKIPPED [1] ../../tests/test_custom_type_setup.py:35: condition: env.PYPY
SKIPPED [1] ../../tests/test_custom_type_setup.py:43: condition: env.PYPY
SKIPPED [1] ../../tests/test_exceptions.py:365: PyErr_NormalizeException Segmentation fault
SKIPPED [1] ../../tests/test_modules.py:100: Sufficiently exercised on platforms other than PyPy.
SKIPPED [1] ../../tests/test_pytypes.py:416: Not defined: PYBIND11_HANDLE_REF_DEBUG
SKIPPED [1] ../../tests/test_stl.py:147: no <experimental/optional>
SKIPPED [1] ../../tests/test_stl_binders.py:89: could not import 'numpy': No module named 'numpy'
XFAIL ../../tests/test_call_policies.py::test_alive_gc - _PyObject_GetDictPtr is unimplemented
XFAIL ../../tests/test_class.py::test_class_refcount - condition: env.PYPY
XFAIL ../../tests/test_class.py::test_final - condition: env.PYPY
XFAIL ../../tests/test_class.py::test_non_final_final - condition: env.PYPY
XFAIL ../../tests/test_eval.py::test_eval_file - condition: env.PYPY
XFAIL ../../tests/test_exceptions.py::test_python_alreadyset_in_destructor - Failure on PyPy 3.8 (7.3.7)
XFAIL ../../tests/test_methods_and_attributes.py::test_dynamic_attributes - condition: env.PYPY
XFAIL ../../tests/test_methods_and_attributes.py::test_cyclic_gc - condition: env.PYPY
XFAIL ../../tests/test_multiple_inheritance.py::test_multiple_inheritance_mix1 - condition: env.PYPY
XFAIL ../../tests/test_multiple_inheritance.py::test_multiple_inheritance_python - condition: env.PYPY
XFAIL ../../tests/test_pickling.py::test_roundtrip_with_dict[PickleableWithDict] - condition: env.PYPY
XFAIL ../../tests/test_pickling.py::test_roundtrip_with_dict[PickleableWithDictNew] - condition: env.PYPY
XFAIL ../../tests/test_pytypes.py::test_memoryview_refcount[test_memoryview_object] - getrefcount is not available
XFAIL ../../tests/test_pytypes.py::test_memoryview_refcount[test_memoryview_buffer_info] - getrefcount is not available
XFAIL ../../tests/test_virtual_functions.py::test_move_support - condition: env.PYPY
XPASS ../../tests/test_call_policies.py::test_keep_alive_argument - sometimes comes out 1 off on PyPy
================================= 590 passed, 17 skipped, 15 xfailed, 1 xpassed in 140.47s (0:02:20) ==================================
[1/6] cd /tmp/pybind11/build/tests/test_cmake_build && /usr/bin/cmake -DCMAKE_INSTALL_PREFIX=/tmp/pybind11/build/mock_install -P /tmp/pybind11/build/cmake_install.cmake
-- Install configuration: "MinSizeRel"
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/attr.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/buffer_info.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/cast.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/chrono.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/common.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/complex.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/detail
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/detail/class.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/detail/common.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/detail/descr.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/detail/init.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/detail/internals.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/detail/type_caster_base.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/detail/typeid.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/eigen.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/eigen
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/eigen/common.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/eigen/matrix.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/eigen/tensor.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/embed.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/eval.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/functional.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/gil.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/gil_safe_call_once.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/iostream.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/numpy.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/operators.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/options.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/pybind11.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/pytypes.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/stl.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/stl
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/stl/filesystem.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/stl_bind.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/type_caster_pyobject_ptr.h
-- Installing: /tmp/pybind11/build/mock_install/include/pybind11/typing.h
-- Installing: /tmp/pybind11/build/mock_install/share/cmake/pybind11/pybind11Config.cmake
-- Installing: /tmp/pybind11/build/mock_install/share/cmake/pybind11/pybind11ConfigVersion.cmake
-- Installing: /tmp/pybind11/build/mock_install/share/cmake/pybind11/FindPythonLibsNew.cmake
-- Installing: /tmp/pybind11/build/mock_install/share/cmake/pybind11/pybind11Common.cmake
-- Installing: /tmp/pybind11/build/mock_install/share/cmake/pybind11/pybind11Tools.cmake
-- Installing: /tmp/pybind11/build/mock_install/share/cmake/pybind11/pybind11NewTools.cmake
-- Installing: /tmp/pybind11/build/mock_install/share/cmake/pybind11/pybind11Targets.cmake
-- Installing: /tmp/pybind11/build/mock_install/share/pkgconfig/pybind11.pc
[2/6] cd /tmp/pybind11/build/tests/test_cmake_build && /usr/bin/ctest --build-and-test /tmp/pybind11/tests/test_cmake_build/installed_function /tmp/pybind11/build/tests/test_cmake_build/installed_function --build-config Release --build-noclean --build-generator Ninja  --build-makeprogram /usr/bin/ninja --build-target check_installed_function --build-options -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DPYBIND11_FINDPYTHON=ON -DPython_EXECUTABLE=/tmp/pybind11/.venv/bin/python3.10 -DCMAKE_PREFIX_PATH=/tmp/pybind11/build/mock_install
FAILED: tests/test_cmake_build/CMakeFiles/test_build_installed_function /tmp/pybind11/build/tests/test_cmake_build/CMakeFiles/test_build_installed_function 
cd /tmp/pybind11/build/tests/test_cmake_build && /usr/bin/ctest --build-and-test /tmp/pybind11/tests/test_cmake_build/installed_function /tmp/pybind11/build/tests/test_cmake_build/installed_function --build-config Release --build-noclean --build-generator Ninja  --build-makeprogram /usr/bin/ninja --build-target check_installed_function --build-options -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DPYBIND11_FINDPYTHON=ON -DPython_EXECUTABLE=/tmp/pybind11/.venv/bin/python3.10 -DCMAKE_PREFIX_PATH=/tmp/pybind11/build/mock_install
Internal cmake changing into directory: /tmp/pybind11/build/tests/test_cmake_build/installed_function
Error: cmake execution failed
The CXX compiler identification is GNU 13.2.1
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working CXX compiler: /usr/bin/c++ - skipped
Detecting CXX compile features
Detecting CXX compile features - done
Found Python: /tmp/pybind11/.venv/bin/python3.10 (found suitable version "3.10.13", minimum required is "3.6") found components: Interpreter Development.Module missing components: Development.Embed
Performing Test HAS_FLTO
Performing Test HAS_FLTO - Success
Found pybind11: /tmp/pybind11/build/mock_install/include (found version "2.13.0dev1")
Found pybind11 v2.13.0 dev1: /tmp/pybind11/build/mock_install/include;/usr/include/pypy3.10
CMake Error at /usr/share/cmake/Modules/FindPython/Support.cmake:4074 (message):
  Python_ADD_LIBRARY: dependent target 'Python::Python' is not defined.

     Did you miss to request COMPONENT 'Development.Embed'?
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPython.cmake:635 (__Python_add_library)
  /tmp/pybind11/build/mock_install/share/cmake/pybind11/pybind11NewTools.cmake:237 (python_add_library)
  CMakeLists.txt:19 (pybind11_add_module)


CMake Error at /tmp/pybind11/build/mock_install/share/cmake/pybind11/pybind11NewTools.cmake:244 (target_link_libraries):
  Cannot specify link libraries for target "test_installed_function" which is
  not built by this project.
Call Stack (most recent call first):
  CMakeLists.txt:19 (pybind11_add_module)


Configuring incomplete, errors occurred!

[3/6] cd /tmp/pybind11/build/tests/test_cmake_build && /usr/bin/ctest --build-and-test /tmp/pybind11/tests/test_cmake_build/installed_target /tmp/pybind11/build/tests/test_cmake_build/installed_target --build-config Release --build-noclean --build-generator Ninja  --build-makeprogram /usr/bin/ninja --build-target check_installed_target --build-options -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DPYBIND11_FINDPYTHON=ON -DPython_EXECUTABLE=/tmp/pybind11/.venv/bin/python3.10 -DCMAKE_PREFIX_PATH=/tmp/pybind11/build/mock_install
Internal cmake changing into directory: /tmp/pybind11/build/tests/test_cmake_build/installed_target
======== CMake output     ======
The CXX compiler identification is GNU 13.2.1
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working CXX compiler: /usr/bin/c++ - skipped
Detecting CXX compile features
Detecting CXX compile features - done
Found Python: /tmp/pybind11/.venv/bin/python3.10 (found suitable version "3.10.13", minimum required is "3.6") found components: Interpreter Development.Module missing components: Development.Embed
Performing Test HAS_FLTO
Performing Test HAS_FLTO - Success
Found pybind11: /tmp/pybind11/build/mock_install/include (found version "2.13.0dev1")
Found pybind11 v2.13.0: /tmp/pybind11/build/mock_install/include;/usr/include/pypy3.10
Configuring done (2.2s)
Generating done (0.0s)
Build files have been written to: /tmp/pybind11/build/tests/test_cmake_build/installed_target
======== End CMake output ======
Change Dir: '/tmp/pybind11/build/tests/test_cmake_build/installed_target'

Run Build Command(s): /usr/bin/ninja check_installed_target
[1/3] Building CXX object CMakeFiles/test_installed_target.dir/tmp/pybind11/tests/test_cmake_build/main.cpp.o
[2/3] Linking CXX shared module test_cmake_build.pypy310-pp73-x86_64-linux-gnu.so
[3/3] cd /tmp/pybind11/build/tests/test_cmake_build/installed_target && /usr/bin/cmake -E env PYTHONPATH=/tmp/pybind11/build/tests/test_cmake_build/installed_target /tmp/pybind11/.venv/bin/python3.10 /tmp/pybind11/tests/test_cmake_build/installed_target/../test.py test_installed_target
test_installed_target imports, runs, and adds: 1 + 2 = 3

[4/6] cd /tmp/pybind11/build/tests/test_cmake_build && /usr/bin/ctest --build-and-test /tmp/pybind11/tests/test_cmake_build/subdirectory_target /tmp/pybind11/build/tests/test_cmake_build/subdirectory_target --build-config Release --build-noclean --build-generator Ninja  --build-makeprogram /usr/bin/ninja --build-target check_subdirectory_target --build-options -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DPYBIND11_FINDPYTHON=ON -DPython_EXECUTABLE=/tmp/pybind11/.venv/bin/python3.10 -Dpybind11_SOURCE_DIR=/tmp/pybind11
Internal cmake changing into directory: /tmp/pybind11/build/tests/test_cmake_build/subdirectory_target
======== CMake output     ======
The CXX compiler identification is GNU 13.2.1
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working CXX compiler: /usr/bin/c++ - skipped
Detecting CXX compile features
Detecting CXX compile features - done
pybind11 v2.13.0 dev1
Found Python: /tmp/pybind11/.venv/bin/python3.10 (found suitable version "3.10.13", minimum required is "3.6") found components: Interpreter Development.Module missing components: Development.Embed
Performing Test HAS_FLTO
Performing Test HAS_FLTO - Success
Configuring done (2.1s)
Generating done (0.0s)
Build files have been written to: /tmp/pybind11/build/tests/test_cmake_build/subdirectory_target
======== End CMake output ======
Change Dir: '/tmp/pybind11/build/tests/test_cmake_build/subdirectory_target'

Run Build Command(s): /usr/bin/ninja check_subdirectory_target
[1/3] Building CXX object CMakeFiles/test_subdirectory_target.dir/tmp/pybind11/tests/test_cmake_build/main.cpp.o
[2/3] Linking CXX shared module test_cmake_build.pypy310-pp73-x86_64-linux-gnu.so
[3/3] cd /tmp/pybind11/build/tests/test_cmake_build/subdirectory_target && /usr/bin/cmake -E env PYTHONPATH=/tmp/pybind11/build/tests/test_cmake_build/subdirectory_target /tmp/pybind11/.venv/bin/python3.10 /tmp/pybind11/tests/test_cmake_build/subdirectory_target/../test.py test_subdirectory_target
test_subdirectory_target imports, runs, and adds: 1 + 2 = 3

[5/6] cd /tmp/pybind11/build/tests/test_cmake_build && /usr/bin/ctest --build-and-test /tmp/pybind11/tests/test_cmake_build/subdirectory_function /tmp/pybind11/build/tests/test_cmake_build/subdirectory_function --build-config Release --build-noclean --build-generator Ninja  --build-makeprogram /usr/bin/ninja --build-target check_subdirectory_function --build-options -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DPYBIND11_FINDPYTHON=ON -DPython_EXECUTABLE=/tmp/pybind11/.venv/bin/python3.10 -Dpybind11_SOURCE_DIR=/tmp/pybind11
Internal cmake changing into directory: /tmp/pybind11/build/tests/test_cmake_build/subdirectory_function
======== CMake output     ======
The CXX compiler identification is GNU 13.2.1
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working CXX compiler: /usr/bin/c++ - skipped
Detecting CXX compile features
Detecting CXX compile features - done
pybind11 v2.13.0 dev1
Found Python: /tmp/pybind11/.venv/bin/python3.10 (found suitable version "3.10.13", minimum required is "3.6") found components: Interpreter Development.Module missing components: Development.Embed
Performing Test HAS_FLTO
Performing Test HAS_FLTO - Success
Configuring done (2.2s)
Generating done (0.0s)
Build files have been written to: /tmp/pybind11/build/tests/test_cmake_build/subdirectory_function
======== End CMake output ======
Change Dir: '/tmp/pybind11/build/tests/test_cmake_build/subdirectory_function'

Run Build Command(s): /usr/bin/ninja check_subdirectory_function
[1/3] Building CXX object CMakeFiles/test_subdirectory_function.dir/tmp/pybind11/tests/test_cmake_build/main.cpp.o
[2/3] Linking CXX shared module test_cmake_build.pypy310-pp73-x86_64-linux-gnu.so
lto-wrapper: warning: using serial compilation of 2 LTRANS jobs
lto-wrapper: note: see the ‘-flto’ option documentation for more information
[3/3] cd /tmp/pybind11/build/tests/test_cmake_build/subdirectory_function && /usr/bin/cmake -E env PYTHONPATH=/tmp/pybind11/build/tests/test_cmake_build/subdirectory_function /tmp/pybind11/.venv/bin/python3.10 /tmp/pybind11/tests/test_cmake_build/subdirectory_function/../test.py test_subdirectory_function
test_subdirectory_function imports, runs, and adds: 1 + 2 = 3

ninja: build stopped: subcommand failed.

Reproducible example code

pypy3 -m venv .venv
. .venv/bin/activate
pip install pytest
mkdir build
cd build
cmake .. -G Ninja
ninja
ninja check

Is this a regression? Put the last known working version here if it is.

2.11.1

Bisected to daea113.

CC @polmes

With further testing, it seems that this is specifically caused by the policy change to 3.27.

Hmm, I seem to be able to workaround the problem by specifying -DPYBIND11_FINDPYTHON=OFF.