-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setting up pyproject and runtime redirections apropriately
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
A shim necessary to make maturin dev builds work properly. | ||
Our maturin builds stick our package inside of a "rerun_sdk" folder | ||
to avoid conflicting with the non-rerun "rerun" package. In released | ||
builds, we include a rerun_sdk.pth file that makes things work properly, | ||
but that doesn't work in dev builds where maturin generates its own | ||
.pth file that points 1 level too high. | ||
When we encounter this file on import, we instead redirect to the | ||
real rerun module by adding it to the path and then, and then | ||
replacing our own module content with it. | ||
""" | ||
from __future__ import annotations | ||
|
||
import pathlib | ||
import sys | ||
|
||
real_path = pathlib.Path(__file__).parent.parent.joinpath("rerun_sdk").resolve() | ||
|
||
print(f"DEV ENVIRONMENT DETECTED! Re-importing rerun2 from: {real_path}", file=sys.stderr) | ||
|
||
sys.path.insert(0, str(real_path)) | ||
|
||
del sys.modules["rerun2"] | ||
sys.modules["rerun2"] = __import__("rerun2") |