Skip to content

PyPy link error when limited_api is set #12727

@mattip

Description

@mattip

Describe the bug
Setting the limite_api argument to extension_module changes the link library for windows to python3.lib (rather than a version-specific python39.lib), but this is not shipped with PyPy.
To Reproduce

This came up in numpy/numpy#25531, where the complete meson build contains two extensions. Here is what I needed to do for the limited api extension:

# py does not export the is_pypy method
if not py.get_variable('SOABI').startswith('pypy')
  py.extension_module(
      'limited_api',
      'limited_api.pyx',
      install: false,
      c_args: [
        '-DNPY_NO_DEPRECATED_API=0',  # Cython still uses old NumPy C API
        # Require 1.25+ to test datetime additions
        '-DNPY_TARGET_VERSION=NPY_2_0_API_VERSION',
        '-DCYTHON_LIMITED_API=1',
      ],
      include_directories: [npy_include_path],
      limited_api: '3.7',
  )
endif

where limited_api.pyx is

#cython: language_level=3

"""
Make sure cython can compile in limited API mode (see meson.build)
"""

cdef extern from "numpy/arrayobject.h":
    pass
cdef extern from "numpy/arrayscalars.h":
    pass

Expected behavior
I expected the build to succeed, it failed. Also, it would be nice to have a cleaner way to detect PyPy.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)? plain
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) windows
  • what Python version are you using e.g. 3.8.0 3.9, 3.10
  • what meson --version latest
  • what ninja --version if it's a Ninja build

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions