diff options
Diffstat (limited to 'python/mozbuild/mozbuild/buildversion.py')
-rw-r--r-- | python/mozbuild/mozbuild/buildversion.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/python/mozbuild/mozbuild/buildversion.py b/python/mozbuild/mozbuild/buildversion.py new file mode 100644 index 0000000000..a0a767ab82 --- /dev/null +++ b/python/mozbuild/mozbuild/buildversion.py @@ -0,0 +1,23 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + +import os +from pathlib import Path + +from packaging.version import Version + + +def mozilla_build_version(): + mozilla_build = os.environ.get("MOZILLABUILD") + + version_file = Path(mozilla_build) / "VERSION" + + assert version_file.exists(), ( + f'The MozillaBuild VERSION file was not found at "{version_file}".\n' + "Please check if MozillaBuild is installed correctly and that the" + "`MOZILLABUILD` environment variable is to the correct path." + ) + + with version_file.open() as file: + return Version(file.readline().rstrip("\n")) |