|
14 | 14 | os.environ["OpenImageIO_ROOT"] = _here |
15 | 15 |
|
16 | 16 | if platform.system() == "Windows": |
| 17 | + # MSVC multi-config builds often put _OpenImageIO*.pyd under OpenImageIO/<Config>/ |
| 18 | + # while this __init__.py lives in OpenImageIO/. Extend the package search path |
| 19 | + # so `from . import _OpenImageIO` resolves (no CMake per-config output juggling). |
| 20 | + for _cfg in ("Release", "Debug", "RelWithDebInfo", "MinSizeRel"): |
| 21 | + _subdir = os.path.join(_here, _cfg) |
| 22 | + if os.path.isdir(_subdir) and _subdir not in __path__: |
| 23 | + __path__.append(_subdir) |
| 24 | + |
17 | 25 | _bin_dir = os.path.join(_here, "bin") |
18 | 26 | if os.path.exists(_bin_dir): |
19 | 27 | os.add_dll_directory(_bin_dir) |
|
23 | 31 | if os.path.exists(path) and path != ".": |
24 | 32 | os.add_dll_directory(path) |
25 | 33 |
|
26 | | -from . import _OpenImageIO as _ext # noqa: E402 |
| 34 | +try: |
| 35 | + from . import _OpenImageIO as _ext # noqa: E402 |
| 36 | +except ImportError as _import_err: |
| 37 | + # TODO Debugging to be removed before merge |
| 38 | + try: |
| 39 | + _nb_paths = list(__path__) |
| 40 | + except NameError: |
| 41 | + _nb_paths = [] |
| 42 | + _nb_cfg_dirs = {} |
| 43 | + for _cfg in ("Release", "Debug", "RelWithDebInfo", "MinSizeRel"): |
| 44 | + _p = os.path.join(_here, _cfg) |
| 45 | + if os.path.isdir(_p): |
| 46 | + try: |
| 47 | + _nb_cfg_dirs[_cfg] = os.listdir(_p) |
| 48 | + except OSError as _oe: |
| 49 | + _nb_cfg_dirs[_cfg] = "<OSError: %s>" % (_oe,) |
| 50 | + print( |
| 51 | + "[OpenImageIO nanobind] import _OpenImageIO failed: %s\n __file__=%r\n _here=%r\n" |
| 52 | + " __path__=%r\n listdir(_here)=%r\n listdir per-config subdirs=%r" |
| 53 | + % ( |
| 54 | + _import_err, |
| 55 | + __file__, |
| 56 | + _here, |
| 57 | + _nb_paths, |
| 58 | + os.listdir(_here) if os.path.isdir(_here) else None, |
| 59 | + _nb_cfg_dirs, |
| 60 | + ), |
| 61 | + file=sys.stderr, |
| 62 | + ) |
| 63 | + raise |
27 | 64 | from ._OpenImageIO import * # type: ignore # noqa: E402, F401, F403 |
28 | 65 |
|
29 | 66 | __doc__ = """ |
|
0 commit comments