Reputation: 71
I'm trying to use the pipenv and pytorch.
To install pytorch in windows, I have to write following codes into the Pipfile:
[packages]
torch = {file = "http://download.pytorch.org/whl/cpu/torch-0.4.1-cp37-cp37m-win_amd64.whl"}
However, the wheel file is different for the linux.
[packages]
torch = {file = "http://download.pytorch.org/whl/cpu/torch-0.4.1.post2-cp37-cp37m-linux_x86_64.whl "}
How to specify both of them in Pipfile?
Upvotes: 7
Views: 2507
Reputation: 2633
This article demonstrates how to structure your Pipfile
to use pytorch
across multiple platforms. I tweaked their example to deal with whl
files on my local file system:
[packages]
pyfoo = {path = "./../pyfoo/dist/pyfoo-1.1.0-cp37-cp37m-linux_x86_64.whl", platform_system = "== 'Linux'"}
pyfoo-win = {path = "./../pyfoo/dist/pyfoo-1.1.0-py3-none-any.whl", platform_system = "== 'Windows'"}
In this case, pyfoo
is an internal libarary that has been built using python setup.py build
and python setup.py bdist_wheel
.
The article uses some kind of pipenv
generated hash in place of pyfoo-win
. I could not coerce pipenv
into generating that hash, so I created my own string. It may just be the prefix of the hash in the lock file.
Note: This approach is working for me, but there is a downer: both whl
files need to be present when you install packages. pipenv sync
bombs out if one of them is missing, even though it really only needs one of the two. Interestingly, the contents of the irrelevant file does not seem to matter. On my linux machine, I did an echo 'hello' >
to the windows whl file, and pipenv
was happy with it.
Upvotes: 2