Updated script that can be controled by Nodejs web app
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#define Py_LIMITED_API 0x03060000
|
||||
|
||||
#include <Python.h>
|
||||
#include <numpy/arrayobject.h>
|
||||
#include <numpy/ufuncobject.h>
|
||||
|
||||
static PyModuleDef moduledef = {
|
||||
.m_base = PyModuleDef_HEAD_INIT,
|
||||
.m_name = "limited_api1"
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC PyInit_limited_api1(void)
|
||||
{
|
||||
import_array();
|
||||
import_umath();
|
||||
return PyModule_Create(&moduledef);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#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
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#if Py_LIMITED_API != PY_VERSION_HEX & 0xffff0000
|
||||
# error "Py_LIMITED_API not defined to Python major+minor version"
|
||||
#endif
|
||||
|
||||
#include <Python.h>
|
||||
#include <numpy/arrayobject.h>
|
||||
#include <numpy/ufuncobject.h>
|
||||
|
||||
static PyModuleDef moduledef = {
|
||||
.m_base = PyModuleDef_HEAD_INIT,
|
||||
.m_name = "limited_api_latest"
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC PyInit_limited_api_latest(void)
|
||||
{
|
||||
import_array();
|
||||
import_umath();
|
||||
return PyModule_Create(&moduledef);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
project('checks', 'c', 'cython')
|
||||
|
||||
py = import('python').find_installation(pure: false)
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
cy = meson.get_compiler('cython')
|
||||
|
||||
# Keep synced with pyproject.toml
|
||||
if not cy.version().version_compare('>=3.0.6')
|
||||
error('tests requires Cython >= 3.0.6')
|
||||
endif
|
||||
|
||||
npy_include_path = run_command(py, [
|
||||
'-c',
|
||||
'import os; os.chdir(".."); import numpy; print(os.path.abspath(numpy.get_include()))'
|
||||
], check: true).stdout().strip()
|
||||
|
||||
npy_path = run_command(py, [
|
||||
'-c',
|
||||
'import os; os.chdir(".."); import numpy; print(os.path.dirname(numpy.__file__).removesuffix("numpy"))'
|
||||
], check: true).stdout().strip()
|
||||
|
||||
# TODO: This is a hack due to https://github.com/cython/cython/issues/5820,
|
||||
# where cython may not find the right __init__.pyd file.
|
||||
add_project_arguments('-I', npy_path, language : 'cython')
|
||||
|
||||
py.extension_module(
|
||||
'limited_api1',
|
||||
'limited_api1.c',
|
||||
c_args: [
|
||||
'-DNPY_NO_DEPRECATED_API=NPY_1_21_API_VERSION',
|
||||
],
|
||||
include_directories: [npy_include_path],
|
||||
limited_api: '3.6',
|
||||
)
|
||||
|
||||
py.extension_module(
|
||||
'limited_api_latest',
|
||||
'limited_api_latest.c',
|
||||
c_args: [
|
||||
'-DNPY_NO_DEPRECATED_API=NPY_1_21_API_VERSION',
|
||||
],
|
||||
include_directories: [npy_include_path],
|
||||
limited_api: py.language_version(),
|
||||
)
|
||||
|
||||
py.extension_module(
|
||||
'limited_api2',
|
||||
'limited_api2.pyx',
|
||||
install: false,
|
||||
c_args: [
|
||||
'-DNPY_NO_DEPRECATED_API=0',
|
||||
# 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',
|
||||
)
|
||||
@@ -0,0 +1,22 @@
|
||||
"""
|
||||
Build an example package using the limited Python C API.
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
from setuptools import setup, Extension
|
||||
import os
|
||||
|
||||
macros = [("NPY_NO_DEPRECATED_API", 0), ("Py_LIMITED_API", "0x03060000")]
|
||||
|
||||
limited_api = Extension(
|
||||
"limited_api",
|
||||
sources=[os.path.join('.', "limited_api.c")],
|
||||
include_dirs=[np.get_include()],
|
||||
define_macros=macros,
|
||||
)
|
||||
|
||||
extensions = [limited_api]
|
||||
|
||||
setup(
|
||||
ext_modules=extensions
|
||||
)
|
||||
Reference in New Issue
Block a user