|
91 | 91 | 'reset': '\33[0m',
|
92 | 92 | }
|
93 | 93 | _NO_COLORS = {color: '' for color in _COLORS}
|
| 94 | + |
94 | 95 | _NINJA_REQUIRED_VERSION = '1.8.2'
|
| 96 | +_MESON_REQUIRED_VERSION = '0.63.3' # keep in sync with the version requirement in pyproject.toml |
95 | 97 |
|
96 | 98 |
|
97 | 99 | class _depstr:
|
@@ -750,7 +752,8 @@ def __init__(
|
750 | 752 | self._meson_args: MesonArgs = collections.defaultdict(list)
|
751 | 753 | self._env = os.environ.copy()
|
752 | 754 |
|
753 |
| - # prepare environment |
| 755 | + _check_meson_version() |
| 756 | + |
754 | 757 | self._ninja = _env_ninja_command()
|
755 | 758 | if self._ninja is None:
|
756 | 759 | raise ConfigError(f'Could not find ninja version {_NINJA_REQUIRED_VERSION} or newer.')
|
@@ -1129,6 +1132,22 @@ def _env_ninja_command(*, version: str = _NINJA_REQUIRED_VERSION) -> Optional[st
|
1129 | 1132 | return None
|
1130 | 1133 |
|
1131 | 1134 |
|
| 1135 | +def _check_meson_version(*, version: str = _MESON_REQUIRED_VERSION) -> None: |
| 1136 | + """Check that the meson executable in the path has an appropriate version. |
| 1137 | +
|
| 1138 | + The meson Python package is a dependency of the meson-python |
| 1139 | + Python package, however, it may occur that the meson Python |
| 1140 | + package is installed but the corresponding meson command is not |
| 1141 | + available in $PATH. Implement a runtime check to verify that the |
| 1142 | + build environment is setup correcly. |
| 1143 | +
|
| 1144 | + """ |
| 1145 | + required_version = _parse_version_string(version) |
| 1146 | + meson_version = subprocess.run(['meson', '--version'], check=False, text=True, capture_output=True).stdout |
| 1147 | + if _parse_version_string(meson_version) < required_version: |
| 1148 | + raise ConfigError(f'Could not find meson version {version} or newer, found {meson_version}.') |
| 1149 | + |
| 1150 | + |
1132 | 1151 | def _pyproject_hook(func: Callable[P, T]) -> Callable[P, T]:
|
1133 | 1152 | @functools.wraps(func)
|
1134 | 1153 | def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
|
|
0 commit comments