| 1 | import os |
| 2 | |
| 3 | |
| 4 | def set_dll_search_path(): |
| 5 | # Python 3.8 no longer searches for DLLs in PATH, so we have to add |
| 6 | # everything in PATH manually. Note that unlike PATH add_dll_directory |
| 7 | # has no defined order, so if there are two cairo DLLs in PATH we |
| 8 | # might get a random one. |
| 9 | if os.name != "nt" or not hasattr(os, "add_dll_directory"): |
| 10 | return |
| 11 | for p in os.environ.get("PATH", "").split(os.pathsep): |
| 12 | try: |
| 13 | os.add_dll_directory(p) |
| 14 | except OSError: |
| 15 | pass |
| 16 | |
| 17 | |
| 18 | set_dll_search_path() |