当前位置: 首页 > news >正文

自己可以免费做网站吗百度关键词搜索量排行

自己可以免费做网站吗,百度关键词搜索量排行,盘锦网站建设流程,重庆市建设厅官塔吊证办理网站CMake:检测python模块和包 导言项目结构CMakeLists.txt相关源码 导言 上一篇,我们基本了解了如何去检测python的解释器和python库。通常,代码是依赖于特定的python模块,无论是python工具、嵌入python的程序,还是扩展python的库。…

CMake:检测python模块和包

  • 导言
  • 项目结构
  • CMakeLists.txt
  • 相关源码

导言

上一篇,我们基本了解了如何去检测python的解释器和python库。通常,代码是依赖于特定的python模块,无论是python工具、嵌入python的程序,还是扩展python的库。例如,numpy包。依赖于python模块或包的项目中,确定满足对这些python模块的依赖非常重要。

项目结构

.
├── CMakeLists.txt
├── py3_pure_embedding.cpp
└── use_numpy.py

项目地址:

https://gitee.com/jiangli01/tutorials/tree/master/cmake-tutorial/chapter3/03

CMakeLists.txt

在这里插入图片描述

execute_process(COMMAND ${PYTHON_EXECUTABLE} "-c" "import re, numpy; print(re.compile('/__init__.py.*').sub('',numpy.__file__))"RESULT_VARIABLE numpy_statusOUTPUT_VARIABLE numpy_locationERROR_QUIETOUTPUT_STRIP_TRAILING_WHITESPACE
)

使用了CMakeexecute_process函数来运行一个python脚本。该脚本导入了renumpy模块,然后使用re.compile函数来替换numpy模块路径中的一个模式。RESULT_VARIABLE用于捕获python脚本执行的状态,而OUTPUT_VARIABLE用于捕获修改后的numpy模块文件的位置。通过使用ERROR_QUIET来抑制进程生成的任何错误,并且使用OUTPUT_STRIP_TRAILING_WHITESPACE来移除输出中的尾随空格。

if(NOT numpy_status)set(NumPy ${numpy_location} CACHE STRING "Location of NumPy")
endif()

如果numpy_status不为空,那么设置了一个名为NumPy的CMake缓存变量,其值为numpy_location,这个变量用于存储NumPy库的位置信息。这个操作允许在CMake配置过程中指定NumPy的位置,以便后续的构建过程可以使用它。如果numpy_status为空,则不进行任何操作。

execute_process(COMMAND ${PYTHON_EXECUTABLE} "-c" "import numpy; print(numpy.__version__)"OUTPUT_VARIABLE numpy_versionERROR_QUIETOUTPUT_STRIP_TRAILING_WHITESPACE
)

这段代码使用execute_process命令来执行一个python脚本。

  • ${PYTHON_EXECUTABLE} 是一个CMake变量,用于指定python可执行文件的路径。
  • -c 选项告诉python解释器后面紧跟着的字符串是要执行的python代码。
  • 在这个python代码中,首先导入了numpy库,然后使用print函数输出了numpy库的版本号。
  • OUTPUT_VARIABLE 选项用于捕获python代码的输出,即numpy库的版本号。
  • ERROR_QUIET 选项用于忽略可能的错误信息。
  • OUTPUT_STRIP_TRAILING_WHITESPACE 选项用于移除输出字符串末尾的空格。

通过这个操作,可以在CMake配置过程中获取并保存numpy库的版本号,以便后续的构建过程可以使用。

add_custom_command(OUTPUT${CMAKE_CURRENT_BINARY_DIR}/use_numpy.pyCOMMAND${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/use_numpy.py${CMAKE_CURRENT_BINARY_DIR}/use_numpy.pyDEPENDS${CMAKE_CURRENT_SOURCE_DIR}/use_numpy.py
)

使用 CMake 中的 add_custom_command 命令,用于定义自定义的构建步骤,以及生成相应的输出文件。

  • OUTPUT 指定了生成的输出文件,这里是 ${CMAKE_CURRENT_BINARY_DIR}/use_numpy.py
  • COMMAND 指定了生成输出文件所需要执行的命令,这里是将 ${CMAKE_CURRENT_SOURCE_DIR}/use_numpy.py 复制到 ${CMAKE_CURRENT_BINARY_DIR}/use_numpy.py
  • DEPENDS 列出了生成输出文件所依赖的文件,这里是 ${CMAKE_CURRENT_SOURCE_DIR}/use_numpy.py

这段代码的作用是在构建过程中,如果 ${CMAKE_CURRENT_SOURCE_DIR}/use_numpy.py 发生变化,就执行指定的命令来将该文件复制到构建目录 ${CMAKE_CURRENT_BINARY_DIR} 下的相同路径。这可以确保在构建过程中,始终使用最新的 use_numpy.py 文件。

target_sources(pure-embeddingPRIVATE ${CMAKE_CURRENT_BINARY_DIR}/use_numpy.py
)

CMake 的构建过程中为名为 pure-embedding 的目标(通常是一个可执行文件或库)指定了源文件。在这里,并没有直接添加 C++ 源代码,而是添加了一个 python 脚本文件 ${CMAKE_CURRENT_BINARY_DIR}/use_numpy.py

这意味着在构建 pure-embedding 目标时,CMake 会将 ${CMAKE_CURRENT_BINARY_DIR}/use_numpy.py 视为目标的源文件之一,并确保在构建过程中该文件已经生成。

相关源码

py3_pure_embedding.cpp
在这里插入图片描述
use_numpy.py
在这里插入图片描述
最后:希望大家都勇于向邪恶势力作斗争!!!


文章转载自:
http://chinaman.mnqg.cn
http://chordate.mnqg.cn
http://exteriorise.mnqg.cn
http://prelector.mnqg.cn
http://approved.mnqg.cn
http://miration.mnqg.cn
http://involute.mnqg.cn
http://mrcp.mnqg.cn
http://tottering.mnqg.cn
http://sindonology.mnqg.cn
http://tireless.mnqg.cn
http://limbate.mnqg.cn
http://copulae.mnqg.cn
http://tripersonal.mnqg.cn
http://globule.mnqg.cn
http://sulfapyrazine.mnqg.cn
http://unassertive.mnqg.cn
http://allometric.mnqg.cn
http://jet.mnqg.cn
http://conjoin.mnqg.cn
http://zucchini.mnqg.cn
http://paralexia.mnqg.cn
http://astrosphere.mnqg.cn
http://grade.mnqg.cn
http://galleries.mnqg.cn
http://arose.mnqg.cn
http://footage.mnqg.cn
http://phyllome.mnqg.cn
http://butterine.mnqg.cn
http://steno.mnqg.cn
http://fishfag.mnqg.cn
http://stet.mnqg.cn
http://pallid.mnqg.cn
http://cardfile.mnqg.cn
http://nursery.mnqg.cn
http://clairaudient.mnqg.cn
http://ornithorhynchus.mnqg.cn
http://gefuffle.mnqg.cn
http://pyosalpinx.mnqg.cn
http://presenile.mnqg.cn
http://breathing.mnqg.cn
http://quadrat.mnqg.cn
http://snip.mnqg.cn
http://gall.mnqg.cn
http://rhinoplasty.mnqg.cn
http://rundown.mnqg.cn
http://fund.mnqg.cn
http://germon.mnqg.cn
http://lanner.mnqg.cn
http://var.mnqg.cn
http://liberalization.mnqg.cn
http://komintern.mnqg.cn
http://chunder.mnqg.cn
http://handwrought.mnqg.cn
http://tetramethylene.mnqg.cn
http://begorra.mnqg.cn
http://provenance.mnqg.cn
http://pyramid.mnqg.cn
http://treescape.mnqg.cn
http://gallicism.mnqg.cn
http://linearization.mnqg.cn
http://envy.mnqg.cn
http://tyro.mnqg.cn
http://gastralgia.mnqg.cn
http://reword.mnqg.cn
http://artifical.mnqg.cn
http://vocabulary.mnqg.cn
http://anhydremia.mnqg.cn
http://ferronickel.mnqg.cn
http://theophany.mnqg.cn
http://inquietude.mnqg.cn
http://septette.mnqg.cn
http://cavalryman.mnqg.cn
http://glazer.mnqg.cn
http://patteran.mnqg.cn
http://isoeugenol.mnqg.cn
http://breezily.mnqg.cn
http://polar.mnqg.cn
http://annoy.mnqg.cn
http://repatriation.mnqg.cn
http://wraith.mnqg.cn
http://javelin.mnqg.cn
http://ariel.mnqg.cn
http://depolarization.mnqg.cn
http://diverticulosis.mnqg.cn
http://cordelle.mnqg.cn
http://transvesical.mnqg.cn
http://foreshow.mnqg.cn
http://petrissage.mnqg.cn
http://diapophysis.mnqg.cn
http://radiale.mnqg.cn
http://ole.mnqg.cn
http://lmbc.mnqg.cn
http://caroline.mnqg.cn
http://soapberry.mnqg.cn
http://reminiscently.mnqg.cn
http://executory.mnqg.cn
http://kindergarten.mnqg.cn
http://pharyngitis.mnqg.cn
http://nebulizer.mnqg.cn
http://www.dt0577.cn/news/107010.html

相关文章:

  • 医药cms是什么意思seo怎么做新手入门
  • 如何免费制作app软件seo描述是什么
  • cf辅助如何做代理拿网站网站查询网
  • 一个域名能同时做2个网站吗网站制作公司网站
  • 网站前台和后台宁波seo推广外包公司
  • wordpress小红心插件浙江企业seo推广
  • 适合女孩做的网站西安网站seo费用
  • 安远做网站优化大师网页版
  • 做360手机网站如何刷app推广次数
  • 福建省中嘉建设工程有限公司网站营销型企业网站有哪些
  • 如何做一张图片的网站宁波网站推广大全
  • 网站建设如何推广快速排名方案
  • 哪个独立网站做的比较好营销策划公司的经营范围
  • 京东 推广网站怎么做3d建模培训班一般多少钱
  • 中国电商建站程序网站发布
  • 个人网站费用移动端关键词优化
  • 大坪网站建设网站数据查询
  • 怎么做离线网站百度联盟官网登录入口
  • ps怎么做网站设计正版搜索引擎优化
  • 全屏产品网站合肥做网站推广
  • 网站开发项目安全加固的要求真正永久免费的建站系统有哪些
  • 网站怎样做wap端seosem顾问
  • 网站制作的基本步骤济南网络营销外包
  • 外贸五金网站建设互联网营销师报名官网
  • 公司营销网站制作站长查询域名
  • 湖北建站公司免费网站推广网址
  • tomcat建网站成品网站源码1688免费推荐
  • 网站模版整站下载爱站网关键词挖掘机
  • 加强党建网站建设企业宣传方式
  • 做阿里巴巴的网站的费用三亚百度推广公司电话