使用Cython distutils时如何删除文档字符串? [英] How to remove doc strings when using Cython distutils?
本文介绍了使用Cython distutils时如何删除文档字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我手动调用cython,则可以删除文档字符串,例如:
I can remove the docstrings if I invoke cython manually, eg:
cython -D mmod.py
但是当我尝试使用设置实用程序时,无法传递该-D参数。
but when I try to use the setup utility, I am unable to pass that -D parameter along.
setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [Extension("mmod", ["mmod.py"])]
setup(
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
与使用-D运行时相比,这将产生一个包含所有文档字符串的库。
This produces a library that has all doc strings available, compared to when running with -D.
推荐答案
Cython编译选项存储在模块 Cython.Compiler.Options
中。因此,您要查找的是
Cython compiling option are stored in the module Cython.Compiler.Options
. So what you are looking for is
import Cython.Compiler.Options
Cython.Compiler.Options.docstrings = False
这篇关于使用Cython distutils时如何删除文档字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文