nixpkgs/pkgs/development/python-modules/nextcord/paths.patch
Andrew Morgan d6673a51bc python3Packages.nextcord: fix issue with loading libopus
The substitution patch used to point nextcord to the installed location
of libopus in nix's store was incorrectly formatted:

* `@opus@` was used while default.nix attempted to substitute instances of
  `@libopus@`.
* `ctypes.util.find_library(<library_name>)` will return a path to a
  library. If we already have the path (provided by the substitution),
  then `find_library` is not necessary to call (nor will it produce the
  desired result).
2022-07-16 07:21:25 +00:00

72 lines
2.4 KiB
Diff

diff --git a/nextcord/opus.py b/nextcord/opus.py
index 52e4ddbd..d8b8090b 100644
--- a/nextcord/opus.py
+++ b/nextcord/opus.py
@@ -255,7 +255,7 @@ def _load_default() -> bool:
_filename = os.path.join(_basedir, "bin", f"libopus-0.{_target}.dll")
_lib = libopus_loader(_filename)
else:
- opus = ctypes.util.find_library("opus")
+ opus = "@libopus@"
if opus is None:
_lib = None
diff --git a/nextcord/player.py b/nextcord/player.py
index 5d0674cc..fd1c20ef 100644
--- a/nextcord/player.py
+++ b/nextcord/player.py
@@ -148,7 +148,7 @@ class FFmpegAudio(AudioSource):
self,
source: Union[str, io.BufferedIOBase],
*,
- executable: str = "ffmpeg",
+ executable: str = "@ffmpeg@",
args: Any,
**subprocess_kwargs: Any,
):
@@ -275,7 +275,7 @@ class FFmpegPCMAudio(FFmpegAudio):
self,
source: Union[str, io.BufferedIOBase],
*,
- executable: str = "ffmpeg",
+ executable: str = "@ffmpeg@",
pipe: bool = False,
stderr: Optional[IO[str]] = None,
before_options: Optional[str] = None,
@@ -378,7 +378,7 @@ class FFmpegOpusAudio(FFmpegAudio):
*,
bitrate: int = 128,
codec: Optional[str] = None,
- executable: str = "ffmpeg",
+ executable: str = "@ffmpeg@",
pipe=False,
stderr=None,
before_options=None,
@@ -532,7 +532,7 @@ class FFmpegOpusAudio(FFmpegAudio):
"""
method = method or "native"
- executable = executable or "ffmpeg"
+ executable = executable or "@ffmpeg@"
probefunc = fallback = None
if isinstance(method, str):
@@ -577,7 +577,7 @@ class FFmpegOpusAudio(FFmpegAudio):
@staticmethod
def _probe_codec_native(
- source, executable: str = "ffmpeg"
+ source, executable: str = "@ffmpeg@"
) -> Tuple[Optional[str], Optional[int]]:
exe = executable[:2] + "probe" if executable in ("ffmpeg", "avconv") else executable
args = [
@@ -606,7 +606,7 @@ class FFmpegOpusAudio(FFmpegAudio):
@staticmethod
def _probe_codec_fallback(
- source, executable: str = "ffmpeg"
+ source, executable: str = "@ffmpeg@"
) -> Tuple[Optional[str], Optional[int]]:
args = [executable, "-hide_banner", "-i", source]
proc = subprocess.Popen(