Skip to content

Commit db6565a

Browse files
committed
Fixing windows CI
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
1 parent a4fbfdd commit db6565a

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

src/python-nanobind/__init__.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
os.environ["OpenImageIO_ROOT"] = _here
1515

1616
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+
1725
_bin_dir = os.path.join(_here, "bin")
1826
if os.path.exists(_bin_dir):
1927
os.add_dll_directory(_bin_dir)
@@ -23,7 +31,36 @@
2331
if os.path.exists(path) and path != ".":
2432
os.add_dll_directory(path)
2533

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
2764
from ._OpenImageIO import * # type: ignore # noqa: E402, F401, F403
2865

2966
__doc__ = """

0 commit comments

Comments
 (0)