How to specify Python 3 source in Cython's setup.py?

后端 未结 3 1736
孤城傲影
孤城傲影 2020-12-01 06:04

I am trying to do a "Hello World" program in Cython, following this tutorial http://docs.cython.org/src/tutorial/cython_tutorial.html#cython-hello-world

I c

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 06:44

    According to official documentation on compilation, the Python language level can be specified using a directive through a special header comment at the top of the file, like this:

    #!python
    #cython: language_level=3
    

    There doesn't seem to be a way to specify this in setup.py. So if you have many Cython files, you'd have to add the compiler directive to each file. Although the only situation I've met so far that needs this directive is for print() as in your sample, and I've used Cython extensively.

提交回复
热议问题