finished docker manylinux compliation for pypi

This commit is contained in:
ykcheungab
2026-08-03 17:07:54 +08:00
parent 3117ddd5b9
commit d7c5845646
31 changed files with 709 additions and 52 deletions
+21 -9
View File
@@ -2,7 +2,7 @@
from __future__ import annotations
import importlib
import ast
import subprocess
import sys
from pathlib import Path
@@ -41,17 +41,29 @@ def extras_require(repo_root: Path) -> dict[str, list[str]]:
def _resolve_version_attr(repo_root: Path, attr: str) -> str:
"""Resolve a setuptools dynamic version attr (e.g. orisys.__version__)."""
src_dir = str(repo_root / "src")
if src_dir not in sys.path:
sys.path.insert(0, src_dir)
module_name, _, attr_name = attr.partition(".")
if not attr_name:
raise RuntimeError(f"Invalid dynamic version attr: {attr!r}")
module = importlib.import_module(module_name)
value = module
for name in attr_name.split("."):
value = getattr(value, name)
return str(value)
# Avoid importing package modules here: __init__ may import heavy runtime deps
# (e.g., cv2/numpy) that are not required just to read __version__.
rel_module = Path(*module_name.split("."))
module_file = repo_root / "src" / rel_module.with_suffix(".py")
if not module_file.is_file():
module_file = repo_root / "src" / rel_module / "__init__.py"
if not module_file.is_file():
raise RuntimeError(f"Cannot resolve module file for dynamic version attr: {attr!r}")
tree = ast.parse(module_file.read_text(encoding="utf-8"), filename=str(module_file))
target_name = attr_name.split(".")[0]
for node in tree.body:
if isinstance(node, ast.Assign):
for target in node.targets:
if isinstance(target, ast.Name) and target.id == target_name:
value = ast.literal_eval(node.value)
return str(value)
raise RuntimeError(f"Attribute {target_name!r} not found in {module_file}")
def get_version(repo_root: Path) -> str: