Bug 1891778 - Move mozilla_build_version out of mozbuild/util.py r=ahochheiden

Differential Revision: https://phabricator.services.mozilla.com/D207594
This commit is contained in:
serge-sans-paille 2024-04-19 09:08:57 +00:00
parent 420631590e
commit e003bc34c6
4 changed files with 25 additions and 19 deletions

View file

@ -15,7 +15,7 @@ import time
import blessed import blessed
import six import six
from mozbuild.util import mozilla_build_version from mozbuild.buildversion import mozilla_build_version
from packaging.version import Version from packaging.version import Version
IS_WINDOWS = sys.platform.startswith("win") IS_WINDOWS = sys.platform.startswith("win")

View file

@ -9,7 +9,7 @@ import subprocess
import sys import sys
from pathlib import Path from pathlib import Path
from mozbuild.util import mozilla_build_version from mozbuild.buildversion import mozilla_build_version
from packaging.version import Version from packaging.version import Version
from mozboot.base import BaseBootstrapper from mozboot.base import BaseBootstrapper

View file

@ -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"))

View file

@ -17,10 +17,8 @@ import os
import re import re
import sys import sys
from io import BytesIO, StringIO from io import BytesIO, StringIO
from pathlib import Path
import six import six
from packaging.version import Version
from mozbuild.dirutils import ensureParentDir from mozbuild.dirutils import ensureParentDir
@ -1229,18 +1227,3 @@ def hexdump(buf):
line += "|\n" line += "|\n"
lines.append(line) lines.append(line)
return lines return lines
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"))