refactor: update packaging logic to remove local wheel path and improve dependency specifications

This commit is contained in:
2026-09-18 19:42:38 +08:00
parent 122f609156
commit 580fe84275
4 changed files with 39 additions and 22 deletions

View File

@@ -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"

View File

@@ -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 (

View File

@@ -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(

14
uv.lock generated
View File

@@ -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"