Files
termux-packages/packages/python-torchcodec/0001-do-not-try-to-import-torch-when-cross-compiling.patch
termux-pacman-bot 22de250ca8 addpkg(main/python-torchcodec): 0.8.1
- Based loosely on Arch Linux package 316a0781e6/PKGBUILD

- Has been tested and confirmed to work with the example in README https://github.com/meta-pytorch/torchcodec?tab=readme-ov-file#decoding
2025-11-13 07:06:41 +00:00

32 lines
1.4 KiB
Diff

--- a/setup.py
+++ b/setup.py
@@ -46,7 +46,6 @@ import subprocess
import sys
from pathlib import Path
-import torch
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
@@ -108,7 +108,8 @@ class CMakeBuild(build_ext):
def _build_all_extensions_with_cmake(self):
# Note that self.debug is True when you invoke setup.py like this:
# python setup.py build_ext --debug install
- torch_dir = Path(torch.utils.cmake_prefix_path) / "Torch"
+ torch_dir = os.environ.get("TORCH_CMAKE_DIR")
+ python_executable = os.environ.get("PYTHON_EXECUTABLE")
cmake_build_type = os.environ.get("CMAKE_BUILD_TYPE", "Release")
enable_cuda = os.environ.get("ENABLE_CUDA", "")
torchcodec_disable_compile_warning_as_error = os.environ.get(
@@ -118,8 +119,10 @@ class CMakeBuild(build_ext):
cmake_args = [
f"-DCMAKE_INSTALL_PREFIX={self._install_prefix}",
f"-DTorch_DIR={torch_dir}",
+ f"-DCMAKE_PREFIX_PATH=@TERMUX_PREFIX@",
"-DCMAKE_VERBOSE_MAKEFILE=ON",
f"-DCMAKE_BUILD_TYPE={cmake_build_type}",
+ f"-DPython_EXECUTABLE={python_executable}",
f"-DPYTHON_VERSION={python_version.major}.{python_version.minor}",
f"-DENABLE_CUDA={enable_cuda}",
f"-DTORCHCODEC_DISABLE_COMPILE_WARNING_AS_ERROR={torchcodec_disable_compile_warning_as_error}",