Skip to content

Fix native REPL search path #25372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions python_files/python_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import traceback
import uuid
from pathlib import Path
from typing import Dict, List, Optional, Union

STDIN = sys.stdin
Expand Down Expand Up @@ -172,6 +173,12 @@ def get_headers():


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