获取 Poetry 除了 .cmd 之外还创建 .bat 文件

问题描述 投票:0回答:1

安装我的应用程序以运行单元测试时 (

poetry install --with dev
),Poetry 会在 Scripts 文件夹中创建一个 .cmd 文件(
D:\a\locust\locust\.tox\fail_fast_test_main\Scripts\locust.cmd
在 GH 上的 tox 中运行时)。

但是,我的测试需要验证已安装命令的行为,例如

subprocess.Popen(["locust", ...]

这在 Linux 上工作正常,但在 Windows 上,除非我使用

shell=True
,否则不会搜索 PATH(这会引入其他问题,特别是在 Linux 上)

如果我能让 Poetry 制作一个 .bat (甚至是 .exe - 在 Windows 上有一堆 .exe: 用于其他 Python 应用程序,我想它们只是与 .cmd 具有类似用途的包装器),我可以直接调用它,例如

D:\a\locust\locust\.tox\fail_fast_test_main\Scripts\locust.bat

有没有办法让Poetry生成这样的文件?

.cmd 文件无法直接执行(为了运行 .cmd,我需要运行

Popen(['cmd', '/c', 'D:\a\locust\locust\.tox\fail_fast_test_main\Scripts\locust.cmd'])
,这与运行
shell=True
本质上相同)

python-poetry
1个回答
0
投票

stackoverflow 要求答案包含超过 30 个字符,所以我们开始吧。 但这是一个是非问题,答案是否定的。

© www.soinside.com 2019 - 2024. All rights reserved.