简体   繁体   English

如何从 python 的安装文件中排除特定的依赖 package 版本

[英]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.我有一个小型 package,它在torch v1.8.0上不起作用,但在新的v1.8.1版本和其他旧版本v1.7.1上运行良好,所以想排除v1.8.0版本。
I could just set我可以设置

install_requires=[
    "torch>=1.8.1",
      ... 

but the torch package size is huge and also want mypackage to work on the older versions of the torch.但是手电筒 package 尺寸很大,并且还希望mypackage在旧版本的手电筒上工作。

I've tried我试过了

install_requires=[
    "torch>=1.8.1,!=1.8.0,<=1.7.1",
       ...

but when installing the package with pip install mypackage getting the following error:但是在使用pip install mypackage会出现以下错误:

ERROR: Could not find a version that satisfies the requirement torch!=1.8.0,<=1.7.1,>=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,<=1.7.1,>=1.8.1 (from mypackage)

how can exclude the v1.8.0 version?怎么能排除v1.8.0版本? thank you.谢谢你。

One can specify a minimum version and also exclude certain versions.可以指定最低版本,也可以排除某些版本。 Below, the minimum version is 1.0.0 .下面,最低版本是1.0.0 This should be set to a reasonable value depending on the project.这应根据项目设置为合理的值。

torch>=1.0.0,!=1.8.0

The issue with torch>=1.8.1,.=1.8,0.<=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. torch>=1.8.1,.=1.8,0.<=1.7.1的问题是它要求torch大于等于1.8.1小于等于1.7.1。 That is not possible, so pip cannot fulfill the request.这是不可能的,因此 pip 无法满足请求。

PEP 508 and PEP 440 are relevant here. PEP 508PEP 440在这里是相关的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM