How to add pytorch as a requirement for a windows python package

I have a python package which depends on pytorch and which I’d like windows users to be able to install via pip (the specific package is: https://github.com/mindsdb/lightwood, but I don’t think this is very relevant to my question).

What are the best practices for going about this ?

Are there some project I could use as examples ?

It seems like the pypi hosted version of torch & torchvision aren’t windows compatible and the “getting started” section suggests installing from the custom pytorch repository, but beyond that I’m not sure what the ideal solution would be to incorporate this as part of a setup script.

Pytorch is available on windows. did you check Pytorch.org?

Hmh, maybe I didn’t phrase my question correctly.

Could you tell me what you thought I was asking :?

It seems like the pypi hosted version of torch & torchvision aren’t windows compatible and the “getting started” section suggests installing from the custom pytorch repository, but beyond that I’m not sure what the ideal solution would be to incorporate this as part of a setup script.

Reading this, I thought you dont know about Pytorch.org that provides 100% windows compatible pip packages which you can use!
You can find all the packages here is as well https://download.pytorch.org/whl/torch_stable.html

Yes, the issue with that is that you can’t list them as a dependency, since pip will complain about downloading stuff from sources other than pypi and the version that pytroch has on pypi doesn’t seem to work on windows.

Please see my answers here: https://github.com/pytorch/pytorch/issues/32485#issuecomment-577113812.

1 Like

I did see the answer, problem being that I can’t do that for a pypi package, setup.py doesn’t support find-links anymore and if I use the @ syntax or some other syntax to set the repository it will complain about “Can’t depend on packages not hosted on pypi”.

The workaround I have right now is a manual install on windows as part of the setup script by calling a pip subprocess and trying the various versions: https://github.com/mindsdb/lightwood/blob/master/setup.py#L41

But it doesn’t look like it’s particularly best practiy to me.