基于可用操作系统库版本的 pip 要求 [英] pip requirement based on available OS library version
问题描述
我正在开发一个基于 pygit2
的 python 包.pygit2 依赖于 libgit2
.
Ubuntu 18.04 版本为 libgit2-2.6
Ubuntu 18.10 版本为 libgit2-2.7
在我的requirements.txt/Pipfile中,如果我有"pygit2" = "==0.26.4"
,它可以在18.04运行(在执行apt-get install libgit2-dev
) 但不是在 18.10.类似地,取决于 "*"
或 "==0.27"
在 18.10 上有效,但在 18.04 上无效.我还没有尝试过其他发行版.有没有一种方法可以指定,
如果 os 有 libgit2-2.6pygit2 == 0.26.4否则如果 os 有 libgit2-2.7pygit2 == 0.27.x
我尝试了 pygit2>=0.26.4
,但不适用于 18.04.
您可以使用 platform
模块指定特定版本的模块.
希望有帮助.
I am developing a python package based on pygit2
. pygit2 depends on libgit2
.
Ubuntu 18.04 has version libgit2-2.6
Ubuntu 18.10 has version libgit2-2.7
In my requirements.txt/Pipfile, if I have "pygit2" = "==0.26.4"
, it works in 18.04 (after doing apt-get install libgit2-dev
) but not in 18.10. Similarly, depending on "*"
or "==0.27"
works on 18.10 but not on 18.04. I have not tried on other distros. Is there a way I can specify like,
if os has libgit2-2.6
pygit2 == 0.26.4
else if os has libgit2-2.7
pygit2 == 0.27.x
I tried pygit2>=0.26.4
, didn't work for 18.04.
You can specify version specific modules by using platform
module.
>>> platform.platform().split('-')[6]
'18.04'
>>>
>>> import platform
>>> if "18.04" in platform.platform():
... print("install 18.04 modules")
... elif "18.10" in platform.platform():
... print("Install 18.10 modules")
...
install 18.04 modules
>>>
Hope it helps.
这篇关于基于可用操作系统库版本的 pip 要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!