Search code examples
pythonpython-poetry

Install different versions of a package on different platforms with poetry


In my project, I need to support both Linux and Windows, so I followed these guidelines and added these lines to my pyproject.toml file:

[tool.poetry.dependencies]
torch = [
    {url="https://download.pytorch.org/whl/cu101/torch-1.4.0-cp36-cp36m-win_amd64.whl", markers="sys_platform=='win32'"},
    {url="https://download.pytorch.org/whl/cu101/torch-1.4.0-cp36-cp36m-linux_x86_64.whl", markers="sys_platform!='win32'"}
]

(In addition I tried os_name=='nt') but when I try to run poetry update, I get the following error:

[RuntimeError]
The Poetry configuration is invalid:
  - [dependencies.torch] [{'url': 'https://download.pytorch.org/whl/cu101/torch-1.4.0-cp36-cp36m-win_amd64.whl', 'markers': "sys_platform=='win32'"}, {'url': 'https://download.pytorch.org/whl/cu101/torch-1.4.0-cp36-cp36m-linux_x86_64.whl', 'markers': "sys_platform!='win32'"}] is not valid under any of the given schemas

What is the right way to install different versions of the same package on different platforms using Poetry?


Solution

  • Apparently, this is a known bug, and there's a PR with a fix, although it's not merged or released yet