From 503364e74dc9a90b5a943e5dcde9296963588cec Mon Sep 17 00:00:00 2001 From: rjdbcm Date: Wed, 28 Aug 2024 16:44:48 -0500 Subject: [PATCH] fix: add new style dep install Signed-off-by: rjdbcm --- meson.build | 10 +++++++ .../meson_postconf_install_dependencies.py | 28 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 ozi/scripts/meson_postconf_install_dependencies.py diff --git a/meson.build b/meson.build index 02061b61..d684d84f 100644 --- a/meson.build +++ b/meson.build @@ -155,6 +155,14 @@ to_distribution = run_command( ], check: true, ).stdout() +install_dependencies = run_command( + python, + [ + '-c', + python_readlines.format(scripts / 'meson_postconf_install_dependencies.py'), + ], + check: true, +).stdout() replace_ruff_target_version = run_command( python, [ @@ -206,6 +214,8 @@ configure_file( command: [python, '-c', meson_setuptools_scm], output: 'PKG-INFO', ) +deps = run_command(python, '-c', install_dependencies, check: true).stdout().strip().split('$$') +meson.add_postconf_script(pip, 'install', deps) meson.add_dist_script(pip, 'install', 'tomli>=2.0.0') meson.add_dist_script(python, '-c', meson_dist_setuptools_scm) vcs_tag(input: 'pyproject.toml', output: 'pyproject.orig.toml') diff --git a/ozi/scripts/meson_postconf_install_dependencies.py b/ozi/scripts/meson_postconf_install_dependencies.py new file mode 100644 index 00000000..f263e19e --- /dev/null +++ b/ozi/scripts/meson_postconf_install_dependencies.py @@ -0,0 +1,28 @@ + +import os +import sys +from pathlib import Path + +if sys.version_info >= (3, 11): # pragma: no cover + import tomllib as toml +elif sys.version_info < (3, 11): # pragma: no cover + import tomli as toml + + +if __name__ == '__main__': + source = '/' / Path( + os.path.relpath( + os.path.join('/', os.environ.get('MESON_BUILD_ROOT', os.path.relpath('..'))), + '/', + ), + ) + dist = '/' / Path( + os.path.relpath( + os.path.join('/', os.environ.get('MESON_DIST_ROOT', os.path.relpath('..'))), + '/', + ), + ) + with (source / 'pyproject.toml').open('rb') as project_file: + pyproject_toml = toml.load(project_file) + dependencies = pyproject_toml.get('project', {}).get('dependencies', []) + print('$$'.join(dependencies))