From 0166dc4756a64d763010575118dd8341757d79a3 Mon Sep 17 00:00:00 2001 From: Siarhei Siniak Date: Fri, 9 May 2025 13:21:23 +0300 Subject: [PATCH] [+] partially migrate pr34 to meson.build 1. add wasm toolchain for meson; --- meson/toolchains/wasm-cross-meson.ini | 13 ++++++ python/cli.py | 1 + python/meson.build | 60 +++++++++++++++++++++++++++ python/pyproject.toml | 31 +++----------- 4 files changed, 80 insertions(+), 25 deletions(-) create mode 100644 meson/toolchains/wasm-cross-meson.ini create mode 100644 python/meson.build diff --git a/meson/toolchains/wasm-cross-meson.ini b/meson/toolchains/wasm-cross-meson.ini new file mode 100644 index 0000000..da0c2e1 --- /dev/null +++ b/meson/toolchains/wasm-cross-meson.ini @@ -0,0 +1,13 @@ +[binaries] +cpp = 'em++' +c = 'emcc' +ar = 'emar' +windres = '/usr/bin/false' +; exe_wrapper = '/usr/bin/false' +exe_wrapper = 'node' + +[host_machine] +system = 'linux' +cpu_family = 'x86_64' +cpu = 'x86_64' +endian = 'little' diff --git a/python/cli.py b/python/cli.py index 3e9e031..b190db9 100644 --- a/python/cli.py +++ b/python/cli.py @@ -47,6 +47,7 @@ class CLI(_cli.CLI): source_dir=self.settings.base_dir / 'python', build_dir=self.settings.base_dir / 'tmp' / 'online' / 'fxreader' / 'pr34' / 'build', dest_dir=self.settings.base_dir / 'tmp' / 'online' / 'fxreader' / 'pr34' / 'install', + meson_path=self.settings.base_dir / 'python' / 'meson.build', ) } diff --git a/python/meson.build b/python/meson.build new file mode 100644 index 0000000..7f612ef --- /dev/null +++ b/python/meson.build @@ -0,0 +1,60 @@ +project( + run_command( + 'tomlq', '-r', '.project.name', 'pyproject.toml', + check: true + ).stdout().strip('\n'), +# 'online.fxreader.uv', +# ['c', 'cpp'], + version: '0.1.5.16+27.7', +# default_options: [ +# 'cpp_std=c++23', +# # 'prefer_static=true', +# ], +) + +install_path = get_option('install_path') +message('install_path = ' + install_path) + +modes = get_option('modes') + +fs = import('fs') + +assert(modes.length() == 1, 'only one mode allowed') + +mode = modes[0] + + +project_root = '.' +source_dir = project_root +include_dir = project_root + + +if mode == 'meson' +# error() +endif + +if mode == 'pyproject' + py = import('python').find_installation(pure: false) + + namespace_path = meson.project_name().replace('.', '/') + + module_root = py.get_install_dir() / namespace_path + + py.install_sources( + [ + namespace_path, + ], + subdir: namespace_path, + ) + + install_data( + files( +# 'py.typed', + # '__init__.py', +# 'pyproject.toml', + 'py.typed', + ), + install_dir : namespace_path, + install_tag: 'python-runtime', + ) +endif diff --git a/python/pyproject.toml b/python/pyproject.toml index 9b3457f..73e8122 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,6 +1,9 @@ [project] name = 'online.fxreader.pr34' -version = '0.1.5.16+27.7' +# version = '0.1.5.16+27.7' +dynamic = [ + 'version', +] dependencies = [ #"-r requirements.txt", @@ -31,30 +34,8 @@ lint = [ early_features = ['default', 'early', 'lint',] [build-system] -requires = ['setuptools'] -build-backend = 'setuptools.build_meta' - -[tool.setuptools] -include-package-data = false - -[tool.setuptools.package-dir] -'online.fxreader.pr34' = 'online/fxreader/pr34' -#package_dir = '..' -#packages = ['online_fxreader'] -#[tool.setuptools.packages.find] -#where = ['../..'] -#include = ['../../online_fxreader/vpn'] -#exclude =['../../aiortc/*', '../../_cffi_src/*'] - -#[tool.setuptools.packages.find] -#exclude = ['*'] -#include = ['*.py'] - -# [tool.setuptools.exclude-package-data] -# 'online.fxreader.pr34' = ['online/fxreader/pr34/py.typed'] - -#[tool.setuptools.package-data] -#'online_fxreader.vpn' = ['requirements.txt'] +requires = ["meson-python", "pybind11"] +build-backend = "mesonpy" [project.scripts] online-fxreader-pr34-commands = 'online.fxreader.pr34.commands:commands_cli'