2

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.

balki
  • 26,394
  • 30
  • 105
  • 151

1 Answers1

0

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.

Raja G
  • 5,973
  • 14
  • 49
  • 82
  • The question is how to put that conditions in `requirements.txt` or `Pipfile`? – phd Jan 15 '19 at 05:42
  • Thanks! Even if there was a way to add using `platform`, this makes it specific to Ubuntu, I want it to be based on `libgit2` version. This doesn't scale for the thousands of distros. – balki Jan 15 '19 at 15:50