Change Cython's naming rules for .so files

前端 未结 3 859
盖世英雄少女心
盖世英雄少女心 2020-12-16 18:39

I\'m using Cython to generate a shared object out of Python module. The compilation output is written to build/lib.linux-x86_64-3.5//.cpyt

3条回答
  •  无人及你
    2020-12-16 18:41

    the solution is very simple, just change one line in build_ext.py at

        def get_ext_filename(self, ext_name):
    
            from distutils.sysconfig import get_config_var
            ext_path = ext_name.split('.')
            ext_suffix = get_config_var('EXT_SUFFIX') 
            return os.path.join(*ext_path) + ext_suffix
    

    change ext_suffix = get_config_var('EXT_SUFFIX') to ext_suffix = ".so" or to ".pyd" on Windows

    that's it, you don't have to worry about the output name ever again

提交回复
热议问题