This feature is still under development, while it is recommended and usable and we will try not to break them in future releases, some breaking changes might still happen if necessary to prepare for the Conan 2.0 release.


Available since: 1.52.0

Variable of type Version (see below) that defines the version of the Conan client. You can use it in your recipes like:

from conan import ConanFile
from conan import conan_version

class pkg(ConanFile):
    def generate(self):
        if conan_version.major == "1":
            print("Running Conan 1.X")


Available since: 1.46.0


def __init__(self, value: str):

Construct a Version object from a string. It supports basic version comparison between objects, like for example:

compiler_lower_than_12 = Version(str(self.settings.compiler.version)) < "12.0"

Please note this is not an implementation of semver, as users may use any pattern in their versions. It is just a helper to parse “.” or “-” and compare taking into account integers when possible.


Available public properties since: 1.50.2


Get all the main digits.

def main(self):

For instance:

v = Version("")
assert [str(i) for i in v.main] == ['1', '2', '3', '4', '5']


Get the major digit.

def major(self):

For instance:

v = Version("")
assert str(v.major) == "1"


Get the minor digit.

def minor(self):

For instance:

v = Version("")
assert str(v.minor) == "2"


Get the patch digit.

def patch(self):

For instance:

v = Version("")
assert str(v.patch) == "3"


Get the micro digit.

def micro(self):

For instance:

v = Version("")
assert str(v.micro) == "4"


Get the pre-release digit.

def pre(self):

For instance:

v = Version("")
assert str(v.pre) == "alpha.3"


Get the build digit.

def build(self):

For instance:

v = Version("")
assert str( == "b1"