Skip to content

Commit

Permalink
Merge pull request #221 from Li-Xiang-Ideal/patch-1
Browse files Browse the repository at this point in the history
Update __init__.py
  • Loading branch information
liZe committed Mar 11, 2024
2 parents f1984d6 + 3e3dafd commit 290b5db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cairocffi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"""

import os
import sys
from contextlib import suppress
from ctypes.util import find_library

from . import constants
Expand All @@ -21,6 +23,17 @@
version_info = (1, 17, 2)


# Python 3.8 no longer searches for DLLs in PATH, so we can add everything in
# CAIROCFFI_DLL_DIRECTORIES manually. Note that unlike PATH, add_dll_directory
# has no defined order, so if there are two cairo DLLs in PATH we might get a
# random one.
dll_directories = os.getenv('CAIROCFFI_DLL_DIRECTORIES')
if dll_directories and hasattr(os, 'add_dll_directory'):
for path in dll_directories.split(';'):
with suppress((OSError, FileNotFoundError)):
os.add_dll_directory(path)


def dlopen(ffi, library_names, filenames):
"""Try various names for the same library, for different platforms."""
exceptions = []
Expand Down
4 changes: 4 additions & 0 deletions docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ If it fails to find it, you will see an exception like this::

Make sure cairo is correctly installed and available through your system’s
usual mechanisms.

On Linux, the ``LD_LIBRARY_PATH`` environment variable can be used to indicate
where to find shared libraries.

On Windows, you can put the folder where Cairo and other DLLs are installed in
the ``CAIROCFFI_DLL_DIRECTORIES`` environment variable.

.. _Pycairo: http://cairographics.org/pycairo/


Expand Down

0 comments on commit 290b5db

Please sign in to comment.