From 4474e08e1006720ef0380fa344b0c9e22906c139 Mon Sep 17 00:00:00 2001 From: Siarhei Siniak Date: Thu, 5 Jun 2025 18:34:13 +0300 Subject: [PATCH] [+] add default third_party_roots --- python/meson.build | 2 +- .../fxreader/pr34/commands_typed/cli.py | 25 ++++++++++++++++++- .../pr34/commands_typed/cli_bootstrap.py | 25 ++++++++++++++----- ...eader_pr34-0.1.5.17+27.18-py3-none-any.whl | 3 +++ 4 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 releases/whl/online_fxreader_pr34-0.1.5.17+27.18-py3-none-any.whl diff --git a/python/meson.build b/python/meson.build index 07bb7c0..869c477 100644 --- a/python/meson.build +++ b/python/meson.build @@ -5,7 +5,7 @@ project( ).stdout().strip('\n'), # 'online.fxreader.uv', # ['c', 'cpp'], - version: '0.1.5.17+27.17', + version: '0.1.5.17+27.18', # default_options: [ # 'cpp_std=c++23', # # 'prefer_static=true', diff --git a/python/online/fxreader/pr34/commands_typed/cli.py b/python/online/fxreader/pr34/commands_typed/cli.py index 82073d1..cbeb73d 100644 --- a/python/online/fxreader/pr34/commands_typed/cli.py +++ b/python/online/fxreader/pr34/commands_typed/cli.py @@ -561,7 +561,30 @@ class CLI(abc.ABC): self, project_name: Optional[str] = None, ) -> list[pathlib.Path]: - return [] + from . import cli_bootstrap + from .pip import pip_show + + res: list[pathlib.Path] = [] + + if not project_name is None: + pyproject = cli_bootstrap.pyproject_load(self.projects[project_name].source_dir / 'pyproject.toml') + + for third_party_root in pyproject.third_party_roots: + if third_party_root.package: + if not third_party_root.module_root: + third_party_root.module_root = third_party_root.package.replace('.', os.path.sep) + if not third_party_root.path: + packages = pip_show([third_party_root.package]) + assert len(packages) == 1 + third_party_root.path = str(pathlib.Path(packages[0].location) / third_party_root.module_root / 'lib') + else: + assert not third_party_root.package and not third_party_root.module_root and third_party_root.path + + res.append(pathlib.Path(third_party_root.path)) + + # res.append(self.projects[project_name].dest_dir / 'lib') + + return res class meson_toolchains_t: class res_t: diff --git a/python/online/fxreader/pr34/commands_typed/cli_bootstrap.py b/python/online/fxreader/pr34/commands_typed/cli_bootstrap.py index 2ac1f1d..bbe275f 100644 --- a/python/online/fxreader/pr34/commands_typed/cli_bootstrap.py +++ b/python/online/fxreader/pr34/commands_typed/cli_bootstrap.py @@ -68,7 +68,14 @@ class PyProject: pip_find_links: Optional[list[pathlib.Path]] = None runtime_libdirs: Optional[list[pathlib.Path]] = None runtime_preload: Optional[list[pathlib.Path]] = None - third_party_roots: list[str] = dataclasses.field( + + @dataclasses.dataclass + class ThirdPartyRoot: + package: Optional[str] = None + module_root: Optional[str] = None + path: Optional[str] = None + + third_party_roots: list[ThirdPartyRoot] = dataclasses.field( default_factory=lambda: [], ) requirements: dict[str, pathlib.Path] = dataclasses.field(default_factory=lambda: dict()) @@ -241,11 +248,17 @@ def pyproject_load( ] if 'third_party_roots' in pr34_tool: - res.third_party_roots = [ - o - # pathlib.Path(o) - for o in check_list(pr34_tool['third_party_roots'], str) - ] + for o in check_list(pr34_tool['third_party_roots']): + o2 = check_dict(o, str, str) + assert all([k in {'package', 'module_root', 'path'} for k in o2]) + + res.third_party_roots.append( + PyProject.ThirdPartyRoot( + package=o2.get('package'), + module_root=o2.get('module_root'), + path=o2.get('path'), + ) + ) if 'requirements' in pr34_tool: res.requirements = { diff --git a/releases/whl/online_fxreader_pr34-0.1.5.17+27.18-py3-none-any.whl b/releases/whl/online_fxreader_pr34-0.1.5.17+27.18-py3-none-any.whl new file mode 100644 index 0000000..738ad7c --- /dev/null +++ b/releases/whl/online_fxreader_pr34-0.1.5.17+27.18-py3-none-any.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:346be68568fb26152695e9d2dda052867c6640a07f0be11ff8733b34ebdfa490 +size 71259