Warning
This tools are experimental and subject to breaking changes.
conan_version
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")
Version
Available since: 1.46.0
constructor
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.
Attributes
Available public properties since: 1.50.2
main
Get all the main digits.
@property
def main(self):
For instance:
v = Version("1.2.3.4-alpha.3+b1")
assert [str(i) for i in v.main] == ['1', '2', '3', '4', '5']
major
Get the major digit.
@property
def major(self):
For instance:
v = Version("1.2.3.4-alpha.3+b1")
assert str(v.major) == "1"
minor
Get the minor digit.
@property
def minor(self):
For instance:
v = Version("1.2.3.4-alpha.3+b1")
assert str(v.minor) == "2"
patch
Get the patch digit.
@property
def patch(self):
For instance:
v = Version("1.2.3.4-alpha.3+b1")
assert str(v.patch) == "3"
micro
Get the micro digit.
@property
def micro(self):
For instance:
v = Version("1.2.3.4-alpha.3+b1")
assert str(v.micro) == "4"
pre
Get the pre-release digit.
@property
def pre(self):
For instance:
v = Version("1.2.3.4-alpha.3+b1")
assert str(v.pre) == "alpha.3"
build
Get the build digit.
@property
def build(self):
For instance:
v = Version("1.2.3.4-alpha.3+b1")
assert str(v.build) == "b1"