Description: Use sox and ffmpeg from system
Author: Shengqi Chen <harry@debian.org>
Forwarded: not-needed
Last-Update: 2025-02-19 
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/setup.py
+++ b/setup.py
@@ -76,7 +76,8 @@
     for dest, url in src:
         if not dest.exists():
             print(f" --- Fetching {os.path.basename(dest)}")
-            torch.hub.download_url_to_file(url, dest, progress=False)
+            #torch.hub.download_url_to_file(url, dest, progress=False)
+            print(f" --- Fetching skipped for Debian build")
 
 
 def _main():
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -167,7 +167,8 @@
 
 add_subdirectory(src/libtorchaudio)
 if (BUILD_SOX)
-  add_subdirectory(third_party/sox)
+  find_package(PkgConfig REQUIRED)
+  pkg_check_modules(SOX REQUIRED IMPORTED_TARGET sox)
   add_subdirectory(src/libtorchaudio/sox)
 endif()
 if (USE_FFMPEG)
--- a/src/libtorchaudio/sox/CMakeLists.txt
+++ b/src/libtorchaudio/sox/CMakeLists.txt
@@ -10,7 +10,7 @@
   libtorchaudio_sox
   "${sources}"
   ""
-  "torch;sox"
+  "torch;PkgConfig::SOX"
   ""
   )
 
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-2.6.0a0
+2.6.0
--- a/third_party/ffmpeg/single/CMakeLists.txt
+++ b/third_party/ffmpeg/single/CMakeLists.txt
@@ -6,31 +6,17 @@
   message(FATAL_ERROR "Environment variable FFMPEG_ROOT is not set.")
 endif()
 
-set(_root $ENV{FFMPEG_ROOT})
-set(lib_dirs "${_root}/lib" "${_root}/bin")
-set(include_dir "${_root}/include")
-
+find_package(PkgConfig REQUIRED)
 add_library(ffmpeg INTERFACE)
-target_include_directories(ffmpeg INTERFACE "${include_dir}")
 
 function (_find_ffmpeg_lib component)
-  find_path("${component}_header"
-    NAMES "lib${component}/${component}.h"
-    PATHS "${include_dir}"
-    DOC "The include directory for ${component}"
-    REQUIRED
-    NO_DEFAULT_PATH)
-  find_library("lib${component}"
-    NAMES "${component}"
-    PATHS ${lib_dirs}
-    DOC "${component} library"
-    REQUIRED
-    NO_DEFAULT_PATH)
-  message(STATUS "Found ${component}: ${lib${component}}")
+  pkg_check_modules("${component}" REQUIRED "lib${component}")
+  message(STATUS "Found ${component}: ${component}")
+  target_include_directories(ffmpeg INTERFACE "${component}_INCLUDE_DIRS")
   target_link_libraries(
     ffmpeg
     INTERFACE
-    ${lib${component}})
+    "${component}_LIBRARIES")
 endfunction ()
 
 _find_ffmpeg_lib(avutil)
