gpt4 book ai didi

python setup.py build命令解析

转载 作者:知者 更新时间:2024-03-12 23:22:11 25 4
gpt4 key购买 nike

python ——setup.py build_ext --inplace命令解析

1. 用python setup.py --help-commands
首先要有个setup.py,用setuptools实现python的setup,这里是一个setup.py的例子:

from setuptools import setup
from setuptools import Extension

example_module = Extension(name='numpy_demo',  # 模块名称
                           sources=['example.cpp'],    # 源码
                           include_dirs=[r'/home/data/CM/10_device/pybind11/include']
                           )

setup(ext_modules=[example_module])

该例子是用pybind11模块,用c++给python写一个模块

2. 命令解析

  • build_ext:build C/C++ extensions (compile/link to build directory),给python编译一个c、c++的拓展
  • –inplace:ignore build-lib and put compiled extensions into the source directory alongside your pure Python modules,忽略build-lib,将编译后的扩展放到源目录中,与纯Python模块放在一起

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com