Skip to content

Commit 751eac1

Browse files
committed
Add extra paths to the pth file
1 parent 5d4ec0d commit 751eac1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/scikit_build_core/build/wheel.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,19 @@ def _build_wheel_impl(
325325
f"_{normalized_name}_editable.py",
326326
editable_txt.encode("utf-8"),
327327
)
328+
# Support Cython by adding the source directory directly to the path.
329+
# This is necessary because Cython does not support sys.meta_path for
330+
# cimports (as of 3.0.5).
331+
pth_import_paths = (
332+
f"import _{normalized_name}_editable\n"
333+
+ "\n".join(
334+
os.fspath(Path(pkg).parent.resolve()) for pkg in packages
335+
)
336+
+ "\n"
337+
)
328338
wheel.writestr(
329339
f"_{normalized_name}_editable.pth",
330-
f"import _{normalized_name}_editable\n".encode(),
340+
pth_import_paths.encode(),
331341
)
332342

333343
if metadata_directory is not None:

0 commit comments

Comments
 (0)