Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which version of fabric API is installed

Tags:

python

fabric

How might I discover which version of fabric I have installed - through the API?

I understand that I can just run

$ fab --version

but I'd rather be doing something like

>>> import fabric
>>> fabric.version
'1.4.1'
like image 672
danodonovan Avatar asked Apr 11 '12 16:04

danodonovan


3 Answers

There's the version submodule in fabric:

>>>import fabric.version
>>>fabric.version.get_version()
'1.2.2'
like image 125
skinp Avatar answered Oct 20 '22 02:10

skinp


You don't need to even do that, it's in the docs:

from fabric.api import *
print env.version
like image 22
Morgan Avatar answered Oct 20 '22 02:10

Morgan


Sadly with Fabric 2 you have now to do something like

import fabric
if hasattr(fabric, '__version__'):
    # For fabric2
    print(fabric.__version_info__)
    print(fabric.__version__)   # for a version tuple
else:
    # for fabric1
    from fabric.api import *
    print(env.version)
like image 2
tobltobs Avatar answered Oct 20 '22 02:10

tobltobs