From 580fe84275410a5e5dbf7109fe57b72a6a896168 Mon Sep 17 00:00:00 2001 From: nan Date: Fri, 18 Sep 2026 19:42:38 +0800 Subject: [PATCH] refactor: update packaging logic to remove local wheel path and improve dependency specifications --- pyproject.toml | 3 --- tests/tools/test_pack.py | 32 +++++++++++++++++++++++++++++--- tools/pack.py | 12 ++++++------ uv.lock | 14 ++++---------- 4 files changed, 39 insertions(+), 22 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5929784..c93c7ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,9 +38,6 @@ build-backend = "hatchling.build" [tool.hatch.build.targets.wheel] packages = ["tools"] -[tool.uv.sources] -blendjob = { path = "src/anyimage/wheels/blendjob-0.1.17-py3-none-any.whl" } - [tool.pytest.ini_options] # Keep native asserts: bpy 4.5 can crash at shutdown after assertion rewriting. addopts = "--assert=plain" diff --git a/tests/tools/test_pack.py b/tests/tools/test_pack.py index 6c25215..677f3f3 100644 --- a/tests/tools/test_pack.py +++ b/tests/tools/test_pack.py @@ -225,7 +225,7 @@ class ExtensionPackagingTest(unittest.TestCase): ): command = call.args[0] self.assertIn("blendjob==0.1.17", command) - self.assertIn(str(pack.SOURCE_DIR / "wheels"), command) + self.assertNotIn(str(pack.SOURCE_DIR / "wheels"), command) self.assertIn(f"--python-version={version}", command) self.assertIn("--implementation=cp", command) self.assertIn(f"--platform={config.pip_platform}", command) @@ -359,7 +359,7 @@ class ExtensionPackagingTest(unittest.TestCase): [], ) - def test_prepare_command_defaults_to_host_and_does_not_build(self): + def test_local_flag_defaults_to_host_and_does_not_build(self): pack = load_pack() with ( patch.object(pack, "current_platform", return_value="windows-x64"), @@ -368,10 +368,36 @@ class ExtensionPackagingTest(unittest.TestCase): ) as prepare, patch.object(pack, "build_all") as build, ): - pack.main(["--prepare"]) + pack.main(["-l"]) prepare.assert_called_once_with("windows-x64") build.assert_not_called() + def test_platform_flag_builds_one_platform(self): + pack = load_pack() + with tempfile.TemporaryDirectory() as directory: + extension = Path(directory) / "AnyImage.v1.0.1.linux-x64.zip" + extension.write_bytes(b"extension") + with ( + patch.object(pack, "build_extension", return_value=extension) as build, + patch.object(pack, "build_all") as build_all, + ): + pack.main(["-p", "linux-x64"]) + build.assert_called_once_with("linux-x64") + build_all.assert_not_called() + + def test_default_command_builds_all_platforms(self): + pack = load_pack() + with tempfile.TemporaryDirectory() as directory: + extension = Path(directory) / "AnyImage.v1.0.1.windows-x64.zip" + extension.write_bytes(b"extension") + with ( + patch.object(pack, "build_all", return_value=[extension]) as build_all, + patch.object(pack, "build_extension") as build_extension, + ): + pack.main([]) + build_all.assert_called_once_with() + build_extension.assert_not_called() + def test_detects_supported_hosts(self): pack = load_pack() for system, machine, expected in ( diff --git a/tools/pack.py b/tools/pack.py index a7aacd8..5563ef0 100644 --- a/tools/pack.py +++ b/tools/pack.py @@ -70,8 +70,6 @@ def download_wheels(platform, destination): numpy_requirement, "--dest", str(target_directory), - "--find-links", - str(SOURCE_DIR / "wheels"), "--only-binary=:all:", f"--python-version={python_version}", "--implementation=cp", @@ -217,20 +215,22 @@ def build_all(): def main(argv=None): parser = argparse.ArgumentParser( - description="Prepare local dependencies or pack Blender extensions" + description="Pack Blender extensions or prepare local dependencies" ) parser.add_argument( - "--prepare", + "-l", + "--local", action="store_true", help="Update source wheels and Manifest for local testing", ) parser.add_argument( + "-p", "--platform", choices=PLATFORMS, - help="Target platform; preparation defaults to this computer", + help="Build one platform; --local defaults to this computer", ) args = parser.parse_args(argv) - if args.prepare: + if args.local: platform = args.platform or current_platform() wheels = prepare_local_dependencies(platform) print( diff --git a/uv.lock b/uv.lock index fd45632..c942ab2 100644 --- a/uv.lock +++ b/uv.lock @@ -40,7 +40,7 @@ dev = [ [package.metadata] requires-dist = [ - { name = "blendjob", path = "src/anyimage/wheels/blendjob-0.1.17-py3-none-any.whl" }, + { name = "blendjob", specifier = "==0.1.17" }, { name = "numpy", specifier = ">=1.26,<2.0" }, { name = "scipy", specifier = "==1.15.3" }, ] @@ -97,18 +97,12 @@ wheels = [ [[package]] name = "blendjob" version = "0.1.17" -source = { path = "src/anyimage/wheels/blendjob-0.1.17-py3-none-any.whl" } +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/bc/27/68328383ae48c33d2e9f570c9496601e266d629e72b6dbb00757c62e50a7/blendjob-0.1.17.tar.gz", hash = "sha256:fa3be5a0341a032dbc7342ae578f361c19104b3eb8106e881334631fb2443d72", size = 21699, upload-time = "2026-09-10T04:38:09.519Z" } wheels = [ - { filename = "blendjob-0.1.17-py3-none-any.whl", hash = "sha256:a300ff10972953e1e930072edf33eed5e0f9342c83b30311341c7a6581c98e95" }, + { url = "https://files.pythonhosted.org/packages/ad/ad/42b749a762a5e49c63ee3e48f9583e310cc1a57fba68dae4332c60b36a8d/blendjob-0.1.17-py3-none-any.whl", hash = "sha256:a300ff10972953e1e930072edf33eed5e0f9342c83b30311341c7a6581c98e95", size = 27060, upload-time = "2026-09-10T04:38:08.698Z" }, ] -[package.metadata] -requires-dist = [ - { name = "fastapi", marker = "extra == 'server'", specifier = "==0.139.2" }, - { name = "uvicorn", marker = "extra == 'server'", specifier = "==0.51.0" }, -] -provides-extras = ["server"] - [[package]] name = "bpy" version = "4.5.3"