From 32b14b1bb533e10c7344c2e04125a226553c9b9f Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 16 Nov 2022 23:53:16 -0500 Subject: hotdoc module: run hotdoc as an external command during configure We need to run it as an external command at build time anyway, and we detect it by looking it up as an ExternalProgram. It seems odd to then import it into Meson's python interpreter and run the main function. Moreover, this errors out when you are running two different pythons, one for Meson and one for hotdoc. For example, when hotdoc is installed normally, but you're testing Meson against a nondefault newer version of python. --- mesonbuild/modules/hotdoc.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'mesonbuild/modules') diff --git a/mesonbuild/modules/hotdoc.py b/mesonbuild/modules/hotdoc.py index 800f766..6a0c48b 100644 --- a/mesonbuild/modules/hotdoc.py +++ b/mesonbuild/modules/hotdoc.py @@ -15,6 +15,7 @@ '''This module provides helper functions for generating documentation using hotdoc''' import os +import subprocess from collections import OrderedDict from mesonbuild import mesonlib @@ -392,12 +393,14 @@ class HotDocModule(ExtensionModule): self.hotdoc = ExternalProgram('hotdoc') if not self.hotdoc.found(): raise MesonException('hotdoc executable not found') + version = self.hotdoc.get_version(interpreter) + if not mesonlib.version_compare(version, f'>={MIN_HOTDOC_VERSION}'): + raise MesonException(f'hotdoc {MIN_HOTDOC_VERSION} required but not found.)') - try: - from hotdoc.run_hotdoc import run # noqa: F401 - self.hotdoc.run_hotdoc = run - except Exception as e: - raise MesonException(f'hotdoc {MIN_HOTDOC_VERSION} required but not found. ({e})') + def run_hotdoc(cmd): + return subprocess.run(self.hotdoc.get_command() + cmd, stdout=subprocess.DEVNULL).returncode + + self.hotdoc.run_hotdoc = run_hotdoc self.methods.update({ 'has_extensions': self.has_extensions, 'generate_doc': self.generate_doc, -- cgit v1.1