Domanda

I can remove the docstrings if I invoke cython manually, eg:

cython -D mmod.py

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
)

This produces a library that has all doc strings available, compared to when running with -D.

È stato utile?

Soluzione

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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top