From ff5b0ae575082fcd10b9c887390c321a110d2051 Mon Sep 17 00:00:00 2001 From: Emily Banerjee Date: Thu, 8 Feb 2024 19:46:36 +0000 Subject: [PATCH] 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 --- port/PyAssimp/pyassimp/helper.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/port/PyAssimp/pyassimp/helper.py b/port/PyAssimp/pyassimp/helper.py index 7c14f6097a..0ae7cbdff9 100644 --- a/port/PyAssimp/pyassimp/helper.py +++ b/port/PyAssimp/pyassimp/helper.py @@ -5,13 +5,17 @@ """ import os +import platform import ctypes import operator -from distutils.sysconfig import get_python_lib import re 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 except ImportError: numpy = None @@ -32,10 +36,14 @@ if 'LD_LIBRARY_PATH' in os.environ: 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. 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() pattern = re.compile('.*\/lib\/') conda_lib = pattern.match(cur_path).group()