Merge pull request #1551 from eli-schwartz/versioncheck
replace Meson version check with a specification-compliant version comparator
This commit is contained in:
commit
c5c332fa56
|
@ -18,6 +18,8 @@ import subprocess
|
||||||
import struct
|
import struct
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
from packaging.version import Version
|
||||||
|
|
||||||
from litex import get_data_mod
|
from litex import get_data_mod
|
||||||
from litex.gen import colorer
|
from litex.gen import colorer
|
||||||
|
|
||||||
|
@ -253,20 +255,18 @@ class Builder:
|
||||||
def _check_meson(self):
|
def _check_meson(self):
|
||||||
# Check Meson install/version.
|
# Check Meson install/version.
|
||||||
meson_present = (shutil.which("meson") is not None)
|
meson_present = (shutil.which("meson") is not None)
|
||||||
meson_version = [0, 0, 0]
|
meson_req = '0.59'
|
||||||
meson_major_min = 0
|
|
||||||
meson_minor_min = 59
|
|
||||||
if meson_present:
|
if meson_present:
|
||||||
meson_version = subprocess.check_output(["meson", "-v"]).decode("utf-8").split(".")
|
meson_version = subprocess.check_output(["meson", "-v"]).decode("utf-8")
|
||||||
if (not meson_present):
|
if not Version(meson_version) >= Version(meson_req):
|
||||||
msg = "Unable to find valid Meson build system, please install it with:\n"
|
msg = f"Meson version to old. Found: {meson_version}. Required: {meson_req}.\n"
|
||||||
msg += "- pip3 install meson.\n"
|
|
||||||
raise OSError(msg)
|
|
||||||
if (int(meson_version[0]) < meson_major_min) or (int(meson_version[0]) == meson_major_min and int(meson_version[1]) < meson_minor_min):
|
|
||||||
msg = f"Meson version to old. Found: {meson_version[0]}.{meson_version[1]}. Required: {meson_major_min}.{meson_minor_min}.\n"
|
|
||||||
msg += "Try updating with:\n"
|
msg += "Try updating with:\n"
|
||||||
msg += "- pip3 install -U meson.\n"
|
msg += "- pip3 install -U meson.\n"
|
||||||
raise OSError(msg)
|
raise OSError(msg)
|
||||||
|
else:
|
||||||
|
msg = "Unable to find valid Meson build system, please install it with:\n"
|
||||||
|
msg += "- pip3 install meson.\n"
|
||||||
|
raise OSError(msg)
|
||||||
|
|
||||||
def _prepare_rom_software(self):
|
def _prepare_rom_software(self):
|
||||||
# Create directories for all software packages.
|
# Create directories for all software packages.
|
||||||
|
|
Loading…
Reference in New Issue