[+] add default third_party_roots

This commit is contained in:
Siarhei Siniak 2025-06-05 18:34:13 +03:00
parent 520ea4211a
commit 4474e08e10
4 changed files with 47 additions and 8 deletions

@ -5,7 +5,7 @@ project(
).stdout().strip('\n'), ).stdout().strip('\n'),
# 'online.fxreader.uv', # 'online.fxreader.uv',
# ['c', 'cpp'], # ['c', 'cpp'],
version: '0.1.5.17+27.17', version: '0.1.5.17+27.18',
# default_options: [ # default_options: [
# 'cpp_std=c++23', # 'cpp_std=c++23',
# # 'prefer_static=true', # # 'prefer_static=true',

@ -561,7 +561,30 @@ class CLI(abc.ABC):
self, self,
project_name: Optional[str] = None, project_name: Optional[str] = None,
) -> list[pathlib.Path]: ) -> 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 meson_toolchains_t:
class res_t: class res_t:

@ -68,7 +68,14 @@ class PyProject:
pip_find_links: Optional[list[pathlib.Path]] = None pip_find_links: Optional[list[pathlib.Path]] = None
runtime_libdirs: Optional[list[pathlib.Path]] = None runtime_libdirs: Optional[list[pathlib.Path]] = None
runtime_preload: 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: [], default_factory=lambda: [],
) )
requirements: dict[str, pathlib.Path] = dataclasses.field(default_factory=lambda: dict()) 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: if 'third_party_roots' in pr34_tool:
res.third_party_roots = [ for o in check_list(pr34_tool['third_party_roots']):
o o2 = check_dict(o, str, str)
# pathlib.Path(o) assert all([k in {'package', 'module_root', 'path'} for k in o2])
for o in check_list(pr34_tool['third_party_roots'], str)
] 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: if 'requirements' in pr34_tool:
res.requirements = { res.requirements = {

Binary file not shown.