如何使用 Pipenv 指定多个 sys_platforms

Gab*_* G. 9 python pip pipenv pipfile

我试图用来Pipenv指定一个特定的包,只安装在 Linux 或 Mac 上。根据pep496,我应该能够在需求文件中做这样的事情。

unicon; sys_platform == 'linux' or sys_platform  == 'darwin'
Run Code Online (Sandbox Code Playgroud)

这就是等效Pipfile部分的样子。

[packages]
requests = "*"
unicon = {version = "*", sys_platform = "== 'linux' or == 'darwin'"}
Run Code Online (Sandbox Code Playgroud)

这将创建一个Pipfile.lock没有错误但也没有任何标记信息的信息。从 Windows 安装时,它应该只是跳过尝试安装,unicorn但它没有,并且没有适用于 Windows 的 unicorn 版本,所以我收到安装错误。

我意识到我可能可以让事情变得简单,只是做,sys_platform = "!= 'win32'"但我想明确平台。

有没有in ['linux', 'darwin']办法做到这一点?

Jon*_*tra 4

使用PEP 496 示例中的语法markers代替sys_platform,可用于在 中指定多个平台Pipfile

[packages]
unicon = {version = "*", markers = "sys_platform == 'linux' or sys_platform == 'darwin'"}
Run Code Online (Sandbox Code Playgroud)