pythonpippipenvpipfile

How to specify multiple sys_platforms with Pipenv


I'm trying to use Pipenv to specify a particular package to only install on Linux or Mac. According to pep496, I should be able to do something like this in a requirements file.

unicon; sys_platform == 'linux' or sys_platform  == 'darwin'

This is what the equivalent Pipfile section looks like.

[packages]
requests = "*"
unicon = {version = "*", sys_platform = "== 'linux' or == 'darwin'"}

This creates a Pipfile.lock without error but also without any marker information. When installing from windows it should just skip trying to install unicorn but it doesn't and there isn't a version of unicorn for windows so I get an install error.

I realize I could probably make things easy and just do sys_platform = "!= 'win32'" but I was wanting to be explicit about the platforms.

Is there any kind of in ['linux', 'darwin'] way to do this?


Solution

  • Using markers instead of sys_platform, the syntax from your PEP 496 example can be used to specify multiple platforms in Pipfile:

    [packages]
    unicon = {version = "*", markers = "sys_platform == 'linux' or sys_platform == 'darwin'"}