Skip to content

test_mesonpy_meta_finder test fails with the experimental free-threading version of Python 3.13.0b4 #654

@jjhelmus

Description

@jjhelmus

Running the unit tests for using the free-threading version of Python 3.13.0b4 results in a single failed test, test_mesonpy_meta_finder.

Currently the CI is using Python 3.13.0b1 for testing where this test passes.

❯ docker run -it -v`pwd`:/io --platform linux/amd64 quay.io/pypa/manylinux_2_28_x86_64
...
# git clone https://github.com/mesonbuild/meson-python.git
# cd meson-python/
# python3.13t -m venv env
# .  env/bin/activate
# python3 -m pip install .[test]
...
# pytest
================================================================================ test session starts ================================================================================
platform linux -- Python 3.13.0b4, pytest-8.3.2, pluggy-1.5.0
rootdir: /root/meson-python
configfile: pyproject.toml
testpaths: tests
plugins: mock-3.14.0, cov-5.0.0
collected 121 items

tests/test_consistency.py .                                                                                                                                                   [  0%]
tests/test_editable.py ...F...........s                                                                                                                                       [ 14%]
tests/test_examples.py .                                                                                                                                                      [ 14%]
tests/test_metadata.py .....                                                                                                                                                  [ 19%]
tests/test_options.py ...                                                                                                                                                     [ 21%]
tests/test_output.py .........                                                                                                                                                [ 28%]
tests/test_pep517.py ...................                                                                                                                                      [ 44%]
tests/test_project.py ............ssssss                                                                                                                                      [ 59%]
tests/test_sdist.py ..........                                                                                                                                                [ 67%]
tests/test_tags.py .sss.....                                                                                                                                                  [ 75%]
tests/test_wheel.py ...............ss...ss.....                                                                                                                               [ 97%]
tests/test_wheelfile.py ...                                                                                                                                                   [100%]

===================================================================================== FAILURES ======================================================================================
_____________________________________________________________________________ test_mesonpy_meta_finder ______________________________________________________________________________

package_complex = PosixPath('/root/meson-python/tests/packages/complex'), tmp_path = PosixPath('/tmp/pytest-of-root/pytest-0/test_mesonpy_meta_finder0')

    def test_mesonpy_meta_finder(package_complex, tmp_path):
        # build a package in a temporary directory
        mesonpy.Project(package_complex, tmp_path)

        # point the meta finder to the build directory
        finder = _editable.MesonpyMetaFinder('complex', {'complex'}, os.fspath(tmp_path), ['ninja'])

        # check repr
        assert repr(finder) == f'MesonpyMetaFinder(\'complex\', {str(tmp_path)!r})'

        # verify that we can look up a pure module in the source directory
        spec = finder.find_spec('complex')
        assert spec.name == 'complex'
        assert isinstance(spec.loader, _editable.SourceFileLoader)
        assert spec.origin == os.fspath(package_complex / 'complex/__init__.py')

        # and an extension module in the build directory
        spec = finder.find_spec('complex.test')
        assert spec.name == 'complex.test'
        assert isinstance(spec.loader, _editable.ExtensionFileLoader)
        assert spec.origin == os.fspath(tmp_path / f'test{EXT_SUFFIX}')

        try:
            # install the finder in the meta path
            sys.meta_path.insert(0, finder)
            # verify that we can import the modules
            import complex
            assert complex.__spec__.origin == os.fspath(package_complex / 'complex/__init__.py')
            assert complex.__file__ == os.fspath(package_complex / 'complex/__init__.py')
>           import complex.extension
E           RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'complex.extension', which has not declared that it can run safely without the GIL. To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.

/root/meson-python/tests/test_editable.py:107: RuntimeWarning
------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------
+ meson setup /root/meson-python/tests/packages/complex /tmp/pytest-of-root/pytest-0/test_mesonpy_meta_finder0 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/tmp/pytest-of-root/pytest-0/test_mesonpy_meta_finder0/meson-python-native-file.ini
The Meson build system
Version: 1.5.1
Source dir: /root/meson-python/tests/packages/complex
Build dir: /tmp/pytest-of-root/pytest-0/test_mesonpy_meta_finder0
Build type: native build
Project name: complex
Project version: 1.0.0
C compiler for the host machine: cc (gcc 12.2.1 "cc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-7)")
C linker for the host machine: cc ld.bfd 2.38-17
Cython compiler for the host machine: cython (cython 3.0.10)
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program python found: YES (/root/meson-python/env/bin/python3)
Found pkg-config: YES (/usr/bin/pkg-config) 1.4.2
Run-time dependency python found: YES 3.13
Build targets in project: 4

complex 1.0.0

  User defined options
    Native files: /tmp/pytest-of-root/pytest-0/test_mesonpy_meta_finder0/meson-python-native-file.ini
    buildtype   : release
    b_ndebug    : if-release
    b_vscrt     : md

Found ninja-1.11.1.git.kitware.jobserver-1 at /root/meson-python/env/bin/ninja
============================================================================== short test summary info ==============================================================================
SKIPPED [1] tests/test_editable.py:295: Cython version too old, no free-threaded CPython support
SKIPPED [1] tests/test_project.py:204: Requires MSVC
SKIPPED [3] tests/test_project.py:216: macOS specific test
SKIPPED [2] tests/test_project.py:233: macOS specific test
SKIPPED [1] tests/test_tags.py:47: macOS specific test
SKIPPED [1] tests/test_tags.py:59: macOS specific test
SKIPPED [1] tests/test_tags.py:69: macOS specific test
SKIPPED [2] tests/test_wheel.py:251: macOS specific test
SKIPPED [1] tests/test_wheel.py:291: Free-threaded CPython does not support the limited API
SKIPPED [1] tests/test_wheel.py:302: Free-threaded CPython does not support the limited API
FAILED tests/test_editable.py::test_mesonpy_meta_finder - RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'complex.extension', which has not declared that it can run safely without the GIL. To overrid...
=============================================================== 1 failed, 106 passed, 14 skipped in 148.98s (0:02:28) ===============================================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions