Search code examples
cmake

No such file or directory: 'build/temp.linux-x86_64-3.6 during setuptools bdist_wheel


I'm building extension with CMake

setup(
...
cmdclass={'build_ext':Cmakebuildclass}
)

where Cmakebuildclass is a custom class. Inside run() function of this class, I'm building the extension It creates a temporary build directory where all artifacts get stored. However, at the end I try to access it but it fails

error: [Errno 2] No such file or directory: 'build/temp.linux-x86_64-3.6

Solution

  • Temporary build directory [e.g. build/temp.linux-x86_64-3.6] gets deleted once the targets are built.

    It's copied over to the lib folder within build generally build/lib.linux-x86_64-3.6/ So use build_lib variable instead of build_temp

    For code: https://github.com/python/cpython/blob/e5fe509054183bed9aef42c92da8407d339e8af8/Lib/distutils/command/build_ext.py#L108

    Details: https://github.com/python/cpython/blob/e5fe509054183bed9aef42c92da8407d339e8af8/Lib/distutils/command/build_ext.py#L57-L60