setup.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:implicit 作者: benfred 项目源码 文件源码
def define_extensions(use_cython=False):
    if sys.platform.startswith("win"):
        # compile args from
        # https://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx
        compile_args = ['/O2', '/openmp']
        link_args = []
    else:
        compile_args = ['-Wno-unused-function', '-Wno-maybe-uninitialized', '-O3', '-ffast-math']
        link_args = []
        if use_openmp:
            compile_args.append("-fopenmp")
            link_args.append("-fopenmp")

    src_ext = '.pyx' if use_cython else '.cpp'
    modules = [Extension("implicit." + name,
                         [os.path.join("implicit", name + src_ext)],
                         language='c++',
                         extra_compile_args=compile_args, extra_link_args=link_args)
               for name in ['_als', '_nearest_neighbours']]

    if CUDA:
        modules.append(Extension("implicit.cuda._cuda",
                                 [os.path.join("implicit", "cuda", "_cuda" + src_ext),
                                  os.path.join("implicit", "cuda", "als.cu"),
                                  os.path.join("implicit", "cuda", "matrix.cu")],
                                 language="c++",
                                 extra_compile_args=compile_args,
                                 extra_link_args=link_args,
                                 library_dirs=[CUDA['lib64']],
                                 libraries=['cudart', 'cublas'],
                                 runtime_library_dirs=[CUDA['lib64']],
                                 include_dirs=[CUDA['include'], '.']))

    if use_cython:
        return cythonize(modules)
    else:
        return modules


# set_gcc copied from glove-python project
# https://github.com/maciejkula/glove-python
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号