Fix PyAssimp under Python >= 3.12 and macOS library search support (#5397)

* Fix PyAssimp under Python >= 3.12

* Make PyAssimp search DYLD_LIBRARY_PATH under macOS

---------

Co-authored-by: Kim Kulling <kimkulling@users.noreply.github.com>
pull/5465/head
Emily Banerjee 2024-02-08 19:46:36 +00:00 committed by GitHub
parent 2d98f6a880
commit ff5b0ae575
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 2 deletions

View File

@ -5,13 +5,17 @@ Some fancy helper functions.
""" """
import os import os
import platform
import ctypes import ctypes
import operator import operator
from distutils.sysconfig import get_python_lib
import re import re
import sys import sys
have_distutils = sys.version_info[0] < 3 and sys.version_info[1] < 12
if have_distutils:
from distutils.sysconfig import get_python_lib
try: import numpy try: import numpy
except ImportError: numpy = None except ImportError: numpy = None
@ -33,9 +37,13 @@ if os.name=='posix':
if 'LD_LIBRARY_PATH' in os.environ: if 'LD_LIBRARY_PATH' in os.environ:
additional_dirs.extend([item for item in os.environ['LD_LIBRARY_PATH'].split(':') if item]) additional_dirs.extend([item for item in os.environ['LD_LIBRARY_PATH'].split(':') if item])
if platform.system() == 'Darwin':
if 'DYLD_LIBRARY_PATH' in os.environ:
additional_dirs.extend([item for item in os.environ['DYLD_LIBRARY_PATH'].split(':') if item])
# check if running from anaconda. # check if running from anaconda.
anaconda_keywords = ("conda", "continuum") anaconda_keywords = ("conda", "continuum")
if any(k in sys.version.lower() for k in anaconda_keywords): if have_distutils and any(k in sys.version.lower() for k in anaconda_keywords):
cur_path = get_python_lib() cur_path = get_python_lib()
pattern = re.compile('.*\/lib\/') pattern = re.compile('.*\/lib\/')
conda_lib = pattern.match(cur_path).group() conda_lib = pattern.match(cur_path).group()