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

@@ -3,6 +3,7 @@ import importlib.util
import io
import tarfile
import tempfile
import tomllib
import unittest
from pathlib import Path
from zipfile import ZipFile
@@ -32,13 +33,16 @@ class PackTest(unittest.TestCase):
finally:
pack.DIST_DIR = original_dist
version = tomllib.loads(
(pack.SOURCE_DIR / "blender_manifest.toml").read_text(
encoding="utf-8"
)
)["version"]
self.assertEqual(
{path.name for path in output_paths},
{
"SnapForm.v0.10.10.windows-x64.zip",
"SnapForm.v0.10.10.macos-x64.zip",
"SnapForm.v0.10.10.macos-arm64.zip",
"SnapForm.v0.10.10.linux-x64.zip",
f"SnapForm.v{version}.{platform}.zip"
for platform in pack.PLATFORMS
},
)
for output_path in output_paths:
@@ -56,12 +60,24 @@ class PackTest(unittest.TestCase):
self.assertIn("ai_host.py", names)
self.assertNotIn("snapform/__init__.py", names)
self.assertNotIn("importer.py", names)
self.assertIn("sources/depth-anything-3.tar.gz", names)
self.assertIn("sources/ben2.tar.gz", names)
self.assertIn("vendor/depth-anything-3.tar.gz", names)
self.assertIn("vendor/ben2.tar.gz", names)
self.assertIn(
f"sources/{pack.PLATFORMS[platform]}",
f"vendor/{pack.PLATFORMS[platform]}",
names,
)
self.assertFalse(
any(name.startswith("sources/") for name in names)
)
bundled_uv = {
name
for name in names
if name.startswith("vendor/uv-")
}
self.assertEqual(
bundled_uv,
{f"vendor/{pack.PLATFORMS[platform]}"},
)
self.assertIn(f'platforms = ["{platform}"]', manifest)
self.assertNotIn(
"windows-x64"
@@ -75,11 +91,24 @@ class PackTest(unittest.TestCase):
with self.assertRaisesRegex(ValueError, "Unsupported platform"):
pack.build_extension("windows-arm64")
def test_platforms_match_manifest(self):
pack = load_pack()
manifest = tomllib.loads(
(pack.SOURCE_DIR / "blender_manifest.toml").read_text(
encoding="utf-8"
)
)
self.assertEqual(set(pack.PLATFORMS), set(manifest["platforms"]))
self.assertEqual(
set(pack.PLATFORMS),
{"windows-x64", "macos-arm64", "linux-x64"},
)
def test_bundled_depth_anything_3_has_no_xformers_dependency(self):
pack = load_pack()
with tarfile.open(
fileobj=io.BytesIO(
pack.bundled_source_bytes("depth-anything-3.tar.gz")
pack.bundled_artifact_bytes("depth-anything-3.tar.gz")
),
mode="r:gz",
) as archive:
@@ -95,7 +124,7 @@ class PackTest(unittest.TestCase):
pack = load_pack()
with tarfile.open(
fileobj=io.BytesIO(
pack.bundled_source_bytes("depth-anything-3.tar.gz")
pack.bundled_artifact_bytes("depth-anything-3.tar.gz")
),
mode="r:gz",
) as archive:
@@ -116,7 +145,7 @@ class PackTest(unittest.TestCase):
def test_official_depth_anything_3_baseline_is_pristine(self):
pack = load_pack()
archive_path = pack.SOURCES_DIR / "depth-anything-3.tar.gz"
archive_path = pack.VENDOR_DIR / "depth-anything-3.tar.gz"
with tarfile.open(archive_path, "r:gz") as archive:
raw_pyproject = archive.extractfile(
"Depth-Anything-3-3d835ec1a5802d64a8b8b15f817a1ab54809bfe4/"
@@ -138,7 +167,7 @@ class PackTest(unittest.TestCase):
pack = load_pack()
with tarfile.open(
fileobj=io.BytesIO(
pack.bundled_source_bytes("depth-anything-3.tar.gz")
pack.bundled_artifact_bytes("depth-anything-3.tar.gz")
),
mode="r:gz",
) as archive:
@@ -152,7 +181,7 @@ class PackTest(unittest.TestCase):
def test_official_depth_anything_3_ray_utils_is_pristine(self):
pack = load_pack()
archive_path = pack.SOURCES_DIR / "depth-anything-3.tar.gz"
archive_path = pack.VENDOR_DIR / "depth-anything-3.tar.gz"
with tarfile.open(archive_path, "r:gz") as archive:
source = archive.extractfile(
"Depth-Anything-3-3d835ec1a5802d64a8b8b15f817a1ab54809bfe4/"