From 43c85ca162fec128fa710a59f178940d61c9ca12 Mon Sep 17 00:00:00 2001 From: Siarhei Siniak Date: Mon, 12 May 2025 10:30:35 +0300 Subject: [PATCH] [+] partially update meson_install --- .../fxreader/pr34/commands_typed/cli.py | 49 ++++++++++++++++++- .../pr34/commands_typed/cli_bootstrap.py | 1 + 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/python/online/fxreader/pr34/commands_typed/cli.py b/python/online/fxreader/pr34/commands_typed/cli.py index a76caa6..9c969b7 100644 --- a/python/online/fxreader/pr34/commands_typed/cli.py +++ b/python/online/fxreader/pr34/commands_typed/cli.py @@ -5,6 +5,7 @@ import os import pathlib import logging import sys +import pydantic import subprocess import shutil import abc @@ -27,6 +28,29 @@ class Project: dest_dir : pathlib.Path meson_path: Optional[pathlib.Path] = None +class PyProject: + class Tool: + class Meson: + class Args: + install: list[str] + + args: Args + + class MesonPython: + class Args: + install: list[str] + + args: Args + + meson: Optional[Meson] = None + + meson_python: Optional[MesonPython] = pydantic.Field( + alias='meson-python', + default=None, + ) + + tool: Optional[Tool] = None + @dataclasses.dataclass class Dependency: name: str @@ -336,14 +360,35 @@ class CLI(abc.ABC): if force and project.dest_dir.exists(): shutil.rmtree(project.dest_dir) - subprocess.check_call([ + pyproject = cli_bootstrap.pyproject_load( + project.source_dir / 'pyproject.toml' + ) + + pyproject_tool = pydantic.RootModel[ + PyProject + ].model_validate(pyproject.module) + + if ( + pyproject_tool.meson and + pyproject_tool.meson.args and + pyproject_tool.meson.args.install + ): + argv = pyproject_tool.meson.args.install + argv + + cmd = [ shutil_which('meson', True,), 'install', '-C', project.build_dir / 'meson', '--destdir', project.dest_dir, *argv, - ]) + ] + + logger.info(dict( + cmd=cmd, + )) + + subprocess.check_call(cmd) for o in glob.glob( str(project.dest_dir / 'lib' / 'pkgconfig' / '*.pc'), diff --git a/python/online/fxreader/pr34/commands_typed/cli_bootstrap.py b/python/online/fxreader/pr34/commands_typed/cli_bootstrap.py index 259392c..5f137b2 100644 --- a/python/online/fxreader/pr34/commands_typed/cli_bootstrap.py +++ b/python/online/fxreader/pr34/commands_typed/cli_bootstrap.py @@ -41,6 +41,7 @@ class PyProject: meson: Optional[pathlib.Path] = None tool: dict[str, Any] = dataclasses.field(default_factory=lambda : dict()) + path: pathlib.Path dependencies: dict[str, list[str]] early_features: Optional[list[str]] = None