How to add PyTorch LTS version in setup.py?

Question:

I would like to know how I can include pytorch LTS version in my setup.py file for a library.

From the instructions on https://pytorch.org/get-started/locally/#start-locally , we can see that it needs additional information to find the package.
Here is the command they suggest :
pip3 install torch==1.8.2+cu111 torchvision==0.9.2+cu111 torchaudio==0.8.2 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html

Note the flag at the end -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html

I would like to know, how to include such option in a setup.py.

What I have tried

  • Using dependency_links, but it is now deprecated and ignored.
  • Using command line flag -f when trying to install my library (pip install -e . -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html ). This works but this is not a solution as it would require to enter it every time and would become hard to maintain with more url.

Setup.py

Here is what my setup.py looks like for now.

from setuptools import setup

setup(
    name="my_library",
    version="0.1",
    description="my library description",
    packages=["my_library"],
    python_requires=">=3.8",
    install_requires=[
        "torch==1.8.2+cu111@https://download.pytorch.org/whl/lts/1.8/torch_lts.html",
        "torchvision==0.9.2+cu111@https://download.pytorch.org/whl/lts/1.8/torch_lts.html",
        "pillow>=8.0.0",
        "numpy>=1.21.0",
        "timm==0.4.12",
    ]
)

Steps to reproduce issue

  1. pip install -e . --no-cache-dir

Actual Output

ERROR: Could not find a version that satisfies the requirement torch==1.8.2+cu111@https://download.pytorch.org/whl/lts/1.8/torch_lts.html (from mdai-core==0.1) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0)
ERROR: No matching distribution found for torch==1.8.2+cu111@https://download.pytorch.org/whl/lts/1.8/torch_lts.html

Expected Output

No error and install process of pytorch lts should begin.

PS : The == in the version requirements is for testing purposes so that it doesn’t download the 1.9 non-LTS. Once we’ll be sure it uses the LTS we’ll be a ble to use >= as it seems to be the recommended approach for libraries.

Thanks

Asked By: Alexandre Brown

||

Answers:

It looks like Pytorch just deprecated Pytorch LTS.
While this question is unanswered, since Pytorch LTS will be removed, it is not a relevant question anymore and one should move to a supported version of Pytorch instead.

Source: https://pytorch.org/blog/pytorch-enterprise-support-update/

Answered By: Alexandre Brown