gpt4 book ai didi

python - 构建Python : how to disable Py_LIMITED_API?

转载 作者:行者123 更新时间:2023-12-01 09:25:00 24 4
gpt4 key购买 nike

哪些配置标志/make 标志对此负责?

如果我不启用此功能,我就没有缓冲区 API。更不用说将其设置为默认值并不是一个好主意...并且该文档没有提及使用某些 Python 的 API 是基于此编译时设置...

实际上,它也不是使用 Python 3.5 构建的。我误读了诊断消息。

最佳答案

以下 setup.py 示例将编译 foo.cpp 以将 py_limited_api 设置为 False :

from setuptools import setup, Extension

setup(
name='foo',
ext_modules=[Extension('foo', ['foo.cpp'], py_limited_api=False)],
)

确保在包含 Python.h 之前没有 #define Py_LIMITED_API ...

您可以使用以下语句测试 Py_LIMITED_API 是否存在:

#ifdef Py_LIMITED_API
#error Py_LIMITED_API is set
#endif
#include <Python.h>
...

编辑:

您可以通过运行来编译模块:

python setup.py build_ext --inplace

或者通过创建一个轮子:

python setup.py bdist_wheel

关于python - 构建Python : how to disable Py_LIMITED_API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50504270/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com