Using Sphinx with a distutils-built C extension

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 04:53:17

Since distutils has a way of figuring out the variable build path, why not just use it?

import distutils.command.build
from distutils.dist import Distribution

b = distutils.command.build.build(Distribution())
b.initialize_options()
b.finalize_options()

print b.build_temp

# If you're building a library, you might need:
print b.build_lib

# Other values of interest are:
b.build_purelib
b.build_platlib
b.build_scripts
b.build_base

Even thought the distutils docs are sparse, here you'll find one-liners about what kinds of build are there.

There are simpler ways to get the build dir name:

>>> from distutils.util import get_platform
>>> get_platform()
'linux-x86_64'

I’ll let you finish the string concatenation :)

Another way to solve your problem is to create a setup.cfg file alongside your setup.py with this content:

[build_ext]
inplace = 1

This will build your extension modules in its parent package directory. Sphinx should see it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!