【问题标题】:Trigger catkin build process from within python从 python 中触发 catkin 构建过程
【发布时间】:2020-01-06 13:10:32
【问题描述】:

我正在编写一个 python 脚本来组织一个由多个 repos 组成的项目。一些目标是使用 catkin 构建的。由于 catkin 是一个 python 工具,我怀疑必须有一种方法可以从 python 脚本中调用与catkin build 等效的方法。 但是,我正在努力这样做。到目前为止,我最接近的是:

from catkin_tools.commands import catkin
catkin.main(["build"])

但是,这对我来说看起来不正确,除了在完成构建过程后,我最终得到:

Exception ignored in: <bound method BaseEventLoop.__del__ of <_UnixSelectorEventLoop running=False closed=True debug=False>>
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.6/site-packages/trollius/base_events.py", line 395, in __del__
  File "/home/user/.local/lib/python3.6/site-packages/trollius/unix_events.py", line 65, in close
  File "/home/user/.local/lib/python3.6/site-packages/trollius/unix_events.py", line 166, in remove_signal_handler
  File "/usr/lib/python3.6/signal.py", line 47, in signal
TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object

有没有一些pythonic的方法可以通过运行python程序来构建catkin包?

【问题讨论】:

    标签: python-3.x catkin


    【解决方案1】:

    原来我看到的异常是由于在 python3.6 中没有正确支持 trollius。在最新版本的 catkin_tools 中,trollius is replaced by asyncio。由于无法通过 pip 或 apt install 进行此更改,因此我必须从源代码安装 catkin。

    此外,我解决问题的方式当然可以改进,但目前可行。

    from catkin_tools.commands import catkin
    try:
       catkin.main(["build","testtarget","--cmake-args","-DFLAG"])
    except SystemExit as ret:
       if ret.code == 0:
          return True
       else:
          return False
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-24
      • 1970-01-01
      • 2014-06-07
      • 2013-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多