feat: Add GitHub Actions workflow for building and testing the Depth Anything 3 extension

- Create a build workflow in `.github/workflows/build.yml` to automate the build process.
- Configure Python environment and install dependencies.
- Add steps for running tests and packaging the extension.

chore: Initialize project metadata and dependencies for Depth Anything 3

- Add `pyproject.toml` for project configuration and dependencies.
- Include optional dependencies for app and gs functionalities.
- Define project scripts and metadata.

chore: Add requirements file for Depth Anything 3 dependencies

- Create `requirements.txt` listing all necessary packages for the project.

feat: Implement export utility functions for Depth Anything 3

- Create `src/depth_anything_3/utils/export/__init__.py` to handle various export formats.
- Implement functions for exporting predictions in different formats.

feat: Add ray utility functions for homography estimation

- Create `src/depth_anything_3/utils/ray_utils.py` with functions for computing optimal rotation and homography using RANSAC.

feat: Implement vendor preparation script

- Add `prepare_vendor.py` to manage third-party dependencies and artifacts.
- Include functions for downloading and verifying artifacts based on a lock file.

test: Add unit tests for vendor preparation script

- Create `tests/test_prepare_vendor.py` to test artifact downloading and verification.
- Implement tests for handling hash mismatches and unsupported platforms.

chore: Add vendor lock file for dependency management

- Create `vendor.lock.toml` to define artifacts and platforms for the project.
This commit is contained in:
2026-08-09 11:44:24 +08:00
parent 97a720051f
commit 2e8af26cdf
17 changed files with 1341 additions and 108 deletions

View File

@@ -27,12 +27,12 @@ def load_bootstrap_runtime():
class BootstrapRuntimeTest(unittest.TestCase):
def create_bundled_sources(self, root):
sources = root / "sources"
sources.mkdir()
(sources / "depth-anything-3.tar.gz").write_bytes(b"da3")
(sources / "ben2.tar.gz").write_bytes(b"ben2")
return sources
def create_bundled_vendor(self, root):
vendor = root / "vendor"
vendor.mkdir()
(vendor / "depth-anything-3.tar.gz").write_bytes(b"da3")
(vendor / "ben2.tar.gz").write_bytes(b"ben2")
return vendor
def test_installs_da3_from_archives_without_gsplat(self):
bootstrap = load_bootstrap_runtime()
@@ -40,11 +40,11 @@ class BootstrapRuntimeTest(unittest.TestCase):
root = Path(directory)
runtime_dir = root / "runtime"
runtime_dir.mkdir()
self.create_bundled_sources(root)
self.create_bundled_vendor(root)
da3_uri = (
root / "sources" / "depth-anything-3.tar.gz"
root / "vendor" / "depth-anything-3.tar.gz"
).as_uri()
ben2_uri = (root / "sources" / "ben2.tar.gz").as_uri()
ben2_uri = (root / "vendor" / "ben2.tar.gz").as_uri()
uv_path = root / "uv"
uv_path.write_bytes(b"uv")
args = SimpleNamespace(
@@ -184,7 +184,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
root = Path(directory)
runtime_dir = root / "runtime"
runtime_dir.mkdir()
self.create_bundled_sources(root)
self.create_bundled_vendor(root)
uv_path = root / "uv"
uv_path.write_bytes(b"uv")
args = SimpleNamespace(
@@ -356,7 +356,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
root = Path(directory)
runtime_dir = root / "runtime"
runtime_dir.mkdir()
self.create_bundled_sources(root)
self.create_bundled_vendor(root)
uv_path = root / "uv"
uv_path.write_bytes(b"uv")
args = SimpleNamespace(
@@ -662,7 +662,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
root = Path(directory)
runtime_dir = root / "runtime"
runtime_dir.mkdir()
self.create_bundled_sources(root)
self.create_bundled_vendor(root)
uv_path = root / "uv"
uv_path.write_bytes(b"uv")
args = SimpleNamespace(
@@ -705,7 +705,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
root = Path(directory)
runtime_dir = root / "runtime"
runtime_dir.mkdir()
self.create_bundled_sources(root)
self.create_bundled_vendor(root)
(runtime_dir / "partial-python.exe").write_text("junk")
args = SimpleNamespace(
uv="uv",
@@ -738,7 +738,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
root = Path(directory)
runtime_dir = root / "runtime"
runtime_dir.mkdir(parents=True)
self.create_bundled_sources(root)
self.create_bundled_vendor(root)
(runtime_dir / "Scripts").mkdir()
(runtime_dir / "Scripts" / "python.exe").write_text("python")
(runtime_dir / "snapform_ready.json").write_text(
@@ -783,7 +783,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
root = Path(directory)
runtime_dir = root / "runtime"
runtime_dir.mkdir()
self.create_bundled_sources(root)
self.create_bundled_vendor(root)
args = SimpleNamespace(
uv="uv",
runtime_dir=str(runtime_dir),
@@ -823,7 +823,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
root = Path(directory)
runtime_dir = root / "runtime"
runtime_dir.mkdir()
self.create_bundled_sources(root)
self.create_bundled_vendor(root)
uv_path = root / "uv" / "uv.exe"
args = SimpleNamespace(
uv=str(uv_path),
@@ -858,7 +858,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
):
bootstrap.install(args)
def test_install_uses_bundled_sources_and_uv_without_network(self):
def test_install_uses_bundled_vendor_and_uv_without_network(self):
bootstrap = load_bootstrap_runtime()
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
@@ -911,7 +911,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
with patch.object(
bootstrap,
"bundled_sources_directory",
"bundled_vendor_directory",
return_value=bundled,
), patch.object(
bootstrap,
@@ -946,8 +946,8 @@ class BootstrapRuntimeTest(unittest.TestCase):
for command in install_commands
if any("depth-anything-3 @" in str(value) for value in command)
)
da3_uri = (root / "sources" / "depth-anything-3.tar.gz").as_uri()
ben2_uri = (root / "sources" / "ben2.tar.gz").as_uri()
da3_uri = (root / "vendor" / "depth-anything-3.tar.gz").as_uri()
ben2_uri = (root / "vendor" / "ben2.tar.gz").as_uri()
self.assertIn(f"depth-anything-3 @ {da3_uri}", ai_command)
self.assertIn(f"ben2 @ {ben2_uri}", ai_command)
@@ -957,7 +957,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
root = Path(directory)
runtime_dir = root / "runtime"
runtime_dir.mkdir()
self.create_bundled_sources(root)
self.create_bundled_vendor(root)
uv_path = root / "uv.exe"
uv_path.write_bytes(b"uv")
args = SimpleNamespace(
@@ -995,7 +995,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
self.assertEqual(uv_path.read_bytes(), b"binary")
def test_sync_bundled_sources_copies_missing_archives(self):
def test_sync_bundled_vendor_copies_missing_archives(self):
bootstrap = load_bootstrap_runtime()
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
@@ -1003,29 +1003,48 @@ class BootstrapRuntimeTest(unittest.TestCase):
bundled.mkdir()
(bundled / "depth-anything-3.tar.gz").write_bytes(b"da3")
(bundled / "ben2.tar.gz").write_bytes(b"ben2")
sources = root / "sources"
vendor = root / "vendor"
bootstrap.sync_bundled_sources(bundled, sources)
bootstrap.sync_bundled_vendor(bundled, vendor)
self.assertEqual(
(sources / "depth-anything-3.tar.gz").read_bytes(),
(vendor / "depth-anything-3.tar.gz").read_bytes(),
b"da3",
)
self.assertEqual(
(sources / "ben2.tar.gz").read_bytes(),
(vendor / "ben2.tar.gz").read_bytes(),
b"ben2",
)
def test_sync_bundled_vendor_replaces_same_size_stale_archive(self):
bootstrap = load_bootstrap_runtime()
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
bundled = root / "bundled"
bundled.mkdir()
(bundled / "depth-anything-3.tar.gz").write_bytes(b"new")
(bundled / "ben2.tar.gz").write_bytes(b"ben2")
vendor = root / "vendor"
vendor.mkdir()
(vendor / "depth-anything-3.tar.gz").write_bytes(b"old")
bootstrap.sync_bundled_vendor(bundled, vendor)
self.assertEqual(
(vendor / "depth-anything-3.tar.gz").read_bytes(),
b"new",
)
def test_install_stages_uses_local_source_archives(self):
bootstrap = load_bootstrap_runtime()
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
runtime_dir = root / "runtime"
runtime_dir.mkdir()
sources = root / "sources"
sources.mkdir()
(sources / "depth-anything-3.tar.gz").write_bytes(b"da3")
(sources / "ben2.tar.gz").write_bytes(b"ben2")
vendor = root / "vendor"
vendor.mkdir()
(vendor / "depth-anything-3.tar.gz").write_bytes(b"da3")
(vendor / "ben2.tar.gz").write_bytes(b"ben2")
uv_path = root / "uv"
uv_path.write_bytes(b"uv")
args = SimpleNamespace(
@@ -1051,8 +1070,8 @@ class BootstrapRuntimeTest(unittest.TestCase):
if kind == "install"
and any("depth-anything-3" in str(value) for value in command)
)
da3_local = (sources / "depth-anything-3.tar.gz").as_uri()
ben2_local = (sources / "ben2.tar.gz").as_uri()
da3_local = (vendor / "depth-anything-3.tar.gz").as_uri()
ben2_local = (vendor / "ben2.tar.gz").as_uri()
self.assertIn(f"depth-anything-3 @ {da3_local}", ai_command)
self.assertIn(f"ben2 @ {ben2_local}", ai_command)
@@ -1062,10 +1081,10 @@ class BootstrapRuntimeTest(unittest.TestCase):
root = Path(directory)
runtime_dir = root / "runtime"
runtime_dir.mkdir()
sources = root / "sources"
sources.mkdir()
(sources / "depth-anything-3.tar.gz").write_bytes(b"da3")
(sources / "ben2.tar.gz").write_bytes(b"ben2")
vendor = root / "vendor"
vendor.mkdir()
(vendor / "depth-anything-3.tar.gz").write_bytes(b"da3")
(vendor / "ben2.tar.gz").write_bytes(b"ben2")
uv_path = root / "uv"
uv_path.write_bytes(b"uv")
args = SimpleNamespace(
@@ -1100,7 +1119,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
root = Path(directory)
runtime_dir = root / "runtime"
runtime_dir.mkdir()
self.create_bundled_sources(root)
self.create_bundled_vendor(root)
uv_path = root / "uv"
uv_path.write_bytes(b"uv")
args = SimpleNamespace(
@@ -1213,7 +1232,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
tar.addfile(info, io.BytesIO(content))
with patch.object(
bootstrap,
"bundled_sources_directory",
"bundled_vendor_directory",
return_value=bundled,
):
bootstrap.install_uv(uv_path, str(root / "status.json"))
@@ -1229,7 +1248,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
bundled.mkdir()
with patch.object(
bootstrap,
"bundled_sources_directory",
"bundled_vendor_directory",
return_value=bundled,
):
with self.assertRaisesRegex(