how to exclude particular dependency package version from setup file in python
I've a small package that does not work on torch v1.8.0 but it works fine on the new v1.8.1 version and other older versions v1.7.1 so want to exclude the v1.8.0 version.

I could just set
install_requires=[
    &quot;torch&gt;=1.8.1&quot;,
      ... 

but the torch package size is huge and also want mypackage to work on the older versions of the torch.
I've tried
install_requires=[
    &quot;torch&gt;=1.8.1,!=1.8.0,&lt;=1.7.1&quot;,
       ...

but when installing the package with pip install mypackage getting the following error:
ERROR: Could not find a version that satisfies the requirement torch!=1.8.0,&lt;=1.7.1,&gt;=1.8.1 (from mypackage) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 0.4.1, 0.4.1.post2, 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1)
ERROR: No matching distribution found for torch!=1.8.0,&lt;=1.7.1,&gt;=1.8.1 (from mypackage)

how can exclude the v1.8.0 version? thank you.

One can specify a minimum version and also exclude certain versions. Below, the minimum version is 1.0.0. This should be set to a reasonable value depending on the project.
torch&gt;=1.0.0,!=1.8.0

The issue with torch&gt;=1.8.1,!=1.8.0,&lt;=1.7.1 is that it requests torch greater than or equal to 1.8.1 and less than or equal to 1.7.1. That is not possible, so pip cannot fulfill the request.
PEP 508 and PEP 440 are relevant here.
