Skip to content

Commit

Permalink
[package] work around Conda bug which breaks DLL loading (fixes: PyAV…
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaine committed Apr 19, 2022
1 parent b1701f5 commit a92ab78
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions av/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# Add the native FFMPEG and MinGW libraries to executable path, so that the
# AV pyd files can find them.
import os
import sys

if os.name == "nt":
# Some Python versions distributed by Conda have a buggy `os.add_dll_directory`
# which prevents binary wheels from finding the FFmpeg DLLs in the `av.libs`
# directory. We work around this by adding `av.libs` to the PATH.
if (
os.name == "nt"
and sys.version_info[:2] in ((3, 8), (3, 9))
and os.path.exists(os.path.join(sys.base_prefix, "conda-meta"))
):
os.environ["PATH"] = (
os.path.abspath(os.path.dirname(__file__)) + os.pathsep + os.environ["PATH"]
os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, "av.libs"))
+ os.pathsep
+ os.environ["PATH"]
)

# MUST import the core before anything else in order to initalize the underlying
Expand Down

0 comments on commit a92ab78

Please sign in to comment.