Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ override-dependencies = [
"onnxruntime ; sys_platform == 'unobtainium'",
]

[[tool.uv.index]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
explicit = true

[tool.uv.sources]
torch = [
{ index = "pytorch-cpu", marker = "sys_platform == 'linux' and platform_machine == 'x86_64'" },
]
torchvision = [
{ index = "pytorch-cpu", marker = "sys_platform == 'linux' and platform_machine == 'x86_64'" },
]

[dependency-groups]
dev = [
"jupyter>=1.1.1",
Expand Down
40 changes: 40 additions & 0 deletions tests/unit/test_uv_lock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------

from __future__ import annotations

from pathlib import Path
from typing import Any

import tomllib


DISALLOWED_ACCELERATOR_PACKAGE_PREFIXES = ("cuda-", "nvidia-")


def _dependency_name(dependency: str | dict[str, Any]) -> str:
if isinstance(dependency, str):
return dependency
return str(dependency["name"])


def test_uv_lock_does_not_include_cuda_accelerator_packages() -> None:
lock_path = Path(__file__).resolve().parents[2] / "uv.lock"
lock_data = tomllib.loads(lock_path.read_text(encoding="utf-8"))

disallowed_refs: set[str] = set()
for package in lock_data["package"]:
package_name = str(package["name"])
if package_name.startswith(DISALLOWED_ACCELERATOR_PACKAGE_PREFIXES):
disallowed_refs.add(package_name)

for dependency in package.get("dependencies", []):
dependency_name = _dependency_name(dependency)
if dependency_name.startswith(DISALLOWED_ACCELERATOR_PACKAGE_PREFIXES):
disallowed_refs.add(f"{package_name} -> {dependency_name}")

assert not disallowed_refs, "Unexpected CUDA/NVIDIA lock entries: " + ", ".join(
sorted(disallowed_refs)
)
Loading
Loading