从 python 调用一个 bat 文件并导入环境
Call a bat file from python and import the environment
我正在编写一个 python 脚本来协调在 windows 上构建多个 Qt 项目。 python 脚本决定为哪个架构构建,以及使用哪个版本的 Visual Studio 和 Qt。完成后,我想 运行 正确的 qtenv2.bat 和 vcvarsall.bat 来设置我的环境,然后导入生成的环境以在我的 python 文件中使用。
如果 bat 文件只包含环境变量的设置,这会很容易,但由于还包含逻辑和东西,我实际上需要 运行 它们并获取它们所做的更改。
我可以使用多个 bat/py 脚本来解决这个问题,但我的目标是编写一个 python 脚本来处理这个构建过程。
"If the bat files contained only setting of environment variables this would be easy"
在批处理文件末尾包含一个 set
命令并捕获其输出,该输出将只是环境中变量及其值的列表
我正在编写一个 python 脚本来协调在 windows 上构建多个 Qt 项目。 python 脚本决定为哪个架构构建,以及使用哪个版本的 Visual Studio 和 Qt。完成后,我想 运行 正确的 qtenv2.bat 和 vcvarsall.bat 来设置我的环境,然后导入生成的环境以在我的 python 文件中使用。
如果 bat 文件只包含环境变量的设置,这会很容易,但由于还包含逻辑和东西,我实际上需要 运行 它们并获取它们所做的更改。
我可以使用多个 bat/py 脚本来解决这个问题,但我的目标是编写一个 python 脚本来处理这个构建过程。
"If the bat files contained only setting of environment variables this would be easy"
在批处理文件末尾包含一个 set
命令并捕获其输出,该输出将只是环境中变量及其值的列表