Reputation: 618
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?
Upvotes: 12
Views: 6417
Reputation: 2779
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'"}
Upvotes: 5
Reputation: 1192
I found a way to not install pypiwin32 on Linux. I had to specify another dependency not listed in my requirements.txt: pywin32
Additionally, I used the os_name marker :
pypiwin32 = { version = "==223", os_name = "=='nt'"}
pywin32 = {version = "*", os_name = "=='nt'"}
And the two packages need the markers
in Pipfile:
"markers": "os_name == 'nt'",
The installation using pipenv now works.
Upvotes: 1