Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove doc strings when using Cython distutils?

Tags:

python

cython

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.

like image 496
user791953 Avatar asked May 09 '14 16:05

user791953


1 Answers

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
like image 111
hivert Avatar answered Oct 08 '22 16:10

hivert