update pip install .copy manifest for developments
This commit is contained in:
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import importlib.util
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -102,7 +103,11 @@ def bundle_items(repo_root: Path) -> list[dict]:
|
||||
|
||||
|
||||
def bundle_data_files(repo_root: Path) -> list[tuple[str, list[str]]]:
|
||||
"""Map bundle items marked dev_install=true to setuptools data_files entries."""
|
||||
"""Map bundle items marked ``dev_install=true`` to install destinations.
|
||||
|
||||
Kept for tests / tooling. Prefer :func:`stage_dev_bundle_into` for pip
|
||||
installs so files land inside ``site-packages/orisys/``.
|
||||
"""
|
||||
resolve_bundle_source_files = _load_wheel_layout_module().resolve_bundle_source_files
|
||||
|
||||
grouped: dict[str, list[str]] = {}
|
||||
@@ -123,3 +128,33 @@ def bundle_data_files(repo_root: Path) -> list[tuple[str, list[str]]]:
|
||||
grouped.setdefault(dest, []).append(rel_src)
|
||||
|
||||
return [(dest, sorted(files)) for dest, files in sorted(grouped.items())]
|
||||
|
||||
|
||||
def stage_dev_bundle_into(repo_root: Path, pkg_dir: Path) -> list[str]:
|
||||
"""Copy ``dev_install`` bundle files under ``pkg_dir`` (the orisys package).
|
||||
|
||||
Returns package-relative paths that were written (e.g. ``sensors/box/...``).
|
||||
"""
|
||||
resolve_bundle_source_files = _load_wheel_layout_module().resolve_bundle_source_files
|
||||
packaged: list[str] = []
|
||||
|
||||
for item in bundle_items(repo_root):
|
||||
if not item.get("dev_install", False):
|
||||
continue
|
||||
|
||||
src_dir = repo_root / item["source"]
|
||||
dst_dir = pkg_dir / item["target"]
|
||||
dst_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
for src_file in resolve_bundle_source_files(repo_root, item):
|
||||
if item.get("preserve_tree", False):
|
||||
rel = src_file.relative_to(src_dir)
|
||||
dst_file = dst_dir / rel
|
||||
else:
|
||||
rel = Path(src_file.name)
|
||||
dst_file = dst_dir / src_file.name
|
||||
dst_file.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(src_file, dst_file)
|
||||
packaged.append(f"{item['target']}/{rel.as_posix()}")
|
||||
|
||||
return packaged
|
||||
|
||||
Reference in New Issue
Block a user