打包pybot,方便robot用例迁移而不依赖robot环境
查看bin目录下的pybot,发现是python脚本
于是想到了将脚本打包,到时候直接运行
#!/usr/local/bin/python3.7 import sys from robot import run_cli run_cli(sys.argv[1:])
使用pyinstaller打包之后,./pybot发现执行用例会报错:
[ ERROR ] Importing test library 'robot.libraries.BuiltIn' failed: Module 'robot.libraries' does not contain 'BuiltIn'.
想到了pyinstaller打包并不会将隐藏引用的包打进来,
需要修改pybots.spec文件,将文件设置为:
hiddenimports=['robot.libraries.BuiltIn','robot.libraries.Reserved','robot.libraries.Collections','robot.libraries.Easter','robot.libraries.OperatingSystem','robot.libraries.DateTime','robot.libraries.Dialogs','robot.libraries.Process','robot.libraries.Remote','robot.libraries.Screenshot','robot.libraries.String','robot.libraries.Telnet','robot.libraries.XML'],
最后pyinstaller pybot.spec即可