Skip to content

Commit 35fbd73

Browse files
committed
Fix native REPL search path
1 parent 11fa35d commit 35fbd73

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

python_files/python_server.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sys
66
import traceback
77
import uuid
8+
from pathlib import Path
89
from typing import Dict, List, Optional, Union
910

1011
STDIN = sys.stdin
@@ -172,6 +173,12 @@ def get_headers():
172173

173174

174175
if __name__ == "__main__":
176+
# https://docs.python.org/3/tutorial/modules.html#the-module-search-path
177+
# The directory containing the input script (or the current directory when no file is specified).
178+
# Here we emulate the same behavior like no file is specified.
179+
input_script_dir = Path(__file__).parent
180+
sys.path.remove(str(input_script_dir))
181+
sys.path.insert(0, str(Path.cwd()))
175182
while not STDIN.closed:
176183
try:
177184
headers = get_headers()

0 commit comments

Comments
 (0)