-
Notifications
You must be signed in to change notification settings - Fork 302
Description
As it currently sits, python-magic does not allow the user to customize the full path to magic.
This is kind of okay on a linux host, as you can set LD_LIBRARY_PATH and ctypes.util.find_library will respect this. On MacOS though, this is not the case.
This makes using python-magic on a macOS host with a nix-managed development tree quite hard.
One needs to either symlink some files around (and know that nix might cleanup the path at any arbitrary garbage collection) or install magic via homebrew (which I personally do not use otherwise) because there's a fixed set of places to look in specified by hand.
It seems to me that something like the following might help (at the top of loader.py:
def _lib_candidates():
user_set_magic_path = os.environ.get("PYTHON_MAGIC_SO_PATH") # Maybe someone has a better name?
if user_set_magic_path:
yield find_lib(user_set_magic_path)
yield find_library('magic')
# ... rest of function bodyI'm happy to put a PR together for this if someone can give me the word on what the environment variable should be called.