From 4fa166c043ca45359cd7080523b7122e7e0f9d91 Mon Sep 17 00:00:00 2001 From: josiahls Date: Tue, 8 Jul 2025 13:42:57 -0400 Subject: [PATCH] fix: add pyproject.toml to declare torch as a build dependency When installing detectron2 with PEP 517-compliant tools like `uv` or `pip`, the build process fails due to `torch` not being available in the isolated build environment. This results in: ModuleNotFoundError: No module named 'torch' This happens because `setup.py` imports `torch`, but torch isn't declared as a build dependency. Adding a `pyproject.toml` with `torch` listed under `[build-system].requires` ensures that torch is installed into the build environment before running `setup.py`, resolving the issue cleanly. One solution is to have the user install torch before installing the package, but tools such as uv by default leverage build isolation. On the developer's machine this might not be an issue, however in automated ci systems that expect standard uv installation behavior, this becomes problematic. This fix makes the package compatible with modern Python packaging tools that enforce build isolation. --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..e0714967e1 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel", "torch"] +build-backend = "setuptools.build_meta"